Summary
Databricks Asset Bundles allow defining alerts-v2 via resources.alerts, but query_text must be inline YAML. There is no native way to source the alert SQL from an external .sql file. Requesting a supported file-include for query_text (or a documented .sql reference analogous to the existing .dbalert.json support).
Motivation / customer context
This comes from a customer (enterprise, EU) managing alerts-v2 as code. Their alert queries are multi-line SQL, and keeping that SQL inline in YAML is hard to maintain, review, and lint. They want the SQL to live in its own .sql file (single source of truth, normal SQL tooling), the same way job sql_task steps can reference a .sql file via file.path.
Current behavior
query_text: ${file("../sql/alert_query.sql")} validates fine but resolves to the literal string ${file(...)}, deploying a broken query. There is no file() include function for this field.
Bundles today allow referencing a .dbalert.json file (as committed from the web UI), but not a standalone .sql file.
Workaround (works, but glue)
Declare a variable and inject the file contents at deploy time via an env var:
export BUNDLE_VAR_alert_query="$(cat sql/alert_query.sql)"
databricks bundle deploy
variables:
alert_query:
default: ""
resources:
alerts:
failed_pipeline_runs:
query_text: ${var.alert_query}
Note: --var="alert_query=$(cat ...)" does not work. Multi-line --var values are truncated at the first newline; only the BUNDLE_VAR_ env var preserves the whole file.
Proposed solution
Support a native file reference for query_text, e.g. either:
- a
file()-style include that interpolates file contents into the string field, or
- a
query_file/file.path style attribute on the alert resource, mirroring how sql_task references .sql files.
Environment
- Databricks CLI: 0.297.2 (also reproduced on 0.281.0)
- alerts-v2 resource (
resources.alerts)
Summary
Databricks Asset Bundles allow defining alerts-v2 via
resources.alerts, butquery_textmust be inline YAML. There is no native way to source the alert SQL from an external.sqlfile. Requesting a supported file-include forquery_text(or a documented.sqlreference analogous to the existing.dbalert.jsonsupport).Motivation / customer context
This comes from a customer (enterprise, EU) managing alerts-v2 as code. Their alert queries are multi-line SQL, and keeping that SQL inline in YAML is hard to maintain, review, and lint. They want the SQL to live in its own
.sqlfile (single source of truth, normal SQL tooling), the same way jobsql_tasksteps can reference a.sqlfile viafile.path.Current behavior
query_text: ${file("../sql/alert_query.sql")}validates fine but resolves to the literal string${file(...)}, deploying a broken query. There is nofile()include function for this field.Bundles today allow referencing a
.dbalert.jsonfile (as committed from the web UI), but not a standalone.sqlfile.Workaround (works, but glue)
Declare a variable and inject the file contents at deploy time via an env var:
Note:
--var="alert_query=$(cat ...)"does not work. Multi-line--varvalues are truncated at the first newline; only theBUNDLE_VAR_env var preserves the whole file.Proposed solution
Support a native file reference for
query_text, e.g. either:file()-style include that interpolates file contents into the string field, orquery_file/file.pathstyle attribute on the alert resource, mirroring howsql_taskreferences.sqlfiles.Environment
resources.alerts)