Add coreanalyzer experiment routing generate through the analysis core - #4544
Add coreanalyzer experiment routing generate through the analysis core#4544kyleconroy wants to merge 3 commits into
Conversation
010a207 to
59c72a0
Compare
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
59c72a0 to
96b5207
Compare
|
The
It needs a re-run, which I can't trigger — the app token here has no Generated by Claude Code |
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 through #4543 (extension catalog seed files). #4545 removed the analyzerv2 experiment, so
coreanalyzeris now the only one and 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 ./...green on the rebased branch with PostgreSQL and MySQL live, including the fullendtoendpackage and the threeexperiment_coreanalyzerreplay cases.🤖 Generated with Claude Code
https://claude.ai/code/session_01ANVHEs41RJbybS3ja9N1SA