hcrosse commented on code in PR #3623:
URL: https://github.com/apache/iceberg-rust/pull/3623#discussion_r4590002017


##########
crates/iceberg/src/arrow/reader/predicate_visitor.rs:
##########
@@ -278,6 +278,27 @@ fn project_column(
     }
 }
 
+/// Like [`project_column`], but widens millisecond timestamps to microseconds 
so
+/// comparisons with microsecond literals keep their precision.
+fn project_comparison_column(
+    batch: &RecordBatch,
+    column_idx: usize,
+) -> std::result::Result<ArrayRef, ArrowError> {
+    let column = project_column(batch, column_idx)?;
+
+    match column.data_type() {
+        DataType::Timestamp(TimeUnit::Millisecond, tz) => cast_with_options(
+            &column,
+            &DataType::Timestamp(TimeUnit::Microsecond, tz.clone()),
+            &CastOptions {
+                safe: false,
+                ..Default::default()
+            },
+        ),
+        _ => Ok(column),
+    }
+}

Review Comment:
   I agree. If #3540 lands first, I'll drop the widening commit and its two 
unit tests and keep the end to end test.



##########
crates/iceberg/src/expr/visitors/bloom_filter_evaluator.rs:
##########
@@ -1612,4 +1633,39 @@ mod tests {
         let result = BloomFilterEvaluator::eval(&predicate, 
&bloom_filters).unwrap();
         assert!(result, "non-representable double must not prune");
     }
+
+    #[test]
+    fn test_eq_probes_timestamp_in_column_unit() {
+        let schema = Arc::new(single_field_schema("ts", 
PrimitiveType::Timestamp));
+        let filter = |unit, values: &[i64]| {
+            let mut sbbf = Sbbf::new_with_ndv_fpp(values.len() as u64, 
0.01).unwrap();
+            for v in values {
+                sbbf.insert(v);
+            }
+            HashMap::from([(
+                1,
+                ColumnBloomFilter::new(sbbf, PhysicalType::INT64, 0)
+                    .with_timestamp_unit(Some(unit)),
+            )])
+        };
+        let millis = filter(TimeUnit::Millisecond, &[-1_500, 2_000]);
+        let nanos = filter(TimeUnit::Nanosecond, &[2_000_000_000]);
+
+        for (filters, micros, expected) in [
+            (&millis, 2_000_000, true),
+            (&millis, 2_000_500, false),
+            (&millis, -1_500_000, true),
+            (&nanos, 2_000_000, true),
+        ] {

Review Comment:
   I added `(&millis, 3_000_000, false)`, so the test also checks a whole 
millisecond value that is absent from the filter.



##########
crates/iceberg/src/arrow/schema.rs:
##########
@@ -2776,16 +2807,95 @@ mod tests {
             PrimitiveType::Geography(GeographyType::default()),
         ] {
             assert_eq!(
-                get_parquet_stat_min_as_datum(&primitive_type, 
&stats).unwrap(),
+                get_parquet_stat_min_as_datum(&primitive_type, &stats, 
None).unwrap(),
                 None
             );
             assert_eq!(
-                get_parquet_stat_max_as_datum(&primitive_type, 
&stats).unwrap(),
+                get_parquet_stat_max_as_datum(&primitive_type, &stats, 
None).unwrap(),
                 None
             );
         }
     }
 
+    #[test]
+    fn test_parquet_timestamp_unit() {

Review Comment:
   I added `TIMESTAMP(MICROS,true)`, `TIMESTAMP(NANOS,false)` and legacy 
`TIMESTAMP_MICROS` columns to `test_parquet_timestamp_unit`, with the expected 
units.



-- 
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]

Reply via email to