@@ -834,20 +834,23 @@ pub trait DataSkippingPredicateEvaluator {
834834 ) -> Option < Self :: Output > {
835835 let max = self . get_max_stat ( col, & val. data_type ( ) ) ?;
836836
837- // Delta Lake min/max stats are stored with millisecond precision (truncated, not rounded up),
838- // so we need to adjust timestamp values by subtracting 999 microseconds from the value to ensure
839- // that comparisons against max stats are correct.
840- // Any rows that pass this filter will be re-evaluated later for exact matches.
837+ // Delta Lake min/max stats are stored with millisecond precision (truncated, not rounded up) so we can't use direct comparison.
838+ // For Ordering::Greater comparison we adjust timestamp values by subtracting 999 microseconds from the value to ensure
839+ // that comparisons against max stats are correct. Any rows that pass this filter will be re-evaluated later for exact matches.
841840 // See:
842841 // - https://github.com/delta-io/delta-kernel-rs/issues/1002
843842 // - https://github.com/delta-io/delta-kernel-rs/pull/1003
843+ if matches ! ( val, Scalar :: Timestamp ( _) | Scalar :: TimestampNtz ( _) ) {
844+ if !inverted && ord == Ordering :: Greater {
845+ let max_ts_adjusted = timestamp_subtract ( val, 999 ) ;
846+ tracing:: debug!(
847+ "Adjusted timestamp value for col {col} for max stat comparison from {val:?} to {max_ts_adjusted:?}"
848+ ) ;
849+ return self . eval_partial_cmp ( ord, max, & max_ts_adjusted, inverted) ;
850+ }
844851
845- if !inverted && ord == Ordering :: Greater && matches ! ( val, Scalar :: Timestamp ( _) | Scalar :: TimestampNtz ( _) ) {
846- let max_ts_adjusted = timestamp_subtract ( val, 999 ) ;
847- tracing:: debug!(
848- "Adjusted timestamp value for col {col} for max stat comparison from {val:?} to {max_ts_adjusted:?}"
849- ) ;
850- return self . eval_partial_cmp ( ord, max, & max_ts_adjusted, inverted) ;
852+ // Disabled by default: https://github.com/delta-io/delta-kernel-rs/issues/1002
853+ return None ;
851854 }
852855
853856 self . eval_partial_cmp ( ord, max, val, inverted)
@@ -995,16 +998,11 @@ impl<T: DataSkippingPredicateEvaluator + ?Sized> KernelPredicateEvaluator for T
995998 }
996999}
9971000
998-
9991001/// Adjust timestamp value by subtracting the given interval in microseconds.
10001002fn timestamp_subtract ( val : & Scalar , interval_micros : i64 ) -> Scalar {
10011003 match val {
1002- Scalar :: Timestamp ( ts) => {
1003- Scalar :: Timestamp ( * ts - interval_micros)
1004- } ,
1005- Scalar :: TimestampNtz ( ts) => {
1006- Scalar :: TimestampNtz ( * ts - interval_micros)
1007- } ,
1004+ Scalar :: Timestamp ( ts) => Scalar :: Timestamp ( * ts - interval_micros) ,
1005+ Scalar :: TimestampNtz ( ts) => Scalar :: TimestampNtz ( * ts - interval_micros) ,
10081006 _ => val. clone ( ) ,
10091007 }
1010- }
1008+ }
0 commit comments