Skip to content

[python] Preserve nanosecond precision in row-level timestamp filters. - #11629

Open
fengruotj wants to merge 1 commit into
apache:masterfrom
fengruotj:fix/timestamp-nans
Open

fengruotj wants to merge 1 commit into
apache:masterfrom
fengruotj:fix/timestamp-nans

Conversation

@fengruotj

Copy link
Copy Markdown
Contributor

Closes #11627

PyPaimon can return incorrect rows when a TIMESTAMP(9) comparison is combined with a predicate that requires row-level filtering. For example, if two rows match name LIKE 'k%p' and their timestamps differ by one nanosecond, filtering for the first timestamp returns both rows, while filtering for the second returns none. Polars converts both values to the same microsecond-precision Python datetime during row iteration.

This PR compares the stored integer timestamp values with literals expressed in the column’s time unit. This preserves nanosecond precision and keeps range comparisons exact when a literal falls between two representable column values. The reader reuses the prepared predicate across batches and returns the selected rows from the original Arrow batch.

Tests

Added a Parquet regression test for the two rows. With the compound filter, both to_arrow() and to_iterator() now return [1] for the first timestamp and [2] for the second. The test also verifies the stored nanosecond value when the timestamp column is projected.

Additional cases cover equality, range and membership predicates, NULL values, mixed timestamp units, and timezone-aware literals.

  • Python 3.13.2 / PyArrow 22.0.0 passed all 73 tests in the two affected test files.
  • Python 3.6.15 / PyArrow 6.0.1 passed 72 tests. One native-reader case was skipped because pypaimon_rust was unavailable.

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.

[Bug] PyPaimon row-level filters lose nanosecond precision when comparing TIMESTAMP(9) values

1 participant