Skip to content

refactor(database): adopt sqlglot-go - #112

Draft
moshloop wants to merge 6 commits into
mainfrom
refactor/database-sqlglot-go-engines-dmbd6f6dzmuo
Draft

moshloop wants to merge 6 commits into
mainfrom
refactor/database-sqlglot-go-engines-dmbd6f6dzmuo

Conversation

@moshloop

Copy link
Copy Markdown
Member

What

  • Move SQL inspection, capabilities, the custom SQL Server integration, catalog readers, and migration engines into sqlglot-go.
  • Keep commons-db public APIs as typed aliases and forwarding shims, and retain the generic catalog cache and freshness metadata.
  • Pin github.com/flanksource/sqlglot-go to v1.0.4-0.20261022122245-dc2638100c55.

Why

  • The native sqlglot-go engines own connections, inspection, HCL/script loading, locking, transactions, and SQL execution.

Notes

  • Merge feat: standalone inspect and migrate sqlglot-go#10 before this PR. The pinned dependency comes from that PR.
  • Original SQL Server ParseType, FormatType, ParseRoutine, CreateOrAlter, DefaultDiff, and DefaultPlan PlanApplier symbols, along with the routine, definition, and attribute types, are preserved.
  • Caller-owned database handles, existing migration options, PostgreSQL bundles, SQLite reconciliation, and reviewed SQL Server execution remain compatible.
  • Validation: all ten tracked database Gavel fixture gates pass. GOWORK=off compatibility, SQL inspection, PostgreSQL bundle/view-dependency migrations, Atlas packages, and focused go vet pass against the published dependency. Native build, lint, PostgreSQL/SQLite reviewed execution, and remote SQL Server runtime/bundle execution pass.

Move SQL inspection, capabilities, custom Atlas SQL Server integration, catalog readers, and migration engines into sqlglot-go. Keep commons-db public APIs as typed aliases and forwarding shims, while retaining its generic catalog cache and freshness metadata.

Preserve the original SQL Server ParseType, FormatType, ParseRoutine, CreateOrAlter, DefaultDiff, DefaultPlan PlanApplier, routine/definition types, and attribute types. Keep caller-owned database handles, existing migration options, PostgreSQL bundles, SQLite reconciliation, and reviewed SQL Server execution compatible.

Pin the published sqlglot-go v1.0.4-0.20261022122245-dc2638100c55 module from flanksource/sqlglot-go#10. Merge that dependency PR first; its native engines own connections, inspection, HCL/script loading, locking, transactions, and SQL execution.

Validation: all ten tracked database Gavel fixture gates pass. The isolated PR tree also passes GOWORK=off database API compatibility, SQL inspection, PostgreSQL bundle/view-dependency migrations, Atlas packages, and focused go vet against the published dependency. Regression coverage verifies the original planner symbols and DefaultPlan interface. Native build, lint, PostgreSQL/SQLite reviewed execution, and remote SQL Server runtime/bundle execution pass.

Gavel-Issue-Id: e5e4b378-75e4-4291-9c72-585d138a7cef
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@socket-security

socket-security Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgolang/​github.com/​flanksource/​sqlglot-go@​v1.0.3 ⏵ v1.0.4-0.20261022123344-3264e440e92590 -7100100100100

View full report

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
e2e 121 0 0 489ms

Totals: 121 passed · 0 failed · 0 skipped · 489ms

