Skip to content

Fix/pr482 division semantics - #484

Merged
tobilg merged 6 commits into
mainfrom
fix/pr482-division-semantics
Oct 7, 2026
Merged

tobilg merged 6 commits into
mainfrom
fix/pr482-division-semantics

Conversation

@tobilg

@tobilg tobilg commented Oct 7, 2026

Copy link
Copy Markdown
Owner

No description provided.

eddietejeda and others added 6 commits September 25, 2026 09:50
- 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.
@tobilg

tobilg commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

Supersedes #482, thanks @eddietejeda

@tobilg
tobilg merged commit df922a6 into main Oct 7, 2026
23 checks passed
@tobilg
tobilg deleted the fix/pr482-division-semantics branch October 7, 2026 15:44
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants