From c917a879656dbc23dc6c1cbc49c69fa33606d3c5 Mon Sep 17 00:00:00 2001 From: Scott Donnelly Date: Tue, 13 Aug 2024 14:12:09 +0100 Subject: [PATCH] feat: support timestamp columns in row filters (#533) Fixes: https://github.com/apache/iceberg-rust/issues/532 --- crates/iceberg/src/arrow/schema.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/iceberg/src/arrow/schema.rs b/crates/iceberg/src/arrow/schema.rs index a69605e90..6215982d4 100644 --- a/crates/iceberg/src/arrow/schema.rs +++ b/crates/iceberg/src/arrow/schema.rs @@ -20,10 +20,12 @@ use std::collections::HashMap; use std::sync::Arc; -use arrow_array::types::{validate_decimal_precision_and_scale, Decimal128Type}; +use arrow_array::types::{ + validate_decimal_precision_and_scale, Decimal128Type, TimestampMicrosecondType, +}; use arrow_array::{ BooleanArray, Datum as ArrowDatum, Float32Array, Float64Array, Int32Array, Int64Array, - StringArray, + PrimitiveArray, Scalar, StringArray, TimestampMicrosecondArray, }; use arrow_schema::{DataType, Field, Fields, Schema as ArrowSchema, TimeUnit}; use bitvec::macros::internal::funty::Fundamental; @@ -613,6 +615,14 @@ pub(crate) fn get_arrow_datum(datum: &Datum) -> Result Ok(Box::new(Float32Array::new_scalar(value.as_f32()))), PrimitiveLiteral::Double(value) => Ok(Box::new(Float64Array::new_scalar(value.as_f64()))), PrimitiveLiteral::String(value) => Ok(Box::new(StringArray::new_scalar(value.as_str()))), + PrimitiveLiteral::Timestamp(value) => { + Ok(Box::new(TimestampMicrosecondArray::new_scalar(*value))) + } + PrimitiveLiteral::Timestamptz(value) => Ok(Box::new(Scalar::new( + PrimitiveArray::::new(vec![*value; 1].into(), None) + .with_timezone("UTC"), + ))), + l => Err(Error::new( ErrorKind::FeatureUnsupported, format!(