Skip to content

fix: give Python node results and provider setup the selected target - #1529

Merged
chio-labs-delivery[bot] merged 8 commits into
mainfrom
fix/python-target-context
Nov 17, 2026
Merged

chio-labs-delivery[bot] merged 8 commits into
mainfrom
fix/python-target-context

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Why

A target schema such as s_${CTX:model.name} resolves only inside a model. sqb build gave Python nodes the raw template as their default schema, so saving a node result ran CREATE SCHEMA IF NOT EXISTS s_${CTX:model.name} and failed.

Providers used by event exporters and command output sinks were set up with ctx=None. Build, check and load reuse that session, so their nodes' providers lost the target too, as did custom sensors' providers.

Changes

  • Build and check use the adapter's default database and schema for Python node results when the target location is unset, empty or holds a ${CTX:...} placeholder.
  • Exporter and sink providers get the selected target's settings (--target, --vars, else the default target) in setup(ctx). Resolving them keeps JSON stdout clean.
  • Commands that use the target (build, check, load, compile, query and the rest) fail at startup when it can't be resolved, before provider setup. Target-free commands such as sqb format still run with ctx=None. No other target is substituted.
  • A custom sensor's providers get the target the sensor evaluates for. Calendars keep ctx=None.
  • The providers page says when ctx is None.
  • The sqlbuild-python cap is set to its exact count, 66,878 (+47).

DuckShop: no edge case added. The bug needs a target-wide ${CTX:...} schema, which changes every model rather than one isolated case; the DuckDB E2E test covers it.

Verification

  • The CTX build E2E and the lifecycle-sink case failed first on the unchanged code.
  • New E2E: build and compile with an unresolvable target exit 1 before provider setup; format --check gets ctx=None.
  • The sensor integration test asserts that setup gets the evaluation target.
  • Targeted build, check, exporter, sensor and event-export tests pass (180).
  • fensu check and fensu dupes --since origin/main are clean.
  • make check-ci passes on the final head.

A target schema such as s_${CTX:model.name} resolves only inside a model.
sqb build passed the raw template to Python tasks and loaders as their
default location, so persisting a node result ran CREATE SCHEMA on the
template and the build failed. Build and check now fall back to the
adapter's default schema and database when the target location holds a
context placeholder.
Event exporters and command output sinks bind their providers when the
command starts, and that session is shared with build, check and load.
It was set up without the target, so a provider used by a sink got
setup(None) even inside sqb build. The scope now resolves the selected
target first and passes its settings; when the project can't resolve
them, ctx stays None and the command still runs.

A custom sensor's providers get the settings of the target the sensor
evaluates for. Calendars keep ctx None and the providers page says so.
…text

# Conflicts:
#	crates/sqlbuild-python-compile/src/compile_driver/_helpers/setup/targets.rs
#	crates/sqlbuild-python/src/bindings/_helpers/build_command/lifecycle.rs
#	crates/sqlbuild-python/src/bindings/_helpers/check/check_command.rs
…olved

Exporter and sink providers fell back to setup(None) whenever the
selected target couldn't be resolved, so a build with an undefined
connection set them up without a target before failing. build, check
and load now fail at startup instead, before any provider is set up.
Other commands, such as sqb format, still run and pass None. A sensor
evaluation fails rather than set its providers up without its target.

Target resolution at startup also runs with stdout sent to stderr in
machine-output modes, like extension discovery next to it.
Exporter, sink and sensor providers now get their setup context from
one native host helper. It returns None when the project has no
providers, fails build, check and load on an unresolvable target, and
ignores the model name that mv, rename and scope take as TARGET.
…target

Compile, dag, plan, test, seed, query, freshness, audit and debug need
the target too, and already fail on an unresolvable one. They now fail
before setting up exporter and sink providers, like build, check and
load, so only target-free commands give those providers None.
@chio-labs-delivery
chio-labs-delivery Bot added this pull request to the merge queue Nov 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 17, 2026
@chio-labs-delivery
chio-labs-delivery Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit c024aea Nov 17, 2026
59 of 62 checks passed
@chio-labs-delivery
chio-labs-delivery Bot deleted the fix/python-target-context branch November 17, 2026 02:36
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