@@ -70,6 +70,7 @@ use substrait::proto::rel_common::EmitKind::Emit;
7070use substrait:: proto:: {
7171 rel_common, ExchangeRel , ExpressionReference , ExtendedExpression , RelCommon ,
7272} ;
73+ use substrait:: proto:: expression:: field_reference:: { RootReference , RootType } ;
7374use substrait:: {
7475 proto:: {
7576 aggregate_function:: AggregationInvocation ,
@@ -2150,7 +2151,7 @@ fn try_to_substrait_field_reference(
21502151 } ) ,
21512152 ) ) ,
21522153 } ) ) ,
2153- root_type : None ,
2154+ root_type : Some ( RootType :: RootReference ( RootReference { } ) ) ,
21542155 } )
21552156 }
21562157 _ => substrait_err ! ( "Expect a `Column` expr, but found {expr:?}" ) ,
@@ -2192,13 +2193,14 @@ fn substrait_field_ref(index: usize) -> Result<Expression> {
21922193 } ) ,
21932194 ) ) ,
21942195 } ) ) ,
2195- root_type : None ,
2196+ root_type : Some ( RootType :: RootReference ( RootReference { } ) ) ,
21962197 } ) ) ) ,
21972198 } )
21982199}
21992200
22002201#[ cfg( test) ]
22012202mod test {
2203+
22022204 use super :: * ;
22032205 use crate :: logical_plan:: consumer:: {
22042206 from_substrait_extended_expr, from_substrait_literal_without_names,
@@ -2422,6 +2424,22 @@ mod test {
24222424 Ok ( ( ) )
24232425 }
24242426
2427+
2428+ #[ test]
2429+ fn to_field_reference ( ) -> Result < ( ) > {
2430+ let expression = substrait_field_ref ( 2 ) ? ;
2431+
2432+ match & expression. rex_type {
2433+ Some ( RexType :: Selection ( field_ref) ) => {
2434+ assert_ne ! ( field_ref. root_type, None ) ;
2435+
2436+ } ,
2437+
2438+ _ => assert ! ( false ) ,
2439+ }
2440+ Ok ( ( ) )
2441+ }
2442+
24252443 #[ test]
24262444 fn named_struct_names ( ) -> Result < ( ) > {
24272445 let schema = DFSchemaRef :: new ( DFSchema :: try_from ( Schema :: new ( vec ! [
0 commit comments