@@ -1053,6 +1053,12 @@ impl Planner {
1053
1053
ASTNode :: SQLBinaryExpr { op, left, right } => {
1054
1054
self . plan_binary_expr ( ctx, op, left, right, plan)
1055
1055
}
1056
+ ASTNode :: SQLBetween {
1057
+ expr,
1058
+ low,
1059
+ high,
1060
+ negated,
1061
+ } => self . plan_between ( ctx, expr, low, high, * negated, plan) ,
1056
1062
ASTNode :: SQLNested ( expr) => self . plan_expr ( ctx, expr, plan) ,
1057
1063
ASTNode :: SQLFunction {
1058
1064
name,
@@ -1061,41 +1067,6 @@ impl Planner {
1061
1067
all,
1062
1068
distinct,
1063
1069
} => self . plan_function ( ctx, name, args, over, * all, * distinct, plan) ,
1064
- ASTNode :: SQLBetween {
1065
- expr,
1066
- low,
1067
- high,
1068
- negated,
1069
- } => {
1070
- let low = ASTNode :: SQLBinaryExpr {
1071
- left : expr. clone ( ) ,
1072
- op : if * negated {
1073
- SQLOperator :: Lt
1074
- } else {
1075
- SQLOperator :: GtEq
1076
- } ,
1077
- right : low. clone ( ) ,
1078
- } ;
1079
- let high = ASTNode :: SQLBinaryExpr {
1080
- left : expr. clone ( ) ,
1081
- op : if * negated {
1082
- SQLOperator :: Gt
1083
- } else {
1084
- SQLOperator :: LtEq
1085
- } ,
1086
- right : high. clone ( ) ,
1087
- } ;
1088
- let both = ASTNode :: SQLBinaryExpr {
1089
- left : Box :: new ( low) ,
1090
- op : if * negated {
1091
- SQLOperator :: Or
1092
- } else {
1093
- SQLOperator :: And
1094
- } ,
1095
- right : Box :: new ( high) ,
1096
- } ;
1097
- self . plan_expr ( ctx, & both, plan)
1098
- }
1099
1070
_ => bail ! (
1100
1071
"complicated expressions are not yet supported: {}" ,
1101
1072
e. to_string( )
@@ -1301,6 +1272,45 @@ impl Planner {
1301
1272
Ok ( ( expr, typ) )
1302
1273
}
1303
1274
1275
+ fn plan_between < ' a > (
1276
+ & self ,
1277
+ ctx : & ExprContext ,
1278
+ expr : & ' a ASTNode ,
1279
+ low : & ' a ASTNode ,
1280
+ high : & ' a ASTNode ,
1281
+ negated : bool ,
1282
+ plan : & SQLPlan ,
1283
+ ) -> Result < ( Expr , Type ) , failure:: Error > {
1284
+ let low = ASTNode :: SQLBinaryExpr {
1285
+ left : Box :: new ( expr. clone ( ) ) ,
1286
+ op : if negated {
1287
+ SQLOperator :: Lt
1288
+ } else {
1289
+ SQLOperator :: GtEq
1290
+ } ,
1291
+ right : Box :: new ( low. clone ( ) ) ,
1292
+ } ;
1293
+ let high = ASTNode :: SQLBinaryExpr {
1294
+ left : Box :: new ( expr. clone ( ) ) ,
1295
+ op : if negated {
1296
+ SQLOperator :: Gt
1297
+ } else {
1298
+ SQLOperator :: LtEq
1299
+ } ,
1300
+ right : Box :: new ( high. clone ( ) ) ,
1301
+ } ;
1302
+ let both = ASTNode :: SQLBinaryExpr {
1303
+ left : Box :: new ( low) ,
1304
+ op : if negated {
1305
+ SQLOperator :: Or
1306
+ } else {
1307
+ SQLOperator :: And
1308
+ } ,
1309
+ right : Box :: new ( high) ,
1310
+ } ;
1311
+ self . plan_expr ( ctx, & both, plan)
1312
+ }
1313
+
1304
1314
fn plan_literal < ' a > ( & self , l : & ' a Value ) -> Result < ( Expr , Type ) , failure:: Error > {
1305
1315
let ( datum, ftype) = match l {
1306
1316
Value :: Long ( i) => ( Datum :: Int64 ( * i) , FType :: Int64 ) ,
0 commit comments