Plans a ` ANY( )` expression for non-subquery operands.
(
left_expr: Expr,
right_expr: Expr,
compare_op: &BinaryOperator,
)
| 1266 | |
| 1267 | /// Plans a `<left> <op> ANY(<right>)` expression for non-subquery operands. |
| 1268 | fn plan_any_op( |
| 1269 | left_expr: Expr, |
| 1270 | right_expr: Expr, |
| 1271 | compare_op: &BinaryOperator, |
| 1272 | ) -> Result<Expr> { |
| 1273 | match compare_op { |
| 1274 | BinaryOperator::Eq => Ok(array_has(right_expr, left_expr)), |
| 1275 | BinaryOperator::NotEq => { |
| 1276 | let min = array_min(right_expr.clone()); |
| 1277 | let max = array_max(right_expr.clone()); |
| 1278 | // NOT EQ is true when either bound differs from left |
| 1279 | let comparison = min |
| 1280 | .not_eq(left_expr.clone()) |
| 1281 | .or(max.clone().not_eq(left_expr)); |
| 1282 | any_op_with_null_handling(max, comparison, right_expr) |
| 1283 | } |
| 1284 | BinaryOperator::Gt => { |
| 1285 | let min = array_min(right_expr.clone()); |
| 1286 | any_op_with_null_handling(min.clone(), min.lt(left_expr), right_expr) |
| 1287 | } |
| 1288 | BinaryOperator::Lt => { |
| 1289 | let max = array_max(right_expr.clone()); |
| 1290 | any_op_with_null_handling(max.clone(), max.gt(left_expr), right_expr) |
| 1291 | } |
| 1292 | BinaryOperator::GtEq => { |
| 1293 | let min = array_min(right_expr.clone()); |
| 1294 | any_op_with_null_handling(min.clone(), min.lt_eq(left_expr), right_expr) |
| 1295 | } |
| 1296 | BinaryOperator::LtEq => { |
| 1297 | let max = array_max(right_expr.clone()); |
| 1298 | any_op_with_null_handling(max.clone(), max.gt_eq(left_expr), right_expr) |
| 1299 | } |
| 1300 | _ => plan_err!( |
| 1301 | "Unsupported AnyOp: '{compare_op}', only '=', '<>', '>', '<', '>=', '<=' are supported" |
| 1302 | ), |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | /// Plans `needle <compare_op> ALL(haystack)` with proper SQL NULL semantics. |
| 1307 | /// |
no test coverage detected
searching dependent graphs…