name: table-dependencies description: 基于外键关系生成表依赖图
表依赖关系技能
生成基于YAML配置中定义的外键关系的表依赖可视化图。这是数据模型的实体关系图。
用法
starlake table-dependencies [options]
选项
--output <value>: 输出文件路径(默认:控制台输出)--all-attrs: 在图中包含所有属性(不只是主键/外键)。默认:true--reload: 在计算前从磁盘重新加载YAML文件--svg: 生成SVG图像--png: 生成PNG图像--json: 生成JSON输出--related: 只包含与其他实体有关系的实体--tables <value>: 要包含的特定表的逗号分隔列表--all: 包含所有表(默认)--reportFormat <value>: 报告输出格式:console、json或html
配置上下文
表依赖关系来源于表定义中的foreignKey属性:
# metadata/load/starbake/order_lines.sl.yml
table:
name: "order_lines"
primaryKey: ["order_id", "product_id"]
attributes:
- name: "order_id"
type: "int"
foreignKey: "orders.order_id"
- name: "product_id"
type: "int"
foreignKey: "products.product_id"
- name: "quantity"
type: "int"
- name: "sale_price"
type: "double"
例子
生成完整的ER图为SVG
starlake table-dependencies --svg --output tables.svg --all
为特定表生成图
starlake table-dependencies --tables starbake.orders,starbake.order_lines --svg --output orders.svg
只显示相关表
starlake table-dependencies --related --svg --output related.svg
生成JSON输出
starlake table-dependencies --json --output tables.json
只显示主键/外键
starlake table-dependencies --all-attrs false --svg --output keys_only.svg
生成PNG图像
starlake table-dependencies --png --output tables.png --all
相关技能
- lineage - 任务依赖关系图
- col-lineage - 列级依赖关系
- acl-dependencies - ACL依赖关系图