Skip to content

refactor(server): move DuckLakeConfig + migration into server/ducklake#480

Merged
fuziontech merged 1 commit intomainfrom
feature/binary-split-pr1.5-ducklake
May 1, 2026
Merged

refactor(server): move DuckLakeConfig + migration into server/ducklake#480
fuziontech merged 1 commit intomainfrom
feature/binary-split-pr1.5-ducklake

Conversation

@fuziontech
Copy link
Copy Markdown
Member

Summary

  • Step 1.5 of the binary-split plan (PR refactor(duckdbservice): extract DuckDB-free arrow helpers into arrowmap subpackage #477 was step 1)
  • Moves DuckLakeConfig and the entire ducklake_migration.go file out of server/ and into a new server/ducklake/ package with zero duckdb-go dependency
  • go list -deps ./server/ducklake | grep duckdb returns empty
  • Public symbols renamed to drop the now-redundant DuckLake prefix; some previously-private helpers exported because they cross the new package boundary
  • Type alias type DuckLakeConfig = ducklake.Config left in server/ so the dozens of server.DuckLakeConfig field types compile unchanged

Why

The migration check uses pgx against the tenant's metadata Postgres — no DuckDB execution at all. But because the migration code lived in the same Go package as server.go (which imports duckdb-go), the control plane was forced to transitively link libduckdb just to call CheckMigrationVersion / BackupMetadata. Carving out the ducklake subpackage gives the CP a callable migration API without DuckDB linkage.

Renames

Public, drops DuckLake prefix (the package name now supplies the context):

Old New
server.DefaultDuckLakeSpecVersion ducklake.DefaultSpecVersion
server.CheckAndBackupDuckLakeMigration ducklake.CheckAndBackupMigration
server.CheckDuckLakeMigrationVersion ducklake.CheckMigrationVersion
server.BackupDuckLakeMetadata ducklake.BackupMetadata
server.DefaultDeltaCatalogPath ducklake.DefaultDeltaCatalogPath

Newly exported (cross the package boundary):

Old (private) New
ensureDuckLakeMigrationCheck ducklake.EnsureMigrationCheck
duckLakeMigrationNeeded ducklake.MigrationNeeded
duckLakeMigrationCheckedVersion ducklake.MigrationCheckedVersion
buildDuckLakeAttachStmt ducklake.BuildAttachStmt
buildDeltaCatalogAttachStmt ducklake.BuildDeltaAttachStmt
deltaCatalogPath ducklake.DeltaCatalogPath

New: ducklake.MigrationCheckError(connStr) error replaces a direct read of the private migrationState sync.Map from server.go's AttachDuckLake.

Compatibility shim

server/server.go keeps two aliases to avoid touching every server.DuckLakeConfig reference in this PR:

type DuckLakeConfig = ducklake.Config
const DefaultDuckLakeSpecVersion = ducklake.DefaultSpecVersion

The remaining server.DuckLakeConfig references are struct field types (e.g. cfg.DuckLake DuckLakeConfig) — those will be migrated to ducklake.Config as part of PR #2's larger server/ split. The alias is purely a transitional measure.

Test plan

  • go build ./... clean
  • go build -tags kubernetes ./... clean
  • go test -short ./server/ducklake/... ./server/... ./controlplane/... ./ — all green
  • go test -short -tags kubernetes ./controlplane/... — green except pre-existing testcontainer Postgres failures in controlplane/admin/ (unrelated, requires Docker)
  • go list -deps ./server/ducklake | grep duckdb returns empty (the load-bearing check)
  • All moved tests still pass (renamed to use new symbol names)

Stack

🤖 Generated with Claude Code

…e package

Step 1.5 of the binary-split plan. The migration / backup helpers in
server/ducklake_migration.go are already DuckDB-free at the import level
(they use pgx against the tenant metadata Postgres) but they live in the
same package as server.go, which imports duckdb-go. The control plane is
forced to transitively link libduckdb just to call CheckMigrationVersion.

This PR carves the DuckLake-specific code into a new server/ducklake
package with no duckdb-go dependency:

  - server/ducklake/config.go    — Config struct (was server.DuckLakeConfig)
  - server/ducklake/migration.go — migration check, backup, ATTACH builders
  - server/ducklake/migration_test.go — moved tests + the delta-catalog tests
    that were under server/ducklake_test.go

Public symbols are renamed to drop the now-redundant DuckLake prefix:

  server.DefaultDuckLakeSpecVersion       → ducklake.DefaultSpecVersion
  server.CheckAndBackupDuckLakeMigration  → ducklake.CheckAndBackupMigration
  server.CheckDuckLakeMigrationVersion    → ducklake.CheckMigrationVersion
  server.BackupDuckLakeMetadata           → ducklake.BackupMetadata
  server.DefaultDeltaCatalogPath          → ducklake.DefaultDeltaCatalogPath

A few previously private helpers are now exported because they cross the
new package boundary:

  ensureDuckLakeMigrationCheck         → ducklake.EnsureMigrationCheck
  duckLakeMigrationNeeded              → ducklake.MigrationNeeded
  duckLakeMigrationCheckedVersion      → ducklake.MigrationCheckedVersion
  buildDuckLakeAttachStmt              → ducklake.BuildAttachStmt
  buildDeltaCatalogAttachStmt          → ducklake.BuildDeltaAttachStmt
  deltaCatalogPath                     → ducklake.DeltaCatalogPath

A new ducklake.MigrationCheckError accessor replaces a direct read of the
private migrationState map from server.go's AttachDuckLake path.

To avoid touching the dozens of references to server.DuckLakeConfig across
the repo in this PR, server keeps a `type DuckLakeConfig = ducklake.Config`
alias and re-exports DefaultDuckLakeSpecVersion as a const. Callers that
already needed to be updated (control plane, config_resolution, server's
internal callers in server.go / checkpoint.go / querylog.go) now use
ducklake.* directly. Remaining server.DuckLakeConfig usages are in struct
field types only — those will move to ducklake.Config in PR #2 as part of
the larger server/ split.

Verified:
  - go build ./...        — clean
  - go build -tags kubernetes ./... — clean
  - go test -short ./server/ducklake/... ./server/... ./controlplane/... ./
    — all green (pre-existing testcontainer failures in admin/ unrelated)
  - go list -deps ./server/ducklake | grep duckdb  — empty (no duckdb-go)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fuziontech fuziontech force-pushed the feature/binary-split-pr1.5-ducklake branch from fbe9491 to dd4d1e2 Compare May 1, 2026 15:30
@fuziontech fuziontech merged commit 155c940 into main May 1, 2026
21 checks passed
@fuziontech fuziontech deleted the feature/binary-split-pr1.5-ducklake branch May 1, 2026 16:02
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