Skip to content

feat: Fix tpch SQL issues - #29269

Merged
ritchie46 merged 15 commits into
mainfrom
sql-pdsh-gaps
Sep 13, 2026
Merged

ritchie46 merged 15 commits into
mainfrom
sql-pdsh-gaps

Conversation

@ritchie46

@ritchie46 ritchie46 commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

fixes: #29169

ritchie46 and others added 2 commits September 12, 2026 11:45
- `INTERVAL '3' MONTH` / `INTERVAL 3 MONTH` (leading unit) intervals
- `YEAR(x)`, `MONTH(x)`, `DAY(x)`, `HOUR(x)`, ... date part functions
- `LIKE`/`ILIKE`/`IN`/... predicates inside `JOIN ... ON`
- bare ISO date in `TIMESTAMP`/`DATETIME` typed literals
- integer literals compared for equality against a String expression
  (`substring(x, 1, 2) IN (13, 31)`) are compared as strings
- literal-only arithmetic (`.06 + 0.01`) is folded exactly so it compares
  correctly against Decimal columns, matching decimal SQL semantics

Closes #29169

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lj7JbtU82rEjCBvQ98absi
…e path

Right-table columns are renamed at the SQL level before parsing, so a
predicate may reference the same clashing column on both sides.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lj7JbtU82rEjCBvQ98absi
@github-actions github-actions Bot added A-sql Area: Polars SQL functionality enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Sep 12, 2026
@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

The uncompressed lib size after this PR is 55.5910 MB (at 4baf69d).

ritchie46 and others added 5 commits September 12, 2026 18:51
Constant WHERE conditions are now evaluated through the expression visitor
instead of comparing raw SQL literals, and the OR-chain IN fallback shares
the same coercion as binary comparisons.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lj7JbtU82rEjCBvQ98absi
Window, aggregate and selector expressions name no column but still read
the input; the constant shortcut now checks the parsed expression. Equi-join
keys get the same string/integer literal coercion as `=`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lj7JbtU82rEjCBvQ98absi
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lj7JbtU82rEjCBvQ98absi
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lj7JbtU82rEjCBvQ98absi
@ritchie46 ritchie46 changed the title feat: Close the SQL gaps needed to run all PDS-H queries feat: Fix minor SQL issues Sep 12, 2026
@ritchie46 ritchie46 changed the title feat: Fix minor SQL issues feat: Fix minor SQL issues Sep 12, 2026
@ritchie46
ritchie46 marked this pull request as ready for review September 12, 2026 18:26
…hmetic

`polars_compute::decimal::exact` owns checked fixed-point scalar arithmetic on
`(mantissa, scale)` pairs; `polars_sql::literal_folding` owns which SQL forms
qualify, reading the literal spelling, and the single conversion to Float64.
…translation

A WHERE condition is always translated to a filter; the planner folds a
constant one. A column-free JOIN ON condition becomes a boolean join key
against `true` whenever the planner proves it input-independent, so true,
false and NULL conditions all defer to normal execution for every join type.
An inner join on the same non-null constant key on both sides lowers to a
cross join.
@ritchie46 ritchie46 changed the title feat: Fix minor SQL issues feat: Fix tpch SQL issues Sep 13, 2026
… lazy predicate path

A literal on the left of `IN` is compared as an OR-chain, which the planner
folds; a constant WHERE condition is cast to boolean lazily; the inner join to
cross join rewrite only applies to unvalidated joins.
An `ARRAY[...]` literal is one list value, not a one-row Series, so the
planner classifies expressions over it as input-independent.

/// Returns `x * 10^e`, or None on overflow; `e` is not bounded by `DEC128_MAX_PREC`.
#[inline]
pub fn i128_mul_pow10(x: i128, mut e: usize) -> Option<i128> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to constant fold decimal literals before we convert to float.

@ritchie46
ritchie46 merged commit d84c1d4 into main Sep 13, 2026
30 of 31 checks passed
@ritchie46
ritchie46 deleted the sql-pdsh-gaps branch September 13, 2026 09:05
@codecov

codecov Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.99666% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.75%. Comparing base (0f7c24a) to head (4baf69d).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-sql/src/literal_folding.rs 97.61% 1 Missing ⚠️
crates/polars-sql/src/sql_expr.rs 98.50% 1 Missing ⚠️
crates/polars-sql/src/sql_visitors.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29269      +/-   ##
==========================================
+ Coverage   81.71%   81.75%   +0.04%     
==========================================
  Files        1914     1916       +2     
  Lines      273645   274104     +459     
  Branches     3113     3113              
==========================================
+ Hits       223612   224098     +486     
+ Misses      49246    49220      -26     
+ Partials      787      786       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-sql Area: Polars SQL functionality enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars title needs formatting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing SQL Functionality for PDS-H

1 participant