Skip to content

Commit c1d6975

Browse files
committed
mtrlz/sql: plan BETWEEN
1 parent 8d9bd18 commit c1d6975

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fuzz/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/materialize/sql/mod.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,41 @@ impl Planner {
10611061
all,
10621062
distinct,
10631063
} => 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+
}
10641099
_ => bail!(
10651100
"complicated expressions are not yet supported: {}",
10661101
e.to_string()

0 commit comments

Comments
 (0)