raviston commented on PR #60293: URL: https://github.com/apache/spark/pull/60293#issuecomment-6766087640
A follow-up review found two mistakes in my walkthrough above. I've pushed 383a4908498, which fixes both, and updated the description. **1. The cutoff was compared in the wrong time representation, so some values still returned 0 rows.** - ORC decides whether to convert a statistic by its *wall clock*: its millis plus the JVM default time zone offset, as in [`SerializationUtils.convertToUtc`](https://github.com/apache/orc/blob/v2.3.1/java/core/src/java/org/apache/orc/impl/SerializationUtils.java#L1378-L1381) applied in [`ColumnStatisticsImpl`](https://github.com/apache/orc/blob/v2.3.1/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java#L1640-L1657). - The first version compared the pushed value's `getTime()`, which is UTC, with 1582-10-15T00:00Z. - In a time zone behind UTC the two differ. With the JVM in America/Los_Angeles, `t = TIMESTAMP'1582-10-04 20:00:00'` and `t >= ...` still returned 0 instead of 1 on a file of that value. That held for anything from 16:07 to 24:00 on 1582-10-04. - The check now computes the wall clock the same way: `millis + TimeZone.getDefault.getOffset(millis) < 1582-10-15 00:00:00`. - The tests now run in UTC, America/Los_Angeles and Asia/Kolkata, and include `1582-10-04 20:00:00`. The first version fails them with `0 did not equal 1 t = TIMESTAMP'1582-10-04 20:00:00', time zone America/Los_Angeles`. **2. The bloom filter argument doesn't apply to master.** - ORC only checks bloom filters for `EQUALS`, `NULL_SAFE_EQUALS` and `IN` ([`shouldEvaluateBloomFilter`](https://github.com/apache/orc/blob/v2.3.1/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java#L801-L812)). - Since SPARK-60449, every `TimestampType` predicate is built as `BETWEEN`, `LESS_THAN` or `LESS_THAN_EQUALS`, so bloom filters are never consulted for these. That's why I removed the bloom filter loop from the test. - The argument only holds on branch-3.5, which doesn't have SPARK-60449. - On master, the reason not to push a converted literal is different. The ranges are exact, so the literal would have to match ORC's own calendar conversion to the millisecond. ORC's conversion is a different implementation from Spark's rebase. Other changes in the commit: - `GregorianSwitchMillis` is now computed with `LocalDate.of(1582, 10, 15)`. Referencing `RebaseDateTime` there loaded its rebase tables when `OrcFilters` was first used, about 0.3 to 0.7 s once per JVM, even for queries without timestamp filters. - The existing `filter pushdown - timestamp` test checks again that its 1000-01-01 and 1582-10-01 values are not pushed down. - The description now says that these predicates no longer show in the DSv2 `PushedFilters`, and that `OR`/`IN` with such a value no longer skip files. The nanosecond timestamp types (`TimestampNanosOrcOps`) look like they may have the same problem. I'll check them separately and open a follow-up JIRA if they do. -- 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]
