Data Engineering Agent Metric Design Guide

Metric design is an important step before data engineering enters modeling and development. It clarifies fields, business logic, statistical granularity, time scope, and naming conventions early — preventing inconsistencies in task development, data warehouse modeling, dashboard construction, and data analysis down the line.

The Data Engineering Agent can help identify field roles, design metric logic, surface logic risks, and give recommendations for persisting metrics to the data warehouse or semantic layer — all based on table structure, sample data, and business objectives.

Applicable Scenarios

The following scenarios are suitable for metric design first:

  • Taking over an unfamiliar business table and needing to determine which fields are suitable as dimensions, metrics, and filters
  • Preparing to build sales, operations, customer, product, or financial topic metrics
  • Multiple fields with similar meanings that could easily lead to incorrect statistical logic
  • Preparing to build DWD / DWS / ADS or Silver / Gold layered models
  • Preparing to persist metrics to a BI tool, semantic layer, or analytics application
  • Business teams have different understandings of the same metric and need to agree on a unified definition

Do not ask the Agent to create tasks when field meanings and metric logic are unclear. Completing metric design first reduces rework and incorrect data outputs.

Do Read-Only Exploration First

Ask the Agent to view the table structure and a small amount of sample data first. Do not create tasks, write to tables, or modify configurations.

Suggested prompt:

The Agent will typically focus on:

  • Field names and types
  • Whether there is a primary key or order line ID
  • Which fields are suitable as dimensions
  • Which fields are suitable as measures
  • Which fields are suitable as time scope
  • Which fields look more like system or audit fields
  • Null values, outliers, date ranges, and enumeration values in the sample data

Identify Field Roles

The first step in metric design is to clarify field roles.

Field roleMeaningExamples
Dimension fieldsUsed for grouping, slicing, and comparisonProduct, customer, region, channel
Metric fieldsUsed for sum, count, average, ratio calculationsAmount, quantity, duration, cost
Time fieldsUsed for daily, weekly, monthly, and quarterly statisticsSales date, order time, partition date
Filter fieldsUsed to define business scopeStatus, type, whether valid, whether refunded
System fieldsUsed for data governance or technical trackingCreated time, updated time, batch ID

For time fields, distinguish between business event time and system processing time. For example, sales analysis typically uses the sales date, not the data write time.

Design Metric Logic

When asking the Agent to output metric definitions, include at least the following:

  • Metric name
  • Business definition
  • Calculation logic
  • Data source
  • Statistical granularity
  • Available dimensions
  • Time scope
  • Filter conditions
  • Logic risks

Example metrics:

MetricBusiness definitionCommon calculation logic
Sales amountTotal sales amount for valid orders in a given time rangeSUM(sale_amount)
Order countNumber of orders in a given time rangeCOUNT(order_id) or COUNT(DISTINCT order_id)
Average order valueAverage spending per order or customerSUM(amount) / COUNT(DISTINCT order_id)
Product sales rankingAggregate sales amount by product and rankSUM(amount) GROUP BY product_name
Daily average sales amountAverage daily sales amount over a time rangeSUM(amount) / COUNT(DISTINCT sale_date)

Order count and average order value especially need business confirmation. If the table only has an order line ID and no order header ID, COUNT(*) may be counting order lines rather than orders.

Logic Risk Review

Metric design should not only output a list of metrics — it should also surface logic risks.

Common risks include:

  • It is unclear whether an amount field represents the actual payment, list price, amount including tax, or net amount after refund
  • Missing order status, refund flag, or validity flag makes it impossible to determine which records should be included in the metric
  • created_at, updated_at, biz_date, and sale_date are used interchangeably
  • An ID field may be an order line ID rather than an order ID
  • The same table has multiple similar amount fields or date fields
  • Too little sample data to determine enumeration values, null rates, and outliers
  • Metrics have different logic when calculated at the customer, order, product, or store level

Suggested prompt:

Metric Naming Recommendations

Metric names should be stable, readable, and maintainable. Use a consistent naming convention, for example:

{business_domain}_{metric_meaning}_{aggregation_method}

Examples:

MetricSuggested nameNotes
Total sales amountsales_amount_totalSum of sales amount
Order countsales_order_countNumber of orders
Average order valuesales_avg_order_valueAverage order value
Product sales rankingsales_product_rankProduct-level ranking
Customer order countsales_customer_order_countCustomer-level order count

If the enterprise already has a metric naming standard, ask the Agent to follow the existing standard rather than inventing a new naming scheme.

Persisting to the Data Warehouse and Semantic Layer

After metric design is complete, you can continue into modeling and development.

Common persistence approaches:

  • Retain cleansed detail data in the DWD or Silver layer
  • Pre-aggregate by day, product, customer, channel, and other dimensions in the DWS or Gold layer
  • Produce wide tables for dashboards or applications in the ADS layer
  • Register measures, dimensions, time fields, and business descriptions in the semantic layer
  • Persist metric definitions, applicable scenarios, and exception rules in a knowledge base or metric catalog

Suggested prompt:

Generate metric design

Check for logic risks

Generate a metric requirements document

Move to data warehouse modeling