Skip to content

fix: SQL parse a typed DATE literal instead of casting it - #29007

Merged
ritchie46 merged 1 commit into
mainfrom
sql
Aug 27, 2026
Merged

ritchie46 merged 1 commit into
mainfrom
sql

Conversation

@ritchie46

Copy link
Copy Markdown
Member

String casts to temporal is not supported in 2.0

`DATE '2019-01-01'` emitted `lit(v).cast(Date)`, which polars no longer has a
kernel for, so any query using the typed-literal form failed with "casting from
string to date is not supported". Its `TIME` and `TIMESTAMP` siblings already
parsed the string; all three now go through `parse_string_as_temporal`.

The time unit `resolve_typed_literal_dtype` derives from a declared precision was
also computed and then discarded, so `TIMESTAMP(3)` produced microseconds. It is
now honoured.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016uVEEL5SiJifQEYPiUxszh
@github-actions github-actions Bot added A-sql Area: Polars SQL functionality fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Aug 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The uncompressed lib size after this PR is 60.4935 MB.

@ritchie46
ritchie46 merged commit 2e57e5f into main Aug 27, 2026
35 checks passed
@ritchie46
ritchie46 deleted the sql branch August 27, 2026 11:14
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.36%. Comparing base (a6782fa) to head (2b32cce).
⚠️ Report is 107 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-sql/src/sql_expr.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29007      +/-   ##
==========================================
- Coverage   81.58%   81.36%   -0.23%     
==========================================
  Files        1890     1886       -4     
  Lines      268762   267396    -1366     
  Branches     3264     3061     -203     
==========================================
- Hits       219280   217564    -1716     
- Misses      48637    49054     +417     
+ Partials      845      778      -67     

☔ 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.

dsprenkels added a commit to dsprenkels/polars that referenced this pull request Sep 8, 2026
The claim that `::date`/`::timestamp` on a SQL string literal no longer
works was true when written (pola-rs#28788), but pola-rs#28986/pola-rs#29007 made SQL parse
string->temporal instead of casting, so those all succeed again.

This commit was generated using Claude Opus 5.
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 fix Bug fix python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant