@@ -56,6 +56,7 @@ use datafusion::prelude::Expr;
56
56
use pbjson_types:: Any as ProtoAny ;
57
57
use substrait:: proto:: exchange_rel:: { ExchangeKind , RoundRobin , ScatterFields } ;
58
58
use substrait:: proto:: expression:: cast:: FailureBehavior ;
59
+ use substrait:: proto:: expression:: field_reference:: { RootReference , RootType } ;
59
60
use substrait:: proto:: expression:: literal:: interval_day_to_second:: PrecisionMode ;
60
61
use substrait:: proto:: expression:: literal:: map:: KeyValue ;
61
62
use substrait:: proto:: expression:: literal:: {
@@ -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,26 @@ mod test {
2422
2424
Ok ( ( ) )
2423
2425
}
2424
2426
2427
+ #[ test]
2428
+ fn to_field_reference ( ) -> Result < ( ) > {
2429
+ let expression = substrait_field_ref ( 2 ) ?;
2430
+
2431
+ match & expression. rex_type {
2432
+ Some ( RexType :: Selection ( field_ref) ) => {
2433
+ assert_eq ! (
2434
+ field_ref
2435
+ . root_type
2436
+ . clone( )
2437
+ . expect( "root type should be set" ) ,
2438
+ RootType :: RootReference ( RootReference { } )
2439
+ ) ;
2440
+ }
2441
+
2442
+ _ => panic ! ( "Should not be anything other than field reference" ) ,
2443
+ }
2444
+ Ok ( ( ) )
2445
+ }
2446
+
2425
2447
#[ test]
2426
2448
fn named_struct_names ( ) -> Result < ( ) > {
2427
2449
let schema = DFSchemaRef :: new ( DFSchema :: try_from ( Schema :: new ( vec ! [
0 commit comments