osi-metrics-authoring

Authors OSI core semantic model metrics from SQL queries and natural language.

1.7k|248|Updated Jul 4, 2025
One-click install
npx skills add https://github.com/Datus-ai/Datus-agent --skill osi-metrics-authoring
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: osi-metrics-authoring
Source: https://github.com/Datus-ai/Datus-agent/tree/main/datus/resources/skills/osi-metrics-authoring
Command: npx skills add https://github.com/Datus-ai/Datus-agent --skill osi-metrics-authoring

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defining reusable business metrics in a semantic model is error-prone: engineers must translate SQL aggregates, window functions, and period-over-period logic into a consistent OSI core schema without leaking execution-engine syntax. This Skill standardizes that translation so metrics are created, updated, or deleted correctly inside an existing OSI semantic model.

Core Features & Use Cases

  • OSI Metric Authoring: Creates and updates metrics with qualified aggregate expressions, descriptions, ai_context instructions, and DATUS custom_extensions hints such as time_dimension, subject_path, format, and unit.
  • Window and Period-over-Period Semantics: Converts rolling, cumulative, and LAG-based SQL into standalone metrics using window, grain_to_date, window_aggregation, and period_over_period extension fields.
  • Filter Classification and Skip Gates: Distinguishes durable metric conditions from query-time filters, and skips non-metric outputs like rankings or detail lists with a structured skipped status.
  • Use Case: Given a SQL query computing monthly year-over-year revenue growth, the Skill binds the existing semantic model, publishes a revenue_month_yoy metric with a period_over_period extension, validates the model, and publishes it to the knowledge base.

Quick Start

Ask the agent to create a monthly year-over-year revenue growth metric from this SQL query in the existing OSI semantic model.

Frequently Asked Questions about osi-metrics-authoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a metric in an OSI semantic model from SQL?

Bind the existing semantic model target, then write the aggregate business expression with dataset-qualified columns and call upsert_osi_metrics with the complete metric objects. After validation passes with validate_semantic, call publish_metrics to sync the knowledge base.

How do I author rolling or year-over-year metrics in OSI?

Write the base aggregate as the OSI expression and encode window, grain_to_date, window_aggregation, or period_over_period semantics in the DATUS custom_extensions JSON. Each window or offset variant is a new standalone metric, never a reference to its base metric.

Does this Skill write MetricFlow YAML or measure definitions?

No. It authors OSI core semantics only and never writes MetricFlow YAML, measure_proxy, type_params, or ratio blocks. The Datus OSI compiler infers backing measures and lowers the model to the execution engine.

When should a SQL WHERE clause become part of a metric?

A predicate becomes a metric condition only when durable intent is confirmed, such as an explicitly requested named filtered KPI or an established business definition. Otherwise it stays a query-time filter and the base metric is reused.

What happens if the target semantic model does not exist yet?

The Skill stops and reports that gen_semantic_model must run first, since it only edits metrics and narrowly required datasets within an existing model. It does not create models, relationships, or model metadata from scratch.