Add Jinja Support for SQL Templates in MXCP #54
miguelbranco80
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Wecould add Jinja templating support to MXCP queries to allow for powerful, governed dynamic SQL generation. This aligns with how users work with tools like dbt, and enables support for
ref
-style resolution and parameter injection while preserving MXCP’s safety guarantees.Goals
Core Features
manifest.json
from dbt to resolve:ref(model_name)
→ resolves toschema.alias
source(pkg, source, table)
→ resolves toschema.table
Additional Features
These aren't in
manifest.json
but are widely used:var(name, default)
→ resolve frommxcp-site.yaml
or CLI flagsenv_var(name, default)
→ read env varsconfig(**kwargs)
→ no-op (safe to ignore)doc(name)
→ optionally inline docs frommanifest.nodes[].meta.docs
metrics(name)
→ optionally map to pre-registered SQL blocksReference Implementation Snippet
Jinja Features to Support
params()
sql_identifier
sql_literal
assert_allowed
if / elif / else
for
loopsmacros
These would support tools that build dynamic aggregations, filters, or joins while preserving governance.
Benefits
Tradeoffs
Open Questions
ref()
support enough to start?Beta Was this translation helpful? Give feedback.
All reactions