名称: 指标 description: 计算表格数据的统计指标
指标技能
计算表格数据的统计指标。指标基于每个属性定义的metric类型:数值列使用continuous(最小值、最大值、平均值、标准差等),分类列使用discrete(不同计数、频率分布)。
用法
starlake metrics [options]
选项
--domain <value>: 域名(必需)--schema <value>: 表/模式名称(必需)--authInfo k1=v1,k2=v2: 连接的认证信息(例如gcpProjectId=my-project)--reportFormat <value>: 报告输出格式:console、json或html
配置上下文
属性指标类型
指标在表的YAML文件中按属性配置:
# 在 table.sl.yml 中
table:
attributes:
- name: "total_amount"
type: "decimal"
metric: "continuous" # 最小值、最大值、平均值、中位数、方差、标准差、百分位数
- name: "status"
type: "string"
metric: "discrete" # 不同计数、类别频率
- name: "order_id"
type: "long"
# 没有指标 - 不计算
指标类型
| 指标类型 | 计算值 |
|---|---|
continuous |
最小值、最大值、总和、平均值、中位数、方差、标准差、偏度、峰度、25th/75th 百分位数、缺失值、行数 |
discrete |
不同计数、类别频率、顶级类别、行数 |
应用级配置
# metadata/application.sl.yml
application:
metrics:
active: true
discreteMaxCardinality: 10 # 离散指标的最大不同值
指标存储在 SL_METRICS 审计表中,用于历史跟踪。
示例
计算表的指标
starlake metrics --domain starbake --schema orders
使用认证信息计算
starlake metrics --domain starbake --schema orders --authInfo gcpProjectId=my-gcp-project
使用JSON报告计算
starlake metrics --domain starbake --schema products --reportFormat json