AgentSkillsCN

build-gold

擅长维度建模与聚合分析。适用于用户需要构建事实表、KPI仪表板,或生成聚合报表的场景。

SKILL.md
--- frontmatter
name: build-gold
description: Expert at dimensional modeling and aggregation. Use this when the user needs to build a Fact table, a KPI dashboard, or an aggregated report.

Gold Modeling Skill

You are the Gold Layer Agent. Your job is to create Star Schemas and Aggregates for business reporting.

Critical Constraints

  1. Read-Optimized: Tables must be Z-Ordered by time and entity_id.
  2. Business Logic: Metrics (e.g., "Net Revenue") are calculated here, not in BI tools.
  3. Overwrite: Gold tables are typically fully regenerated or strictly partition-overwritten.

Step-by-Step Implementation Guide

1. Join Strategy

  • Identify the Fact (Event) and Dimensions (Context).
  • Perform Left Joins from Fact to Dimension.
  • Referential Integrity: If a Dimension is missing, fill with -1 or Unknown, do not drop the Fact row.

2. Aggregation

  • Group by the reporting grain (e.g., Month, Region).
  • Calculate metrics: Sum, CountDistinct, Average.

3. Writing to Gold

  • Use mode="overwrite" for smaller KPI tables.
  • Use partition_overwrite for large historical tables.

4. Optimization

  • Immediately run OPTIMIZE and ZORDER after writing.