@@ -70,6 +70,7 @@ use substrait::proto::rel_common::EmitKind::Emit;
70
70
use substrait:: proto:: {
71
71
rel_common, ExchangeRel , ExpressionReference , ExtendedExpression , RelCommon ,
72
72
} ;
73
+ use substrait:: proto:: expression:: field_reference:: { RootReference , RootType } ;
73
74
use substrait:: {
74
75
proto:: {
75
76
aggregate_function:: AggregationInvocation ,
@@ -2150,7 +2151,7 @@ fn try_to_substrait_field_reference(
2150
2151
} ) ,
2151
2152
) ) ,
2152
2153
} ) ) ,
2153
- root_type : None ,
2154
+ root_type : Some ( RootType :: RootReference ( RootReference { } ) ) ,
2154
2155
} )
2155
2156
}
2156
2157
_ => substrait_err ! ( "Expect a `Column` expr, but found {expr:?}" ) ,
@@ -2192,13 +2193,14 @@ fn substrait_field_ref(index: usize) -> Result<Expression> {
2192
2193
} ) ,
2193
2194
) ) ,
2194
2195
} ) ) ,
2195
- root_type : None ,
2196
+ root_type : Some ( RootType :: RootReference ( RootReference { } ) ) ,
2196
2197
} ) ) ) ,
2197
2198
} )
2198
2199
}
2199
2200
2200
2201
#[ cfg( test) ]
2201
2202
mod test {
2203
+
2202
2204
use super :: * ;
2203
2205
use crate :: logical_plan:: consumer:: {
2204
2206
from_substrait_extended_expr, from_substrait_literal_without_names,
@@ -2422,6 +2424,22 @@ mod test {
2422
2424
Ok ( ( ) )
2423
2425
}
2424
2426
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
+
2425
2443
#[ test]
2426
2444
fn named_struct_names ( ) -> Result < ( ) > {
2427
2445
let schema = DFSchemaRef :: new ( DFSchema :: try_from ( Schema :: new ( vec ! [
0 commit comments