Skip to content

fix(controlplane): force DuckLake transpile mode in multitenant remote backend#550

Merged
fuziontech merged 1 commit intomainfrom
fix/mtcp-ducklake-transpile-always
May 7, 2026
Merged

fix(controlplane): force DuckLake transpile mode in multitenant remote backend#550
fuziontech merged 1 commit intomainfrom
fix/mtcp-ducklake-transpile-always

Conversation

@fuziontech
Copy link
Copy Markdown
Member

Summary

  • Multitenant control plane has empty server.Config.DuckLake.MetadataStore (per-org stores live in configstore), so the transpiler was running with DuckLakeMode: false. The DDL transform never registered, and Fivetran's ALTER TABLE … ADD PRIMARY KEY ("id") flowed straight through to the worker, which rejected it with Not implemented Error: Adding indexes or constraints is not supported in DuckLake.
  • Add server.Config.AlwaysDuckLake and set it from the remote-backend control plane so DuckLake-aware transforms (DDL stripping, ON CONFLICT, pg_catalog/information_schema rewrites) run on every session.
  • Extend TestTranspile_DDL_NoOps with the bare ADD PRIMARY KEY / ADD UNIQUE / ADD FOREIGN KEY forms; the existing case only covered the named-constraint variant.

Why this only bit MTCP and not single-tenant

Single-tenant deployments set DUCKGRES_DUCKLAKE_METADATA_STORE globally, so DuckLakeMode was already true. MTCP doesn't (each org has its own store), so the gate was always false there.

Test plan

  • go test ./transpiler/... ./server/... ./controlplane/...
  • go build ./... and go build -tags kubernetes ./...
  • Deploy to a staging MTCP and re-run a Fivetran sync against posthog_data_import — confirm ALTER TABLE … ADD PRIMARY KEY now no-ops instead of erroring.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a multitenant control-plane issue where DuckLake-specific SQL transpilation was not being enabled (because DuckLake.MetadataStore is intentionally empty globally in MTCP), causing unsupported DDL like ALTER TABLE … ADD PRIMARY KEY to reach DuckDB/DuckLake workers and fail.

Changes:

  • Add server.Config.AlwaysDuckLake to force DuckLake transpiler mode even when the global metadata store is empty.
  • Enable AlwaysDuckLake automatically in the control plane when worker_backend=remote.
  • Extend TestTranspile_DDL_NoOps to cover additional ALTER TABLE ... ADD {PRIMARY KEY|UNIQUE|FOREIGN KEY} forms (including the Fivetran-prefixed variant).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
transpiler/transpiler_test.go Expands DDL no-op test cases to include bare constraint-add forms seen in real client traffic.
server/server.go Introduces AlwaysDuckLake configuration flag on the server config struct.
server/conn.go Forces transpiler DuckLake mode when either a metadata store is configured or AlwaysDuckLake is set.
controlplane/control.go Sets AlwaysDuckLake=true automatically for remote (multitenant) worker backend mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…e backend

Sessions on the multitenant control plane are always backed by DuckLake
workers, but the per-org metadata store comes from configstore so the
global server.Config.DuckLake.MetadataStore stays empty. The transpiler
was gated on that field alone, so the DDL transform never registered
in MTCP — meaning Fivetran's ALTER TABLE ... ADD PRIMARY KEY (and
ON CONFLICT, DuckLake-aware pg_catalog/info_schema rewrites) flowed
straight through to the worker, which rejects them with
"Adding indexes or constraints is not supported in DuckLake".

Add server.Config.AlwaysDuckLake and set it from the remote-backend
control plane. Tests cover the bare ADD PRIMARY KEY / UNIQUE / FK
forms (the existing test only exercised the named-constraint path).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fuziontech fuziontech force-pushed the fix/mtcp-ducklake-transpile-always branch from 765acf1 to b35fb1a Compare May 7, 2026 21:52
@fuziontech fuziontech merged commit fe7aab6 into main May 7, 2026
22 checks passed
@fuziontech fuziontech deleted the fix/mtcp-ducklake-transpile-always branch May 7, 2026 22:21
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.

2 participants