Skip to content

fix: default targets to the only connection and infer source freshness settings - #973

Merged
kvlonge merged 4 commits into
mainfrom
fix/config-default-connection
Oct 7, 2026
Merged

kvlonge merged 4 commits into
mainfrom
fix/config-default-connection

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Why

A target without connection = silently used an empty in-memory connection, so a build failed with "Schema dev does not exist", both when the project defined exactly one connection and when it defined none. Source freshness also required a strategy and type that the source already implies.

Changes

  • A target that sets no connection uses the only named connection when there is exactly one and no top-level [connection] block (across sqlbuild_project.toml and sqlbuild_local.toml). With several named connections it fails at config load with D001, naming the target and the connections.
  • With no connection configured at all, warehouse commands (build, plan, test, query, debug) fail with D001 before connecting; compile, format, lineage, scope, dag, rename and mv keep working. An explicit database = ":memory:" still works. Tests that relied on the empty fallback now set a connection.
  • Freshness strategy is inferred from the keys present (column, query, or neither for adapter), and the column strategy takes type from the declared column when it maps clearly. Contradictions and unmappable types are errors; explicit settings keep working.
  • Docs: default_target listed as optional, the default-connection rule, and the freshness inference table.

Verification

  • Unit tests for target resolution, config-load validation and freshness parsing; an integration test for a real build into the only connection, sqb debug, the D001 failures and inferred freshness.
  • Focused pytest (487 passed), ruff, fensu check and make check-ci.

@kvlonge
kvlonge enabled auto-merge (squash) October 6, 2026 12:25
@kvlonge
kvlonge disabled auto-merge October 6, 2026 12:31
@kvlonge
kvlonge force-pushed the fix/config-default-connection branch from fabc278 to 201c34c Compare October 6, 2026 13:44
@kvlonge
kvlonge enabled auto-merge (squash) October 6, 2026 13:44
@kvlonge
kvlonge force-pushed the fix/config-default-connection branch 2 times, most recently from 5ea161b to 6283f91 Compare October 7, 2026 07:26
A target without a connection silently used an empty inline connection, so DuckDB builds ran in memory and failed on a missing schema. When exactly one named connection is defined across the project and local files, and neither file has a top-level [connection] block, targets without a connection now use it. With several named connections, configuration loading rejects such targets. The docs also list default_target as optional.
Source freshness now implies its strategy from the keys set (column, query or neither for adapter) and takes the column strategy's type from the source's declared column type when it maps unambiguously. Explicit values keep working, and contradictions are rejected.
Commands that connect to the warehouse now stop with D001 before connecting when no connection is configured at all (no named connection, no top-level [connection] and no inline target connection), instead of silently using an empty connection that opened an in-memory DuckDB database. Compile, format, lineage, scope, rename and mv keep working without a connection, and an explicit database = ":memory:" still works. Test fixtures that relied on the empty fallback now configure an explicit connection.
`sqb test --inspect` only compiles and prints the test plan, but it resolved the connection eagerly and failed with D001 on projects without one; it now skips the connection requirement. Build validates target execution limits from the project adapter before resolving the connection, so limit errors no longer depend on a configured connection. `sqb freshness` resolves the connection only when sources are selected.
@kvlonge
kvlonge force-pushed the fix/config-default-connection branch from 6283f91 to 7779868 Compare October 7, 2026 08:03
@kvlonge
kvlonge merged commit a811140 into main Oct 7, 2026
32 checks passed
@kvlonge
kvlonge deleted the fix/config-default-connection branch October 7, 2026 08:33
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