refactor(server): extract SQL/result interfaces into server/sqlcore so flightclient is duckdb-free#487
Closed
fuziontech wants to merge 1 commit intofeature/binary-split-pr5-flightfrom
Closed
Conversation
0451c12 to
bc069e4
Compare
…o flightclient is duckdb-free
Step 6 of the binary-split plan. Carves the SQL/result interfaces and
two pure helpers out of server/ into a new server/sqlcore subpackage so
the Flight client can talk to those abstractions without importing the
rest of server/ (which still links libduckdb).
Symbols moved:
- Interfaces: RowSet, ExecResult, RawConn, ColumnTyper, QueryExecutor
(from server/executor.go)
- IsEmptyQuery + the previously private isEmptyQuery /
stripLeadingComments helpers (from server/conn.go and
server/exports.go) — now sqlcore.IsEmptyQuery and
sqlcore.StripLeadingComments
- OTELGRPCClientHandler (from server/otelgrpc_filter.go)
Backward compatibility preserved via type aliases and re-export `var`s
in server/executor.go and a new server/sqlcore_aliases.go. Existing
references to server.RowSet / server.QueryExecutor / server.IsEmptyQuery
/ server.OTELGRPCClientHandler / etc. compile unchanged.
The Flight client (server/flightclient) is the first consumer to drop
its server import entirely. After this PR:
go list -deps ./server/sqlcore | grep duckdb-go # empty
go list -deps ./server/flightclient | grep duckdb-go # empty
This means a hypothetical cmd/duckgres-controlplane that imports
flightclient (and arrowmap, auth, sysinfo, tlscert, ducklake from
earlier PRs) would not link libduckdb at all. The control plane's
remaining duckdb-go linkage comes from its server import for the
larger Server / clientConn / Config surface, which PR #7+ tackles.
LocalExecutor / PinnedExecutor / LocalRowSet stay in server/executor.go
intentionally — they're standalone-mode-only adapters around *sql.DB
and aren't needed by flightclient or the control plane.
Verified:
- go build ./... clean
- go build -tags kubernetes ./... clean
- go test -short ./server/sqlcore/... ./server/flightclient/...
./server/... ./controlplane/... — all green (existing
isEmptyQuery / stripLeadingComments tests in conn_test.go pass via
the unexported wrappers)
- go list -deps ./server/sqlcore | grep duckdb-go is empty
- go list -deps ./server/flightclient | grep duckdb-go is empty
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4eff491 to
38c5fb3
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server/sqlcore/subpackage with the SQL/result interfaces (RowSet,ExecResult,RawConn,ColumnTyper,QueryExecutor),IsEmptyQuery+StripLeadingCommentshelpers, andOTELGRPCClientHandlerserver/flightclientis now the first consumer to fully drop itsserverimport — making it duckdb-free at the linkage levelLocalExecutor/PinnedExecutor/LocalRowSetstay inserver/executor.go(standalone-mode-only adapters around*sql.DB, not needed by the CP path)The win
After this PR, a hypothetical
cmd/duckgres-controlplanethat importsflightclientplus the other already-extracted leaves (arrowmap,auth,sysinfo,tlscert,ducklake) does not link libduckdb at all. The CP still pulls duckdb-go through itsserverimport for the largerServer/clientConn/Configsurface, which PR #7+ tackles.Backward-compat shims
Type aliases and re-export
vars inserver/executor.goand a newserver/sqlcore_aliases.gokeep:The previously private
isEmptyQueryandstripLeadingCommentsinserver/conn.goare now thin one-line wrappers delegating tosqlcore.IsEmptyQuery/sqlcore.StripLeadingComments— so the existingTestIsEmptyQuery/TestStripLeadingCommentsinconn_test.gopass unchanged.Test plan
go build ./...cleango build -tags kubernetes ./...cleango test -short ./server/sqlcore/... ./server/flightclient/... ./server/... ./controlplane/...— all greengo list -deps ./server/sqlcore | grep duckdb-goreturns emptygo list -deps ./server/flightclient | grep duckdb-goreturns empty (the load-bearing check)Stack
server.go/conn.go/types.go's duckdb-bound code intoserver/exec/soserveritself stops linking duckdb-go (depends on PR add test user #1.5 for the config-type rebase)cmd/duckgres-controlplaneandcmd/duckgres-workerbinaries🤖 Generated with Claude Code