Skip to content

feat: add query execution context provider transport - #6173

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

mday-io wants to merge 3 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

Style and fast tests were rerun after the test-only DuckLake cache fix. Earlier
feature checks remain applicable because feature code and examples are unchanged.

  • Local make style and all six make fast-test phases passed. 2,984 passed,
    13 skipped.
  • 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.
  • Windows CI
    passed with DuckDB 1.5.6 after the previous extension-install failure. All four
    DuckLake cases passed with worker-owned caches. The isolation mutation failed
    as expected; local serial/two-worker checks passed.
  • Remaining CI on the revised head.
  • 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.

Signed-off-by: mday-io <mdaytn@gmail.com>
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