@@ -37,7 +37,11 @@ impl OptdPlanContext<'_> {
37
37
Ok ( scan. into_plan_node ( ) )
38
38
}
39
39
40
- fn conv_into_optd_expr ( & mut self , expr : & logical_expr:: Expr , context : & DFSchema ) -> Result < Expr > {
40
+ fn conv_into_optd_expr (
41
+ & mut self ,
42
+ expr : & logical_expr:: Expr ,
43
+ context : & DFSchema ,
44
+ ) -> Result < Expr > {
41
45
use logical_expr:: Expr ;
42
46
match expr {
43
47
Expr :: BinaryExpr ( node) => {
@@ -64,15 +68,39 @@ impl OptdPlanContext<'_> {
64
68
Expr :: Literal ( x) => match x {
65
69
ScalarValue :: UInt8 ( x) => {
66
70
let x = x. as_ref ( ) . unwrap ( ) ;
67
- Ok ( ConstantExpr :: int ( * x as i64 ) . into_expr ( ) )
71
+ Ok ( ConstantExpr :: uint8 ( * x) . into_expr ( ) )
68
72
}
69
- ScalarValue :: Utf8 ( x) => {
73
+ ScalarValue :: UInt16 ( x) => {
70
74
let x = x. as_ref ( ) . unwrap ( ) ;
71
- Ok ( ConstantExpr :: string ( x) . into_expr ( ) )
75
+ Ok ( ConstantExpr :: uint16 ( * x) . into_expr ( ) )
76
+ }
77
+ ScalarValue :: UInt32 ( x) => {
78
+ let x = x. as_ref ( ) . unwrap ( ) ;
79
+ Ok ( ConstantExpr :: uint32 ( * x) . into_expr ( ) )
80
+ }
81
+ ScalarValue :: UInt64 ( x) => {
82
+ let x = x. as_ref ( ) . unwrap ( ) ;
83
+ Ok ( ConstantExpr :: uint64 ( * x) . into_expr ( ) )
84
+ }
85
+ ScalarValue :: Int8 ( x) => {
86
+ let x = x. as_ref ( ) . unwrap ( ) ;
87
+ Ok ( ConstantExpr :: int8 ( * x) . into_expr ( ) )
88
+ }
89
+ ScalarValue :: Int16 ( x) => {
90
+ let x = x. as_ref ( ) . unwrap ( ) ;
91
+ Ok ( ConstantExpr :: int16 ( * x) . into_expr ( ) )
92
+ }
93
+ ScalarValue :: Int32 ( x) => {
94
+ let x = x. as_ref ( ) . unwrap ( ) ;
95
+ Ok ( ConstantExpr :: int32 ( * x) . into_expr ( ) )
72
96
}
73
97
ScalarValue :: Int64 ( x) => {
74
98
let x = x. as_ref ( ) . unwrap ( ) ;
75
- Ok ( ConstantExpr :: int ( * x) . into_expr ( ) )
99
+ Ok ( ConstantExpr :: int64 ( * x) . into_expr ( ) )
100
+ }
101
+ ScalarValue :: Utf8 ( x) => {
102
+ let x = x. as_ref ( ) . unwrap ( ) ;
103
+ Ok ( ConstantExpr :: string ( x) . into_expr ( ) )
76
104
}
77
105
ScalarValue :: Date32 ( x) => {
78
106
let x = x. as_ref ( ) . unwrap ( ) ;
@@ -118,7 +146,7 @@ impl OptdPlanContext<'_> {
118
146
expr,
119
147
)
120
148
. into_expr ( ) )
121
- }
149
+ }
122
150
_ => bail ! ( "Unsupported expression: {:?}" , expr) ,
123
151
}
124
152
}
@@ -224,22 +252,18 @@ impl OptdPlanContext<'_> {
224
252
// instead of converting them to a join on true, we bail out
225
253
226
254
match node. filter {
227
- Some ( DFExpr :: Literal ( ScalarValue :: Boolean ( Some ( val) ) ) ) => {
228
- Ok ( LogicalJoin :: new (
229
- left,
230
- right,
231
- ConstantExpr :: bool ( val) . into_expr ( ) ,
232
- join_type,
233
- ) )
234
- }
235
- None => {
236
- Ok ( LogicalJoin :: new (
237
- left,
238
- right,
239
- ConstantExpr :: bool ( true ) . into_expr ( ) ,
240
- join_type,
241
- ) )
242
- }
255
+ Some ( DFExpr :: Literal ( ScalarValue :: Boolean ( Some ( val) ) ) ) => Ok ( LogicalJoin :: new (
256
+ left,
257
+ right,
258
+ ConstantExpr :: bool ( val) . into_expr ( ) ,
259
+ join_type,
260
+ ) ) ,
261
+ None => Ok ( LogicalJoin :: new (
262
+ left,
263
+ right,
264
+ ConstantExpr :: bool ( true ) . into_expr ( ) ,
265
+ join_type,
266
+ ) ) ,
243
267
_ => bail ! ( "unsupported join filter: {:?}" , node. filter) ,
244
268
}
245
269
} else if log_ops. len ( ) == 1 {
@@ -279,7 +303,9 @@ impl OptdPlanContext<'_> {
279
303
LogicalPlan :: Projection ( node) => self . conv_into_optd_projection ( node) ?. into_plan_node ( ) ,
280
304
LogicalPlan :: Sort ( node) => self . conv_into_optd_sort ( node) ?. into_plan_node ( ) ,
281
305
LogicalPlan :: Aggregate ( node) => self . conv_into_optd_agg ( node) ?. into_plan_node ( ) ,
282
- LogicalPlan :: SubqueryAlias ( node) => self . conv_into_optd_plan_node ( node. input . as_ref ( ) ) ?,
306
+ LogicalPlan :: SubqueryAlias ( node) => {
307
+ self . conv_into_optd_plan_node ( node. input . as_ref ( ) ) ?
308
+ }
283
309
LogicalPlan :: Join ( node) => self . conv_into_optd_join ( node) ?. into_plan_node ( ) ,
284
310
LogicalPlan :: Filter ( node) => self . conv_into_optd_filter ( node) ?. into_plan_node ( ) ,
285
311
LogicalPlan :: CrossJoin ( node) => self . conv_into_optd_cross_join ( node) ?. into_plan_node ( ) ,
0 commit comments