@@ -119,6 +119,7 @@ fn to_iceberg_predicate(expr: &Expr) -> TransformedResult {
119119 _ => TransformedResult :: NotTransformed ,
120120 }
121121 }
122+ Expr :: Cast ( c) => to_iceberg_predicate ( & c. expr ) ,
122123 _ => TransformedResult :: NotTransformed ,
123124 }
124125}
@@ -211,7 +212,7 @@ fn scalar_value_to_datum(value: &ScalarValue) -> Option<Datum> {
211212
212213#[ cfg( test) ]
213214mod tests {
214- use datafusion:: arrow:: datatypes:: { DataType , Field , Schema } ;
215+ use datafusion:: arrow:: datatypes:: { DataType , Field , Schema , TimeUnit } ;
215216 use datafusion:: common:: DFSchema ;
216217 use datafusion:: logical_expr:: utils:: split_conjunction;
217218 use datafusion:: prelude:: { Expr , SessionContext } ;
@@ -224,6 +225,7 @@ mod tests {
224225 let arrow_schema = Schema :: new ( vec ! [
225226 Field :: new( "foo" , DataType :: Int32 , true ) ,
226227 Field :: new( "bar" , DataType :: Utf8 , true ) ,
228+ Field :: new( "ts" , DataType :: Timestamp ( TimeUnit :: Second , None ) , true ) ,
227229 ] ) ;
228230 DFSchema :: try_from_qualified_schema ( "my_table" , & arrow_schema) . unwrap ( )
229231 }
@@ -392,4 +394,13 @@ mod tests {
392394 let expected_predicate = Reference :: new ( "foo" ) . less_than ( Datum :: long ( 0 ) ) ;
393395 assert_eq ! ( predicate, expected_predicate) ;
394396 }
397+
398+ #[ test]
399+ fn test_predicate_conversion_with_cast ( ) {
400+ let sql = "ts >= timestamp '2023-01-05T00:00:00'" ;
401+ let predicate = convert_to_iceberg_predicate ( sql) . unwrap ( ) ;
402+ let expected_predicate =
403+ Reference :: new ( "ts" ) . greater_than_or_equal_to ( Datum :: string ( "2023-01-05T00:00:00" ) ) ;
404+ assert_eq ! ( predicate, expected_predicate) ;
405+ }
395406}
0 commit comments