Repository navigation
Conversation
… zone A filter or a Top-N on a zoned timestamp column failed to bind unless the column's time zone was UTC. DuckDB's zoned timestamps have no time zone, so their constants and dynamic filter values convert to Vortex timestamps in UTC, and Vortex only compares timestamps of the same time zone. Give those values the time zone of the column they are compared with once a pushed filter is converted. Both sides are UTC instants. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SMtfpBcKnfP3CkWWQL6mit Signed-off-by: William Beckler <wbeckler@gmail.com>
myrrc
left a comment
There was a problem hiding this comment.
The right way to solve this is to teach Vortex how to compare timestamps with different time zones, jiff already supports this
|
Thanks for the review. Agreed that handling this in the comparison itself is cleaner than rewriting literals in the DuckDB converter, and it would cover the other integrations too. One thing to check before I rewrite it: #11016 made comparisons require equal dtypes, and it calls out timestamps with different time zones as one of the cases that now errors. Should If that is the direction, I'd do the core change as its own PR and reduce this one to the |
Summary
ORDER BY ... LIMITon a zoned timestamp column fail unless its time zone isUTC#11522A filter or an
ORDER BY ... LIMITon a zoned timestamp column fails to bind in DuckDB unless the column's time zone isUTC, for example withComparison requires equal dtypes ignoring nullability, got vortex.timestamp[µs, tz=America/New_York](i64?) and vortex.timestamp[µs, tz=UTC](i64?). DuckDB'sTIMESTAMP WITH TIME ZONEhas no time zone, so its constants and the dynamic value of a Top-N filter convert to Vortex timestamps inUTC, and Vortex only compares timestamps of the same time zone.Both sides are UTC instants, so this gives those values the time zone of the column they are compared with.
Changes
convert/time_zone.rs:align_time_zoneswalks a converted filter. Where a node has an operand that is a zoned timestamp over the scan's dtype, its timestamp literals (and lists of them, forIN) of the same unit take that operand's time zone, and a dynamic comparison is rebuilt with the operand's dtype. Nothing else changes, and a column inUTCleaves the expression as it is.try_from_table_filterandtry_from_bound_expressionapply it to what they return, so table filters, expression filters, complex filters and filters under a pushed aggregate are covered.try_from_bound_expressiontakes the scan's dtype for this.I did the rewrite after conversion, not where each literal is made, because the converter builds literals without knowing the dtype of the column next to them.
Tests
test_vortex_scan_zoned_timestamp_filters:=,>=,BETWEEN,IN, a filter withOR(the complex filter path) and a Top-N, each over a file inUTCand one inAmerica/New_York. The sixAmerica/New_Yorkcases fail ondevelop.align_time_zones: a comparison, aBETWEENand anINlist take the column's zone and then bind; a literal in the same zone, in another unit or without a zone, and a column without a zone, are left alone.VORTEX_SCAN_V2=1:cargo test -p vortex-duckdb --lib(289 passed, the two S3 tests ignored) andcargo test -p vortex-sqllogictest --test sqllogictests(81 passed; TPC-H, TPC-DS and ClickBench ignored without local data). Clippy with-D warnings, fmt on the pinned nightly and typos are clean.Notes
vortex-array, so the rewrite rebuilds the comparison whenever its operand is in a zone other thanUTC. An accessor would let it skip the ones that already match.AI assistance
Written by Claude Code (Claude Fable 5.2), an AI coding agent, working at my direction. It also ran the checks listed above and opened this PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SMtfpBcKnfP3CkWWQL6mit