Skip to content

feat: add query execution context provider transport - #6173

Draft
mday-io wants to merge 2 commits into
SQLMesh:mainfrom
mday-io:feat/query-execution-context-provider
Draft

mday-io wants to merge 2 commits into
SQLMesh:mainfrom
mday-io:feat/query-execution-context-provider

Conversation

@mday-io

@mday-io mday-io commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Description

SQLMesh's plan and run markers identify the parent job in warehouse query history,
but not the model evaluation behind each statement. This PR adds an opt-in
provider so applications can use the same evaluation ID in SQL and observer records.

Enable query_execution_context on a connection and supply an adapter provider
that returns an immutable QueryExecutionContext. SQLMesh appends version-one
JSON after the existing correlation marker, once SQL is rendered.

  • Escape comment delimiters and bound the comment to 8,192 UTF-8 bytes. Provider
    or serialization errors omit optional context and let the query continue.
  • Preserve settings across adapter clones, isolate cached DuckDB settings, and
    exclude the default state adapter.
  • Roll back adapter-owned transactions on provider or driver cancellation, then
    propagate the original BaseException.

The flag defaults to false. Without a provider, enabled adapters can emit
parent-only context. Athena and other adapters without generic comment support
skip this transport. A runnable DuckDB example connects context to observer events.
#6174 adds automatic model context.

Test Plan

The DuckLake extension-cache repair moved to #6193 and is excluded from this PR.

Local style and fast tests passed on the revised head. Earlier feature
checks remain applicable because all other file contents are unchanged.

  • Local make style and all six make fast-test phases passed. 2,983 passed,
    13 skipped, with automatic workers limited to two.
  • The restored DuckDB adapter module passed all 15 tests serially.
  • Earlier serializer, adapter, configuration, and cancellation checks passed,
    including real SQLite rollback and later transaction reuse.
  • Earlier CLI init/DLT tests, doctests, and runnable example passed. Native
    plan/apply/run checks matched observer and SQL IDs across six batches and audits.
    Rows and hashes were unchanged; default state SQL had no rich context.
  • GitHub CI on the revised head. The DuckLake repair in fix(tests): isolate DuckLake extension caches per worker #6193 may
    need to land before Windows CI passes.
  • Strict local MkDocs build and remote warehouse qualification. MkDocs is
    unavailable locally; remote warehouses were not exercised locally.

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

Signed-off-by: mday-io <mdaytn@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Autofix is paused · Paused

The task's access, billing or publication was refused. Check the Coding task for the specific failure before resuming.

@mday-io mday-io mentioned this pull request Oct 31, 2026
8 of 10 tasks
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Autofix was enabled. Check current status in the Coding task.

@mday-io
mday-io force-pushed the feat/query-execution-context-provider branch from d915507 to 41f5d27 Compare November 4, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant