@@ -5,10 +5,10 @@ use std::ffi::c_void;
55use delta_kernel:: expressions:: {
66 ArrayData , BinaryExpression , BinaryExpressionOp , BinaryPredicate , BinaryPredicateOp ,
77 ColumnName , Expression , ExpressionRef , ExpressionStructPatch , JunctionPredicate ,
8- JunctionPredicateOp , MapData , MapToStructExpression , OpaqueExpression , OpaqueExpressionOpRef ,
9- OpaquePredicate , OpaquePredicateOpRef , ParseJsonExpression , Predicate , Scalar , StructData ,
10- UnaryExpression , UnaryExpressionOp , UnaryPredicate , UnaryPredicateOp , VariadicExpression ,
11- VariadicExpressionOp ,
8+ JunctionPredicateOp , MapData , MapToStructExpression , MapToStructOptions , OpaqueExpression ,
9+ OpaqueExpressionOpRef , OpaquePredicate , OpaquePredicateOpRef , ParseJsonExpression , Predicate ,
10+ Scalar , StructData , UnaryExpression , UnaryExpressionOp , UnaryPredicate , UnaryPredicateOp ,
11+ VariadicExpression , VariadicExpressionOp ,
1212} ;
1313
1414use super :: kernel_visitor:: NullTypeTag ;
@@ -174,9 +174,9 @@ pub struct EngineExpressionVisitor {
174174 /// `child_list_id`. The `output_schema` handle specifies the schema to parse the JSON
175175 /// into.
176176 pub visit_parse_json : VisitParseJsonFn ,
177- /// Visits the `MapToStruct` expression belonging to the list identified by `sibling_list_id`.
178- /// The sub-expression (map column) will be in a _one_ item list identified by `child_list_id`.
179- /// The output struct schema is determined by the evaluator's result type .
177+ /// Visits a `MapToStruct` expression with default options. The sub-expression is in the
178+ /// one- item list identified by `child_list_id`. Expressions with configured options are
179+ /// reported through `visit_unknown` without visiting the child expression .
180180 pub visit_map_to_struct : VisitUnaryFn ,
181181 /// Visits the `LessThan` binary operator belonging to the list identified by
182182 /// `sibling_list_id`. The operands will be in a _two_ item list identified by
@@ -696,7 +696,12 @@ fn visit_expression_impl(
696696 schema_handle
697697 ) ;
698698 }
699- Expression :: MapToStruct ( MapToStructExpression { map_expr } ) => {
699+ Expression :: MapToStruct ( map_to_struct)
700+ if map_to_struct. options != MapToStructOptions :: default ( ) =>
701+ {
702+ visit_unknown ( visitor, sibling_list_id, "map_to_struct" )
703+ }
704+ Expression :: MapToStruct ( MapToStructExpression { map_expr, .. } ) => {
700705 let child_list_id = call ! ( visitor, make_field_list, 1 ) ;
701706 visit_expression_impl ( visitor, map_expr, child_list_id) ;
702707 call ! ( visitor, visit_map_to_struct, sibling_list_id, child_list_id) ;
@@ -771,7 +776,7 @@ fn visit_predicate_internal(predicate: &Predicate, visitor: &mut EngineExpressio
771776
772777#[ cfg( test) ]
773778mod tests {
774- use delta_kernel:: expressions:: { lit, Expression , Scalar } ;
779+ use delta_kernel:: expressions:: { lit, Expression , MapToStructOptions , Scalar } ;
775780 use rstest:: rstest;
776781
777782 use super :: * ;
@@ -791,6 +796,10 @@ mod tests {
791796 sibling_list_id : usize ,
792797 parts : Vec < String > ,
793798 } ,
799+ Unknown {
800+ sibling_list_id : usize ,
801+ name : String ,
802+ } ,
794803 }
795804
796805 #[ derive( Default ) ]
@@ -847,6 +856,18 @@ mod tests {
847856 } ) ;
848857 }
849858
859+ extern "C" fn visit_unknown_name (
860+ data : * mut c_void ,
861+ sibling_list_id : usize ,
862+ name : KernelStringSlice ,
863+ ) {
864+ let builder = unsafe { & mut * ( data as * mut TestExpressionBuilder ) } ;
865+ let name = unsafe { String :: try_from_slice ( & name) } . unwrap ( ) ;
866+ builder. events . push ( LiteralEvent :: Unknown {
867+ sibling_list_id,
868+ name,
869+ } ) ;
870+ }
850871 macro_rules! ignore_fn {
851872 ( $fn_name: ident $( , $arg_type: ty) * ) => {
852873 extern "C" fn $fn_name(
@@ -925,7 +946,7 @@ mod tests {
925946 visit_field_patch : ignore_field_patch,
926947 visit_opaque_expr : ignore_opaque_expr,
927948 visit_opaque_pred : ignore_opaque_pred,
928- visit_unknown : ignore_string_slice ,
949+ visit_unknown : visit_unknown_name ,
929950 }
930951 }
931952
@@ -992,4 +1013,25 @@ mod tests {
9921013 assert_eq ! ( top_level_id, 0 ) ;
9931014 assert_eq ! ( builder. events, vec![ expected] ) ;
9941015 }
1016+
1017+ #[ test]
1018+ fn timezone_aware_map_to_struct_visits_unknown ( ) {
1019+ let expression = Expression :: map_to_struct (
1020+ Expression :: column ( [ "partitionValues" ] ) ,
1021+ MapToStructOptions :: default ( ) . with_timestamp_timezone ( "America/Los_Angeles" ) ,
1022+ ) ;
1023+ let mut builder = TestExpressionBuilder :: default ( ) ;
1024+ let mut visitor = test_visitor ( & mut builder) ;
1025+
1026+ let top_level_id = visit_expression_internal ( & expression, & mut visitor) ;
1027+
1028+ assert_eq ! ( top_level_id, 0 ) ;
1029+ assert_eq ! (
1030+ builder. events,
1031+ vec![ LiteralEvent :: Unknown {
1032+ sibling_list_id: 0 ,
1033+ name: "map_to_struct" . to_string( ) ,
1034+ } ]
1035+ ) ;
1036+ }
9951037}
0 commit comments