Add coreanalyzer experiment routing generate through the analysis core - #4544
Open
kyleconroy wants to merge 3 commits into
Open
Add coreanalyzer experiment routing generate through the analysis core#4544kyleconroy wants to merge 3 commits into
kyleconroy wants to merge 3 commits into
Conversation
kyleconroy
commented
Aug 6, 2026
SQLCEXPERIMENT=coreanalyzer builds each query set's compiler with WithCoreAnalysis, the same path sqlc analyze and the ClickHouse and GoogleSQL engines already use. The experiment now actually reaches the compiler: processQuerySets threads it into the parser options, which were previously always empty. Generating through the core also needs a catalog for codegen to build models from, which the core path never carried: its Result held a nil catalog that pluginCatalog would dereference. The core catalog is now dumped into the legacy catalog shape after the schema is applied. Array columns additionally set ArrayDims, which codegen renders a [] per, so they come out as slices rather than silently losing their array-ness. An end-to-end case pins the generated output for postgresql, sqlite and mysql. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANVHEs41RJbybS3ja9N1SA
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANVHEs41RJbybS3ja9N1SA
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANVHEs41RJbybS3ja9N1SA
kyleconroy
force-pushed
the
claude/sqlc-core-analyzer-experiment-djnr70
branch
from
August 7, 2026 04:11
010a207 to
59c72a0
Compare
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
SQLCEXPERIMENT=coreanalyzerroutessqlc generatethrough the core catalog and analyzer — the same pathsqlc analyzeand the ClickHouse and GoogleSQL engines already use — instead of each engine's own analysis path.internal/opts:coreanalyzer(noprefix to disable, case-insensitive). When set,parse()builds each query set's compiler withcompiler.WithCoreAnalysis().Env.Experimentwas parsed from the environment but never reached the compiler —processQuerySetsalways built empty parser options. It now threads the experiment through.Resultcarried a nil catalog, whichpluginCatalogwould dereference — generate had never run on this path (ClickHouse/GoogleSQL only haveparse/analyzecases).catalog_core.gonow dumps the core catalog into the legacy catalog shape after the schema is applied, so codegen builds models as usual. Seededpg_catalog/information_schemarelations come along but codegen already skips those schemas.[]perArrayDims, which the core path never set — array columns silently generated as scalars (Tags stringinstead ofTags []string, nopq.Arrayscan). Both the catalog dump and core query columns now setArrayDims: 1when the core reports an array.Output through the core matches the legacy path exactly for the covered cases, except
SELECT */RETURNING *stay literal in the emitted SQL: the core takes columns from analysis rather than rewriting the query text.Also documents the experiment in
docs/reference/environment-variables.md, replacing the stale "no experiments are defined" note.Rebased on main after #4545 removed the analyzerv2 experiment;
coreanalyzeris now the only experiment, so the wiring passesEnv.Experimentthrough unscoped.Testing
internal/endtoend/testdata/experiment_coreanalyzer/with committed goldens for postgresql (stdlib), sqlite, and mysql, run viaexec.jsonenvSQLCEXPERIMENT=coreanalyzer.internal/optstests.go test --tags=examples -timeout 20m ./...with PostgreSQL and MySQL live. After the rebase:go build ./..., theopts/compilerpackage tests, and the threeexperiment_coreanalyzerreplay cases.🤖 Generated with Claude Code
https://claude.ai/code/session_01ANVHEs41RJbybS3ja9N1SA