sqlmesh icon indicating copy to clipboard operation
sqlmesh copied to clipboard

Support Databricks query tags in session properties

Open WhammyLeaf opened this issue 6 months ago • 2 comments

Description

The Databricks SQL connector supports per-statement query_tags, but SQLMesh did not previously pass model/session-level session_properties.query_tags through to the connector. This change stores validated query tags for the active adapter session and forwards them to Databricks SQL connector executions.

Query tags are only applied on the Databricks SQL connector path. They are not passed when execution is routed through Spark session / Databricks Connect paths, since those cursors do not support the query_tags argument.

ISSUE: https://github.com/SQLMesh/sqlmesh/issues/5795

Test Plan

  • Added Databricks engine adapter tests covering:
    • forwarding session query tags to Databricks SQL connector executions
    • clearing query tags after the session ends
    • preserving explicit per-statement query_tags
    • accepting NULL query tag values
    • rejecting invalid session_properties.query_tags
    • not applying query tags to Spark session / Databricks Connect execution paths
  • Verified the installed Databricks SQL connector exposes Cursor.execute(..., query_tags=...).
  • Built the package wheel successfully.
  • Ran:
pytest -q -o addopts='' tests/core/engine_adapter/test_databricks.py
python -m pip wheel . --no-deps -w /tmp/sqlmesh-wheel-final

WhammyLeaf avatar May 15 '26 13:05 WhammyLeaf

Will fix the failing style tests.

WhammyLeaf avatar May 15 '26 16:05 WhammyLeaf

@izeigerman Perhaps you can have a look at this 😄 ?

WhammyLeaf avatar May 15 '26 18:05 WhammyLeaf