Skip to content

About

Mint governed dbt Semantic Layer metrics from institutional SQL via DataHub query history - compile dbt Semantic Layer YAML with fail-closed validation and VERIFIED write-back.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

QueryMint

License: Apache-2.0 CI Python DataHub

Mint governed dbt Semantic Layer metrics from the SQL your organization already runs. QueryMint reads institutional query history from DataHub, clusters recurring SQL patterns with sqlglot, compiles dbt Semantic Layer YAML, validates every column against live catalog schema (fail-closed), and writes semantic specs back so the next agent inherits official metric definitions.

Track: Build with DataHub - Metadata-Aware Code Generation · License: Apache-2.0

Judges - start here (no Docker):

pip install -e ".[dev]"
querymint demo && querymint verify

Interactive demo: War room · Examples viewer · 60-second judge guide

QueryMint

Headline: Eval 18/18 grounded · 18/18 VERIFIED write-backs · 176 tests · 92% coverage · dual dataset (orders + customers)

Validation proof

Local war room (from repo root):

cd demo-ui && npm install && npm run dev

GitHub Pages: enable Settings → Pages → Deploy from branch main → /docs. Or use the Actions workflow (requires Settings → Pages → Source: GitHub Actions).


The problem

Your semantic layer is already written - in BI dashboards, analyst notebooks, and ad-hoc SQL that runs against production every day. The dbt Semantic Layer wants YAML. Manually translating institutional SQL is slow, and LLMs hallucinate column names that look plausible but are not in the catalog.

The thesis, measured

Ungrounded codegen QueryMint (catalog-grounded)
Column picks correct (18 cases) 0 / 18 18 / 18
Schema gate (orders demo run) - 10 / 10 artifacts passed
Schema gate (customers demo run) - 8 / 8 artifacts passed
Write-back protocol - 18 / 18 VERIFIED

Ungrounded baseline simulates typical LLM column hallucination. Full protocol: docs/eval.md.


What QueryMint does

get_dataset_queries (DataHub)
  → sqlglot intent extraction
  → structural hash clustering
  → Jinja compile → semantic_models + metrics + staging SQL
  → fail-closed schema gate (catalog allow-list)
  → write-back: document + semantic-layer-candidate tag
  → next agent inherits validated metric definitions

Pipeline overview

Visual diagrams (open in browser):

Diagram Description
Solution architecture (light) Clean 3:2 overview for slides / Devpost
How we built it (story) Problem → idea → build → proof
Full architecture (dark) Detailed component map
  1. Mine - institutional SQL from DataHub query history
  2. Extract - SELECT / GROUP BY / aggregations via sqlglot
  3. Cluster - dedupe recurring patterns by structural hash
  4. Compile - dbt Semantic Layer YAML + staging models
  5. Validate - reject any column not in catalog schema (fail-closed)
  6. Write-back - attach spec to dataset for downstream agents

Why DataHub is essential

Step DataHub capability API / tool
Mine SQL Institutional query history get_dataset_queries
Validate Schema field allow-list schema metadata read
Write-back Next agent inherits metric spec document + tags + description

QueryMint reads context from DataHub, validates against it, and writes back semantic-layer candidates. Without query history there is nothing to mine; without schema metadata there is no fail-closed gate.

Details: docs/architecture.md


Quick start (offline - recommended)

git clone https://github.com/HawaleShailesh004/querymint-app.git
cd querymint-app
pip install -e ".[dev]"
querymint demo
pytest -q

Inspect sealed artifacts in examples/. Step-by-step: docs/quickstart.md.

Live DataHub setup

Requires Docker and a running DataHub GMS. See docs/datahub-setup.md.

pip install -e ".[datahub,dev]"
export DATAHUB_GMS_URL=http://localhost:18080   # or :8080
querymint run --write-back --no-fixture
querymint verify --no-fixture --urn "urn:li:dataset:(urn:li:dataPlatform:dbt,showcase_ecommerce.orders,PROD)"

CLI

Command Description
querymint demo Full offline pipeline + eval
querymint verify Verify sealed bundle + dbt lint/parse
querymint mine --no-fixture Show get_dataset_queries output (video/live demo)
querymint run --write-back --no-fixture Live pipeline + PENDING→VERIFIED write-back
querymint eval Regenerate eval table

Full reference: docs/cli-reference.md


Examples (judge bundle)

Path Purpose
examples/scenario_walkthrough.md Side-by-side ungrounded vs QueryMint
examples/validation_report.json Schema gate - all_passed
examples/generated/ Semantic YAML + dbt SQL
examples/eval/EVAL.md Honest eval
examples/next_agent_flip/ Write-back changes next-agent answers

What is wired (honesty table)

Capability Status
Offline demo (querymint demo) Wired
Fail-closed schema gate Wired
Sealed examples/ bundle Wired
Live DataHub write-back Wired - needs running GMS
Official MCP stdio subprocess Wired - QUERYMINT_TRANSPORT=mcp
Custom web UI War Room + examples viewer

Documentation

Guide Description
Judges — 60 sec Fast reproduce path + proof table
Quick start Install, demo, verify
Architecture Pipeline design + diagrams
DataHub setup Docker, ports, seeding queries
Evaluation Grounded vs ungrounded methodology
CLI reference All commands and flags
Upstream skill RFC Proposal for datahub-skills

Tests

176 tests, 92% line coverage (CI enforces ≥85%).

pytest -q --cov=querymint --cov-fail-under=85
python scripts/verify_submission.py

Upstream contribution

datahub-skills PR #140 — adds the datahub-query-to-semantic skill (open).


License

Apache-2.0 - see LICENSE.

About

Mint governed dbt Semantic Layer metrics from institutional SQL via DataHub query history - compile dbt Semantic Layer YAML with fail-closed validation and VERIFIED write-back.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages