feat: add Vertica dialect - #467
ArjixWasTaken wants to merge 1 commit into
Conversation
|
This was based on the vertica plugin for sqlglot, and it was compared against it. |
|
Thanks for the PR! I'd like to ask you to at least fix the known issues, I will run other verifications on my side... |
|
My recommendation is NO-GO for the current revision / request changes. I reviewed commit The main correctness concerns are:
Additional reproducible issues:
I also compared the reference Vertica plugin 0.2.7, using its supported SQLGlot 30.13.0 dependency. It rejects the unsupported PostgreSQL Local validation passed: 1,280 Rust unit tests, 744 custom dialect fixture cases—including all 121 Vertica cases—formatting, project consistency, and a minimal Vertica/transpile feature build. These checks did not include the full Before merging, I suggest addressing the findings above, adding regressions to the existing test infrastructure, and completing |
|
Following a broader comparison with the official Vertica 26.2 SQL reference, my recommendation remains NO-GO / request changes for commit This supplements the earlier review. The additional checks found both missing dialect coverage and further cases where accepted SQL changes meaning, including during native Vertica-to-Vertica transpilation. The additional correctness findings are:
The broader coverage audit also identified these gaps:
These distinctions matter for the support contract: accepting a statement, preserving its text, exposing its structure for analysis, and translating it correctly are separate capabilities. I compared 53 reference-driven examples across native Vertica, PostgreSQL, and DuckDB generation: 318 Polyglot checks, covering default and strict modes, and 159 reference-plugin comparisons. The reference plugin handles many of the missing forms above, including collection types, array-index adjustment, historical queries, parameterized functions, native locking, and specialized query clauses. It also has gaps, so its output still needs verification against the SQL reference. The earlier correctness findings remain applicable, including aggregate-filter loss, discarded Before merging, I suggest:
The additional checks used actual Polyglot and reference-plugin execution, with selected generated expressions executed in DuckDB. |
|
This PR is superceeded by #468 |
* feat: add Vertica dialect * Fix Vertica semantics and dialect coverage (#467) * Preserve bare Vertica KSAFE through JSON (#467) * Verify Vertica bindings and document coverage (#467) * Fixes * Cleanup * Cleanup --------- Co-authored-by: ArjixWasTaken <53124886+ArjixWasTaken@users.noreply.github.com>
Add Vertica dialect
Adds
verticaas a supported dialect across the Rust crate, FFI, Python, WASM, the TypeScript SDK and the playground. Behavior follows the vertica-sqlglot-dialect reference, and the fixture expectations are taken from its tests.This covers core query SQL only. Vertica-only DDL and query clauses are listed under "Not included" below.
Vertica semantics
Types: every Vertica integer is 64-bit and every float is a double.
INT/INTEGER/SMALLINT/TINYINT/INT8becomeBIGINT.REAL/FLOAT/FLOAT8becomeDOUBLE PRECISION.LONG VARCHAR[(n)]andLONG VARBINARY[(n)].BINARY VARYING(n)becomesVARBINARY(n), andTIMETZis kept.INTERVAL SECOND(3),INTERVAL DAY TO SECOND(5).Operators:
MINUSis read asEXCEPT. Adds//(integer division), postfix!and prefix!!(factorial), and prefix@(absolute value).|/and||/becomeSQRT/CBRT.Functions:
NVL,NVL2,DECODEandZEROIFNULLstay as written when the output is Vertica.TIMESTAMPDIFFbecomesDATEDIFF.TIMESTAMPADDandDATEDIFFunits are upper-cased.SYSDATEbecomesGETDATE().DAYOFWEEK_ISOis supported.LISTAGG(x USING PARAMETERS separator = …, max_length = …, on_overflow = …)is parsed and generated.Converting from other dialects into Vertica:
IF/IFFCASEDATEADDTIMESTAMPADDCHARINDEXINSTRAPPROX_COUNT_DISTINCTAPPROXIMATE_COUNT_DISTINCTGROUP_CONCAT/STRING_AGGLISTAGGTRY_CAST/SAFE_CASTCASTCOUNT_IFSUM(CASE …)QUALIFYand semi/anti joinsEXISTSConverting Vertica into other dialects:
GETDATE()/SYSDATEare start-of-statement times, so for PostgreSQL they becomeCAST(STATEMENT_TIMESTAMP() AS TIMESTAMP).GETUTCDATE()gets its UTC equivalent.LISTAGG … WITHIN GROUPbecomesSTRING_AGG(x, sep ORDER BY …)(Postgres family, T-SQL, BigQuery) orGROUP_CONCAT(MySQL family, SQLite). The default','separator is written out explicitly.ZEROIFNULLbecomesCOALESCE(x, 0).TIMESTAMPADDbecomes each target's date-add form, or interval arithmetic for Postgres.APPROXIMATE_COUNT_DISTINCTbecomes the portable approximate-distinct node.NULL sort order: where Vertica puts NULLs depends on the column type (
NULLS AUTO). So no default is assumed when reading Vertica, and when writing Vertica the source's NULL ordering is always spelled out.Changes to shared code
ListAggFunchas a new optionalmax_lengthfield. It's skipped from JSON when unset. Other dialects report it as unsupported instead of silently dropping it.double_slash_int_div, off by default and enabled only for Vertica.NVL2/DECODE,INSTRgeneration,IF→CASE, the 2-argumentDATEDIFFrewrite andGETDATE/SYSDATEhandling.dialects/normalization/vertica.rs.Standardrules with a NUMERIC precision cap of 1024.Registration and docs
dialect-verticafeature to bothCargo.tomlfiles. The dialect is registered in the FFI, Python, WASM, SDK and playground lists.transpile,dialect-verticafeature-gate check to the Makefile.docs/set-operation-types.mdandCHANGELOG.md(Unreleased).Tests
New
tests/custom_fixtures/vertica/fixtures:identity.json,types.jsonandtranspilation.json.Results:
FFI, WASM and Python binding tests pass.
cargo fmt --checkandscripts/check_project_consistency.pypass.Not included
SEGMENTED BY/KSAFE,TIMESERIES,MATCH,INTERPOLATE, andLIMIT n OVER (…).INTERVALYMkeyword andINTERVAL(p) '…'literals. The latter is still parsed incorrectly without an error.SERIALandJSONtypes to Vertica.Existing issues found but not fixed here
TIMESTAMPADD(DAY, n, ts)→ Postgres dropsn.//operator.LISTAGG→ Postgres isn't converted toSTRING_AGG.🤖 Generated with Claude Code