View full results

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
./www 229 0 0 2.2s
app 8 0 0 654ms
commands 26 0 0 57ms
connection 27 0 0 52ms
connections 70 0 0 5.3s
context 39 0 0 10ms
database 2 0 0 19ms
db 36 0 3 32ms
dbtest 44 0 0 13.5s
deadlocks 48 0 0 34ms
devtools 59 0 0 84ms
drivers 2 0 0 113.02µs
esdsl 140 0 0 18ms
git 156 0 0 8.5s
github.com/flanksource/commons-db/cmd/query/connections 135 0 0 240ms
github.com/flanksource/commons-db/cmd/query/internal/app 61 0 0 4.3s
github.com/flanksource/commons-db/cmd/query/internal/paramfile 18 0 0 -
github.com/flanksource/commons-db/cmd/query/profiles 204 0 0 11.0s
github.com/flanksource/commons-db/cmd/query/sessions 35 0 0 1m9s
github.com/flanksource/commons-db/connection 48 0 0 370ms
github.com/flanksource/commons-db/context 23 0 0 -
github.com/flanksource/commons-db/db 27 0 2 300ms
github.com/flanksource/commons-db/dbtest 15 0 0 -
github.com/flanksource/commons-db/fs 14 0 3 90ms
github.com/flanksource/commons-db/gorm 22 0 0 -
github.com/flanksource/commons-db/inspect/opensearch 7 0 0 -
github.com/flanksource/commons-db/kubernetes 14 0 0 -
github.com/flanksource/commons-db/logs 37 0 0 -
github.com/flanksource/commons-db/logs/azureloganalytics 0 0 1 -
github.com/flanksource/commons-db/logs/bigquery 0 0 1 -
github.com/flanksource/commons-db/logs/opensearch 24 0 0 20ms
github.com/flanksource/commons-db/migrate 7 0 0 2.4s
github.com/flanksource/commons-db/pkg/allowlist 3 0 0 -
github.com/flanksource/commons-db/pkg/kube/labels 1 0 0 70ms
github.com/flanksource/commons-db/query 16 0 0 20ms
github.com/flanksource/commons-db/query/providers 13 0 0 -
github.com/flanksource/commons-db/query/sqltext 53 0 0 -
github.com/flanksource/commons-db/secret 7 0 0 -
github.com/flanksource/commons-db/shell 31 0 1 620ms
github.com/flanksource/commons-db/shutdown 1 0 0 -
github.com/flanksource/commons-db/tracing 1 0 0 -
github.com/flanksource/commons-db/tracing/sqlserver/xesession 1 0 0 1.1s
github.com/flanksource/commons-db/tracing/sqlserver/xetrace 333 0 0 2.5s
github.com/flanksource/commons-db/types 9 0 0 -
goprof 12 0 0 2.8s
gorm 8 0 0 5ms
grammar 6 0 0 1ms
http 10 0 0 311ms
httpproxy 15 0 0 2.7s
inspect 22 0 0 354ms
jfr 35 0 0 1.4s
k8s 13 0 0 245ms
kubecatalog 2 0 0 1ms
kv 112 0 12 2.1s
labels 157 0 0 12ms
migrate 3 0 0 932ms
ndjson 111 0 12 754ms
notification 8 0 0 273.498µs
observability 13 0 0 13ms
opensearch 7 0 2 248ms
owner 49 0 0 6.7s
parquet 7 0 0 27ms
pgproxy 28 0 0 285ms
probe 10 0 0 1ms
process 26 0 0 10.0s
processor 66 0 0 29ms
profiles 85 0 0 196ms
providerkit 4 0 0 151.012µs
providers 252 0 10 6.7s
query 869 0 0 5.9s
recordresults 94 0 0 1.7s
recordresultse2e 102 0 0 9.4s
recordstore 166 0 6 3.2s
report 6 0 0 9ms
schedules 17 0 0 55ms
schema 57 0 0 348ms
secret 17 0 0 12ms
senders 17 0 0 7ms
sessions 143 0 0 1m4s
shell 13 0 0 274ms
snapshots 25 0 0 194ms
spool 27 0 0 152ms
sql 8 0 0 66ms
sqlite 334 0 2 4.7s
sqlitetable 41 0 0 82ms
sqlstatements 37 0 0 379ms
sse 2 0 0 303ms
stacks 15 0 1 1.5s
terminal 12 0 0 209ms
traceserve 7 0 0 155ms
tracing 94 0 0 5.0s
viewdeps 10 0 0 255ms
workload 10 0 0 3ms
xeprovider 22 0 0 1ms
xesession 43 0 0 1.1s
xetrace 53 0 0 16ms
xevent 13 0 1 178ms

Totals: 5361 passed · 0 failed · 57 skipped · 4m17s

View full results

Align root, recordstore, tracing and query modules on the published SQL Server compatibility and Windows SQLite URI fixes from sqlglot-go PR #10. HCL and PostgreSQL parsing are now indirect dependencies owned by the standalone engine, and obsolete sqlglot checksums are removed.

Reproduced the CI tidy failure locally; GOWORK=off make tidy-check now passes for all four modules.
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
lint: betterleaks 0 0 1 -
lint: golangci-lint 1 0 0 48.5s
lint: react-doctor 3 0 0 31.1s
lint: tsc 2 0 0 9.7s

Totals: 6 passed · 0 failed · 1 skipped · 1m29s

View full results

Claude-Session-Id: 01a15eea-9e79-7161-890a-03eac0c66cf1
Claude-Session-Id: 01a15eea-9e79-7161-890a-03eac0c66cf1
Claude-Session-Id: 01a15eea-9e79-7161-890a-03eac0c66cf1
Claude-Session-Id: 01a15eea-9e79-7161-890a-03eac0c66cf1
moshloop added a commit that referenced this pull request Oct 23, 2026
Retain the public type, routine and planner symbols through aliases and forwarding functions, including the DefaultPlan PlanApplier interface. Pin the final published sqlglot PR commit and add API compatibility regression coverage.

Validated in the isolated PR with GOWORK=off database compatibility, inspection, PostgreSQL migrations and go vet; linked compatibility also passes. Published as part of commons-db PR #112.
moshloop added a commit that referenced this pull request Oct 23, 2026
Mirror the verified PR #112 tidy fix in the original checkout. Root, recordstore, tracing and query use the final published sqlglot PR commit; moved HCL and PostgreSQL parser dependencies become indirect. The isolated PR passes make tidy-check for all four modules.
moshloop added a commit that referenced this pull request Oct 23, 2026
Retain the public type, routine and planner symbols through aliases and forwarding functions, including the DefaultPlan PlanApplier interface. Pin the final published sqlglot PR commit and add API compatibility regression coverage.

Validated in the isolated PR with GOWORK=off database compatibility, inspection, PostgreSQL migrations and go vet; linked compatibility also passes. Published as part of commons-db PR #112.
moshloop added a commit that referenced this pull request Oct 23, 2026
Mirror the verified PR #112 tidy fix in the original checkout. Root, recordstore, tracing and query use the final published sqlglot PR commit; moved HCL and PostgreSQL parser dependencies become indirect. The isolated PR passes make tidy-check for all four modules.
moshloop added a commit that referenced this pull request Oct 23, 2026
Retain the public type, routine and planner symbols through aliases and forwarding functions, including the DefaultPlan PlanApplier interface. Pin the final published sqlglot PR commit and add API compatibility regression coverage.

Validated in the isolated PR with GOWORK=off database compatibility, inspection, PostgreSQL migrations and go vet; linked compatibility also passes. Published as part of commons-db PR #112.
moshloop added a commit that referenced this pull request Oct 23, 2026
Mirror the verified PR #112 tidy fix in the original checkout. Root, recordstore, tracing and query use the final published sqlglot PR commit; moved HCL and PostgreSQL parser dependencies become indirect. The isolated PR passes make tidy-check for all four modules.
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