Repository navigation
Fix/pr482 division semantics - #484
Merged
Merged
Conversation
- Enable the existing double_slash_int_div tokenizer flag for DuckDB (already used by Vertica) instead of a bespoke parser lookahead; the existing DIV-keyword parsing path then handles it for free. Fixes separated/commented slashes (e.g. "7 / / 2") being wrongly accepted - Report unsupported instead of silently wrong output when a DuckDB // operand is a float literal, since DuckDB falls back to ordinary float division there (7.0 // 2 is 3.5, not 3) and truncating DIV forms can't reproduce that - Report unsupported for BigQuery when dividing by a literal zero, since BigQuery's DIV raises an error where DuckDB's // returns NULL - Emulate integer division for SQLite (CAST(CAST(x AS REAL) / y AS INTEGER)), which has no DIV function and previously got invalid SQL - Wire duckdb_integer_division into make test-rust-verify; expand coverage from 4 to 9 cases
- Move the float-operand guard into the DuckDB-source transform so it only applies to DuckDB's //; it had been placed in target-side code that can't see the source and broke MySQL's own DIV (7.5 DIV 2) and Vertica's //, which genuinely truncate - Reject a literal-zero divisor for every non-DuckDB target, not just BigQuery: PostgreSQL's DIV and ClickHouse's intDiv raise too, where DuckDB returns NULL - Recognize negated, parenthesized, and exponent-form float literals - Treat Vertica and ClickHouse as truncating targets for the float guard
DuckDB's // is ordinary float division when either operand is a float literal, so emit / (which then follows each target's own division rules) instead of reporting it unsupported. hotquery's hotdata target already lowered IntDiv to / and was producing the right answer here; the guard would have turned that into an error.
Owner
Author
|
Supersedes #482, thanks @eddietejeda |
eddietejeda
added a commit
to hotdata-dev/polyglot
that referenced
this pull request
Oct 8, 2026
Upstream landed its own versions of the DuckDB ORDER BY ALL (tobilg#485) and // integer-division (tobilg#484) work, built on and superseding ours. Upstream's implementation is taken for every conflicting feature hunk and for the two feature test files; the fork-only schema-annotation hook is kept alongside upstream's new prepare_integer_division pass. The fork's own SQLite IntDiv emulation and duplicate resolve_positional_order_by helper are dropped in favor of upstream's.
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.
No description provided.