hive-sql-lineage
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "hive-sql-lineage" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-4376368e7f42abaddff9e8148ccb43610436e3070a398153d6c7fa3e82ab2539. Verify the upstream source and version against https://skillhub.cn/skills/user_1cc6a194/hive-sql-lineage before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
ODPS/Hive SQL lineage and knowledge-graph CLI: uses SQLGlot to automatically scan INSERT/SELECT/FROM/JOIN and extract table-level lineage dependencies, integrates Graphify to build a code knowledge graph, and supports column-level provenance, impact analysis, and upstream/downstream dependency queries. Intended for understanding, refactoring, or reviewing large SQL projects and table dependencies.
Introduction source: third_party · user_1cc6a194 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Inputs and outputs
- Translation pending; see source documentation.
- Software, accounts and paid services
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: sql-analysis
description: CLI 标准的 ODPS / Hive SQL 项目血缘分析与知识图谱构建技能。核心能力:1)基于 SQLGlot 自动扫描 INSERT/SELECT/FROM/JOIN 提取表级血缘依赖链;2)整合 Graphify 构建代码知识图谱;3)支持字段溯源、影响分析、上下游依赖查询。触发场景:用户提到 SQL 血缘、表依赖、数据链路、ODPS 项目结构分析、SQL 脚本依赖关系,以及需要理解/重构/审查大型 SQL 工程时。
agent_created: trueSQL Lineage Analysis Skill
大型分层 ODPS / MaxCompute / Hive SQL 项目的血缘分析、依赖追踪与分层概览。所有命令通过统一 CLI 入口调用。
Commands
sql_lineage_install
安装所有依赖(sqlglot + graphify + tree-sitter-sql)。
python3 scripts/cli.py install
sql_lineage_extract
扫描 SQL 项目目录,提取表级血缘并输出为 graph.json。
python3 scripts/cli.py extract <project_dir> [options]
| 参数 | 说明 |
|---|---|
project_dir |
SQL 项目根目录(必填) |
--dialect hive |
SQL 方言(默认 hive,适用 ODPS) |
--merge-graphify |
与 Graphify 已有的 graph.json 合并血缘边 |
--tmp-prefix tmp_,mid_,z_ |
跳过指定前缀的临时表(逗号分隔) |
--out <dir> |
输出目录(默认 <project>/graphify-out) |
--no-write |
只输出统计,不写入文件 |
--json-output |
JSON 格式输出到 stdout |
--verbose |
详细日志 |
sql_lineage_upstream
向上溯源:从指定表追溯到所有上游源表。
python3 scripts/cli.py upstream <table> [options]
| 参数 | 说明 |
|---|---|
table |
目标表名(必填) |
--graph <path> |
graph.json 路径(默认自动查找 graphify-out/graph.json) |
--project <dir> |
项目目录(用于自动查找 graph.json) |
--max-depth 10 |
最大追溯深度 |
sql_lineage_downstream
向下影响分析:从指定表追踪到所有下游终端表。
python3 scripts/cli.py downstream <table> [options]
| 参数 | 说明 |
|---|---|
table |
起始表名(必填) |
--graph <path> |
graph.json 路径 |
--project <dir> |
项目目录 |
--max-depth 10 |
最大追踪深度 |
sql_lineage_deps
查看指定表的一级直接上下游依赖。
python3 scripts/cli.py deps <table> [--graph <path>] [--project <dir>]
sql_lineage_layers
分层概览:统计各层表数量及层间调用关系。
python3 scripts/cli.py layers [--graph <path>] [--project <dir>]
sql_lineage_stats
血缘图统计:表数量、边数量、源头/终端表、分层分布。
python3 scripts/cli.py stats [options]
| 参数 | 说明 |
|---|---|
--graph <path> |
graph.json 路径 |
--project <dir> |
项目目录 |
--show-layers |
显示分层分布 |
--show-sources |
列出所有数据源表 |
--show-sinks |
列出所有终端输出表 |
Workflows
初始化项目血缘分析
触发词:分析血缘、提取依赖、扫描项目、项目结构分析
- 先安装依赖:
cli.py install - (推荐)如有 Graphify,先运行
graphify extract <project_dir> --no-cluster获取文件级结构 - 执行血缘提取:
cli.py extract <project_dir> --merge-graphify --verbose - 读取统计结果,向用户汇报:表数量、边数量、分层分布
溯源分析(从报表追溯到源表)
触发词:这张表的上游是什么、从哪里来的、依赖链、数据源
- 执行
cli.py upstream <table> - 向用户展示完整溯源树,标注每张表所在层
影响分析(修改中间表的影响范围)
触发词:影响范围、改这张表影响哪些、下游是什么、会被谁用
- 执行
cli.py downstream <table> - 向用户展示完整下游链,标注影响范围
分层概览
触发词:分层结构、项目概览、有哪些层
- 执行
cli.py layers查看各层表数量和调用关系 - 执行
cli.py stats --show-layers --show-sources --show-sinks查看完整统计
环形依赖检测
触发词:环形依赖、循环引用、死循环
遍历 graph.json 中的 WRITES_TO 边,用 DFS + 回溯检测环路:如果某条路径回到已访问节点,报告环路。
Output Format
extract 命令输出示例:
✅ 血缘图已写入: /path/to/project/graphify-out/graph.json
47 张表, 83 条边
upstream 命令输出示例:
溯源: ads_user_report
────────────────────────────────────────────────────────────
── dws_user_summary_1d [dws]
└─ dwd_user_order_detail [dwd]
└─ ods_order_info [ods]
└─ ods_user_info [ods]
└─ dim_user_tag [dim]
共 5 个上游表。
────────────────────────────────────────────────────────────
deps 命令输出示例:
表: dwd_trade_order_detail [dwd]
──────────────────────────────────────────────────
▲ 上游 (3):
ods_order_info [ods]
ods_order_item [ods]
dim_product [dim]
▼ 下游 (2):
dws_trade_summary_1d [dws]
dws_user_order_1d [dws]
──────────────────────────────────────────────────
layers 命令输出示例:
分层概览
──────────────────────────────────────────────────────────────────────
层 表数量 来源/去向
──────────────────────────────────────────────────────────────────────
01_ods 8 ↓12
02_dwd 15 ↓18 ↑12
03_dws 12 ↓15 ↑18
04_ads 12 ↑15
──────────────────────────────────────────────────────────────────────
合计 47 层
脚本说明
| 文件 | 用途 |
|---|---|
scripts/cli.py |
统一 CLI 入口(所有子命令) |
scripts/extract_lineage.py |
核心血缘提取(SQLGlot 解析 + Graphify 合并) |
scripts/install_deps.sh |
一键安装所有依赖 |
references/odps_patterns.md |
ODPS 特有 SQL 语法参考(变量、分区、UDF、复杂数据类型) |
Notes
- 首次使用必须先
install,确保 sqlglot 已安装 - 所有命令需在 skill 根目录下执行(即 SKILL.md 所在目录),确保
scripts/cli.py可以正确找到 - Graphify 的 SQL 解析器只处理 DDL(CREATE TABLE/VIEW),不处理 INSERT/SELECT 中的表引用。因此需要先运行
graphify extract再运行cli.py extract --merge-graphify - SQLGlot 使用 hive 方言解析 ODPS SQL,大部分语法兼容。
LATERAL VIEW、TRANS_ARRAY等极少数 ODPS 特有语法可能解析不完整,但 INSERT/SELECT/FROM/JOIN 的核心表引用不受影响 - 临时表默认被跳过(前缀:
tmp_,mid_,z_),可通过--tmp-prefix调整 - 分区变量(如
${bizdate})会被自动替换为占位符以通过解析 - 字段级血缘不在本技能范围内。如需字段级溯源,建议结合 DataHub / Amundsen 等专业数据治理工具
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 高价值/高频刚需,直接解决用户明确的核心任务痛点
- 显著提升日常高频场景的效率,适用于大型SQL项目的血缘分析、依赖追踪与分层概览
Highlights
- 触发词精准完整,覆盖多种变体,边界清晰
- 触发场景包括SQL血缘、表依赖、数据链路、ODPS项目结构分析、SQL脚本依赖关系等
Highlights
- Phase/步骤清晰,有出口条件,含端到端示例
- frontmatter完整,单文件≤500行,文档结构清晰
Highlights
- 工具来源明确,参数正确,覆盖主要异常
- 不可逆操作有确认机制,依赖安装、血缘提取、溯源分析等命令均有详细说明
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Translation pending; see source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.