Repository navigation
perf(convert): write set operations, constant JSON and repeated operands once - #279
Merged
Merged
Conversation
…e fast check would
A PARSE_JSON of a string literal that json_checked_v1's fast check reads
as it is (plain strings, short numbers, true, false and null, valid, no
key repeated) is now json('<literal>') instead of the macro call. A Rust
reader decides it and is never looser than the macro: it also refuses
escaped keys and escaped backslashes, and any other literal keeps the
call.
…integer casts - Only a set operation's first branch writes its select-list names; DuckDB takes the result's names from it. BY NAME and ordered set operations keep every name they read. - A plain SELECT branch, and a left branch that is the same set operation, are no longer parenthesised; DuckDB groups them the same. - A relation aliased to its own name is written without the alias. - A UNION ALL chain whose every branch holds an integer literal of at most 18 digits in a column writes it bare and casts the column once around the chain, where that saves more bytes than the wrapper costs.
…and sums VARIANCE, VAR_POP, STDDEV and the like over a long operand, such as text read as FLOAT, wrote the operand into its count, its exact sum and its exact sum of squares, seven times in all. They now list the group's values once and take the count, the sum and the sum of squares from that list, with the same exactness checks and raise.
…ame, bind a long held cast - TO_DATE and TO_TIMESTAMP_NTZ in a literal format extract all the format's groups with one regexp_extract into a struct, where that is shorter than one regexp_extract per group. - An ordered window aggregate without a frame no longer writes RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which is DuckDB's frame when none is written. - A cast of a long VARIANT-held value to ARRAY or OBJECT binds the value once instead of writing it in both the kind check and the result.
A later branch's star expands to several columns, so an item's position was not its column's: a literal after the star marked the wrong column bare, skipping that column's own reading of text. The chain now casts once only when every branch has one item per column.
…nd meet the lint rules A star can expand to no columns, so a branch could match the first's item count while its columns still shifted. The chain now casts once only when no branch item is a star. The set operation helpers take grouped parameters, the new constants move to the constants files, and the test helpers move to helpers.rs.
kvlonge
enabled auto-merge
November 25, 2026 03:42
The playground test and the converted SQL on the home page and in the docs still showed FROM "ORDERS" AS "ORDERS", which the converter no longer writes.
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.
Why
Converted SQL still said things several times. Every UNION ALL branch restated its names, parentheses and integer casts, a constant PARSE_JSON literal was checked at run time, and some blocks repeated an operand or regex match. Each change keeps the same rows, names, types, NULLs and raised error tags.
Changes
json_checked_v1's fast check would read as it is becomesjson('<literal>'). A stricter Rust reader decides; any other literal keeps the call.Verification
regexp_extractagree on DuckDB for the corpus's 42 format patterns.make verify-recorded(strict errors): 0 failed, 8,237 passed and 1,054 diverged as recorded; error checks 397 agree, 113 divergence raises, 0 findings; 0 syntax-coverage changes.make check-cipasses.