Skip to content

dft query

Run a named face query, execute raw SQL, validate SQL for structural issues, or inspect column schema — all in one command. The first operand is the query context: a data source name, or a .yaml face file.

Modes

Mode Invocation Description
Face execute dft query face.yaml NAME Run a named query from a face, return sample rows
Raw SQL execute dft query db 'SELECT …' Execute SQL directly against a data source
SQL from file dft query db --file query.sql Execute SQL read from a file
Validate dft query db 'SELECT …' --validate Lint SQL for fanout, missing joins, and re-aggregation
Column describe dft query db 'SELECT …' --describe Return column schema without fetching rows
Face describe dft query face.yaml NAME --describe Return column schema for a named face query
Validate + describe dft query db 'SELECT …' --validate --describe Run static lint, then return column schema (describe skipped on error-severity diagnostics)

Usage

dft query [OPTIONS] [CONTEXT] [QUERY]

CONTEXT is either a source name or a .yaml face path. QUERY is SQL for source contexts, or a named query/reference for face contexts.

Options

Flag Description
--validate Run static lint before execution/describe output.
--describe Return column schema via the warehouse adapter.
--file PATH Read SQL from a file instead of passing inline. Requires a source context.
--dialect NAME SQL dialect hint for --validate (duckdb, bigquery, etc.).
--var KEY=VALUE Variable override (repeatable).
--limit INT Max rows to return. Default 20, max 1000.
--show-suppressed Include suppressed diagnostics in --validate output.
--json Output JSON instead of rich text.
--project-dir PATH Project directory for resolving relative paths.

Examples

# Run the `revenue` query from a face, show first 20 rows
dft query faces/sales.yaml revenue

# Execute raw SQL against a named source
dft query my_warehouse 'SELECT month, SUM(revenue) FROM orders GROUP BY 1'

# Execute SQL from a file
dft query my_warehouse --file analytics/monthly.sql

# Static lint
dft query my_warehouse 'SELECT SUM(a.x), SUM(b.y) FROM a JOIN b ON a.id = b.id GROUP BY 1' --validate

# Static lint on a named face query
dft query faces/sales.yaml revenue --validate

# Column schema introspection
dft query my_warehouse 'SELECT month, SUM(revenue) FROM orders GROUP BY 1' --describe

# Validate then describe in one pass (describe skipped on error-severity lint)
dft query my_warehouse 'SELECT 1 AS n' --validate --describe

# Machine-readable output
dft query faces/sales.yaml revenue --json
dft query my_warehouse 'SELECT 1' --validate --json

Exit codes

  • 0 — success (named-query execute, SQL execute, validate with no errors, describe ok)
  • 1 — error (file not found, compile error, validation errors, warehouse error)