mhatipog opened a new pull request, #60523: URL: https://github.com/apache/spark/pull/60523
### What changes were proposed in this pull request? Do not push down a filter whose DATE or TIMESTAMP literal falls in 1582-10-05..1582-10-14 when the filter would carry it as `java.sql.Date` / `java.sql.Timestamp`: - `DataSourceStrategy.translateLeafNodeFilter` returns `None` for such literals unless the Java 8 time API is enabled. For TIMESTAMP the range is widened by a day on each side, because the conversion happens in the JVM time zone. - `OrcFilters` also refuses `LocalDate` values in the gap, because it converts them back to `java.sql.Date`. The filter is then evaluated by Spark after the scan, as for any filter that is not pushed. ### Why are the changes needed? Those days exist in Spark's proleptic Gregorian calendar but not in the hybrid calendar of `java.sql.Date`. `convertToScala` turns `DATE'1582-10-10'` into 1582-10-15 (and a gap TIMESTAMP into a time ten days later), so Parquet and ORC skip row groups that match. See SPARK-61739 for the repro; with a gap value stored in the file (pyarrow, delta-rs, Spark in CORRECTED mode) even `=` returns nothing. ORC TIMESTAMP is handled separately by SPARK-60152 (#60293); this change does not touch that path. ### Does this PR introduce _any_ user-facing change? Yes, correct results for filters with literals in the gap. Those filters are no longer pushed down, which only affects scans with such literals. ### How was this patch tested? New tests in `FileBasedDataSourceSuite` for DATE (Parquet and ORC) and TIMESTAMP (Parquet), with the Java 8 API on and off. They fail without the change. The fix was verified on an earlier master; this branch is rebased on current master, with a trivial import conflict resolved. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
