Skip to main content Switch to mobile version lakehouse-doctor 0.7.1 Zero-cluster offline SQL static auditor, column-level lineage analyzer, and AI Agent toolkit for Apache Doris, StarRocks, Apache Paimon, and Flink SQL.
pip install lakehouse-doctor==0.7.1 Copy PIP instructions
面向 Apache Doris、StarRocks、Apache Paimon 与 Flink SQL 的离线 SQL 静态审计、字段级血缘分析、Query Profile 诊断、DQC 生成工具与 MCP 服务。
lakehouse-doctor 无需连接真实数据库集群,通过解析项目中的 CREATE TABLE 建表语句构建内存元数据目录(Catalog),在此基础上执行 Schema-Aware AST 静态检查、跨文件字段血缘影响面追踪与执行计划剖析。
catalog:解析 Doris、StarRocks、Paimon 及 Flink SQL 建表语句,提取字段类型族(含 DECIMALV3/DATEV2)、主键/分桶/分区键(含 AUTO PARTITION / date_trunc 表达式分区)与引擎属性;支持通过 --dsn 只读拉取线上 FE 缺失的 DDL 补全目录。
audit:兼容调度宏变量(${biz_date}、#{dt}、{{ ds }}、{{ ref(...) }} 与裸 $var)及 UTF-8/GB18030/latin-1 编码,运行语法/DDL/DML 审计规则(LH001、LH101–LH106、LH201–LH212),支持行内豁免注释(-- lh-doctor: disable=... / -- noqa)、健康分卡(Scorecard)、可选只读 --dsn ... --explain(LE001)校验及文本/JSON/SARIF 2.1.0 输出。
lineage / impact:穿透 CTE、CREATE VIEW、SELECT * 与 UNION ALL 构建 ODS → DWD → DWS → ADS 表级与字段级血缘,区分 DIRECT/DERIVED/FILTER 依赖边语义,支持上下游变更影响分析(--upstream 快捷溯源),并导出 Mermaid、JSON 或单文件交互式 HTML。
profile:解析 Doris(含 PipelineX MergedProfile)与 StarRocks 3.x 慢查询 Query Profile(LP001–LP009),定位实例倾斜、算子等待阻塞、低效 Scan、Hash Join Build/Probe 大小表颠倒、高基数预聚合失效、Broadcast 内存膨胀与磁盘 Spill,支持 --diff 调优前后对比、终端火焰图、--format ai-json 与单文件 HTML 报告。
dqc:结合主键约束与血缘依赖,一键生成新鲜度、主键唯一性、非空、非负指标及上下游行数对账 SQL。
mcp & skills/:内置标准库 stdio MCP Server(lh-doctor mcp)与开放标准 Agent Skills。
方式一:发给你的 AI Agent 自动装好(推荐)
直接复制下面这段话发给 Claude Code / Codex / WorkBuddy / Qoder / DeepSeek Harness 等支持 MCP 和 Skills 的编程助手,让它直接从 PyPI 安装、配好 MCP 并跑通首轮体检:
请帮我把 lakehouse-doctor 接入到当前环境(仓库地址:https://github.com/tolgerx/lakehouse-doctor): 1. 直接从 PyPI 安装(`pip install lakehouse-doctor`,如需 `--dsn` 只读连 FE 则装 `pip install "lakehouse-doctor[online]"`;也可使用 `uvx lakehouse-doctor` 免安装运行); 2. 将 `lh-doctor mcp`(或 `uvx lakehouse-doctor mcp`)配进我的 MCP Server 配置,如需使用内置 `skills/*` 可从仓库拉取并关联到 Skills 目录; 3. 完成后调用 `lh-doctor audit`(或 MCP 工具 `audit_sql`)对我当前项目的 SQL 目录做一次检查并汇报结果。 方式二:命令行安装
# 推荐直接从 PyPI 安装 pip install lakehouse-doctor # 如需启用只读 FE 建表补全与在线 EXPLAIN(--dsn / --explain) pip install "lakehouse-doctor[online]" # 或使用 uvx 免安装运行(MCP 可直接配 command: "uvx", args: ["lakehouse-doctor", "mcp"]) uvx lakehouse-doctor --help 如需运行仓库内置的 4 层 Paimon + Doris 示例项目(examples/ecommerce_lakehouse)与示例 Profile(examples/profiles):
git clone https://github.com/tolgerx/lakehouse-doctor.git cd lakehouse-doctor lh-doctor catalog examples/ecommerce_lakehouse lh-doctor audit examples/ecommerce_lakehouse lh-doctor impact examples/ecommerce_lakehouse --column ods_orders.pay_amount lh-doctor impact examples/ecommerce_lakehouse --column ads_gmv_dashboard.total_gmv --upstream lh-doctor lineage examples/ecommerce_lakehouse --format html --output lineage.html lh-doctor profile examples/profiles/doris_skewed_broadcast_join.txt lh-doctor profile examples/profiles/doris_skewed_broadcast_join.txt --diff examples/profiles/doris_skewed_broadcast_join_tuned.txt lh-doctor dqc examples/ecommerce_lakehouse --table dwd_order_detail 输出示例
lh-doctor audit examples/ecommerce_lakehouse
Lakehouse Doctor Audit (files: 8, catalog tables: 5) Summary: 3 CRITICAL | 9 WARNING | 1 INFO Health Score: 9/100 (Grade F) [CRITICAL] LH203 dml/01_dwd_load_order_detail.sql:13 - Implicit type cast in JOIN/WHERE comparison SQL: ON o.user_id = u.id Why: Implicit cast in `o.user_id = u.id`: `ods_orders.user_id` (VARCHAR(64)) vs `ods_users.id` (BIGINT). Fix: Align column types in DDL or explicitly `CAST(o.user_id AS BIGINT)` before joining. [CRITICAL] LH201 dml/01_dwd_load_order_detail.sql:15 - Partition pruning disabled by function wrap SQL: WHERE DATE_FORMAT(o.dt, '%Y-%m') = '2026-11' Why: Partition column `o.dt` is wrapped in `TIME_TO_STR(CAST(o.dt AS TIMESTAMP), '%Y-%m')`, disabling partition pruning. Fix: Rewrite using a half-open range predicate directly on `o.dt` (e.g. `o.dt >= '2026-11-01' AND o.dt < '2026-12-01'`). [CRITICAL] LH202 dml/03_ads_gmv_report.sql:4 - Missing partition filter on partitioned table SQL: SELECT * FROM dws_user_order_1d Why: Partitioned table `dws_user_order_1d` (partitioned by `dt`) is scanned without a partition predicate. Fix: Add a filter on `dt` in `WHERE` (or `JOIN ... ON` for outer-joined tables). lh-doctor impact examples/ecommerce_lakehouse --column ods_orders.pay_amount
Impact Analysis (downstream): ods_orders.pay_amount -> 3 affected target(s) [Hop 1 | DWD] dwd_order_detail.pay_amount [DIRECT] Path: ods_orders.pay_amount -> dwd_order_detail.pay_amount [Hop 2 | DWS] dws_user_order_1d.total_gmv [DERIVED] Path: ods_orders.pay_amount -> dwd_order_detail.pay_amount -> dws_user_order_1d.total_gmv [Hop 3 | ADS] ads_gmv_dashboard.total_gmv [DERIVED] Path: ods_orders.pay_amount -> dwd_order_detail.pay_amount -> dws_user_order_1d.total_gmv -> ads_gmv_dashboard.total_gmv lh-doctor profile examples/profiles/doris_skewed_broadcast_join.txt
Lakehouse Doctor Query Profile (engine: DORIS, total: 14.82s, operators: 5, findings: 6) Query ID: 9f4c2b8a-7e11-4d3a-9c52-88a1e72b1104 [CRITICAL] LP001 Fragment 1 / HASH_JOIN_OPERATOR (id=4) - Severe instance data skew Why: Operator `HASH_JOIN_OPERATOR (id=4)` exhibits 7.9x time skew (max=9820ms vs avg=1240ms) and 8.7x row skew. [CRITICAL] LP002 Fragment 1 / HASH_JOIN_OPERATOR (id=4) - Dominant execution bottleneck operator Why: Operator `HASH_JOIN_OPERATOR (id=4)` accounts for 64.8% of operator max time (max=9820ms). [CRITICAL] LP004 Fragment 1 / HASH_JOIN_OPERATOR (id=4) - Heavy BROADCAST join memory/fan-out risk Why: BROADCAST join `HASH_JOIN_OPERATOR (id=4)` reached 2.85 GB peak memory and processed 84.5M probe/read rows. lh-doctor dqc examples/ecommerce_lakehouse --table dwd_order_detail
SELECT 'DQC_PK_UNIQUE_DWD_ORDER_DETAIL' AS check_id, 'dwd_order_detail' AS table_name, COUNT(*) - COUNT(DISTINCT CONCAT_WS('#', order_id, dt)) AS metric_value, CASE WHEN COUNT(*) = COUNT(DISTINCT CONCAT_WS('#', order_id, dt)) THEN 'PASS' ELSE 'FAIL' END AS status FROM dwd_order_detail WHERE dt = '${biz_date}'; 规则清单
GitHub PR 自动门禁:复制 .github/workflows/sql-guard-template.yml 即可在 PR 中上传 SARIF 扫描结果并自动评论违规 SQL。
项目级配置与行内豁免:运行 lh-doctor init 生成 .lh-doctor.toml(示例见 .lh-doctor.toml.example),可自定义规则开关 ignore、严重级别覆盖、max_buckets、分区列名与目录排除 exclude;同时支持 SQL 行内豁免注释(-- lh-doctor: disable=LH203、disable-file、disable-next-line、-- noqa)。
内置 Agent Skills (skills/) 与斜杠命令 (.claude/commands/):包含 doris-starrocks-modeling、paimon-flink-lakehouse、lakehouse-sql-and-profile-tuning、lakehouse-lineage-and-dqc 及 /lh-audit、/lh-profile、/lh-impact。
MCP 工具清单 (lh-doctor mcp):参考 examples/mcp_config.json,暴露 audit_sql、inspect_catalog、trace_impact、analyze_profile、compare_profiles、generate_dqc。
Both files in this release have provenance metadata.
Development Status 3 - Alpha
Intended Audience Developers
License OSI Approved :: MIT License
Programming Language Python :: 3
Software Development :: Quality Assurance
Release files for lakehouse-doctor 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 189.0 kB
Release files / lakehouse_doctor-0.7.1.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Security for lakehouse-doctor 0.7.1
Both files in this release have been uploaded with provenance metadata.
With provenance lakehouse_doctor-0.7.1.tar.gz Dec 1, 2026
Attestation for lakehouse_doctor-0.7.1.tar.gz
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Dec 3, 2026 2 release files Full provenance
Dec 2, 2026 2 release files Full provenance
Dec 1, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




