Skip to content

Commit 0146c69

Browse files
Cover comparison bounds and Spark BETWEEN behavior
1 parent 094e849 commit 0146c69

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎tests/sqlparser_common.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21056,6 +21056,14 @@ fn parse_comparison_in_between_low_bound() {
2105621056
"SELECT a BETWEEN b BETWEEN 1 AND 2 AND c",
2105721057
"Expected: AND, found: BETWEEN",
2105821058
),
21059+
(
21060+
"SELECT a BETWEEN (1 AND 2 FROM t",
21061+
"Expected: ), found: FROM",
21062+
),
21063+
(
21064+
"SELECT a BETWEEN b = (1, 2 FROM t",
21065+
"Expected: ), found: FROM",
21066+
),
2105921067
] {
2106021068
assert_eq!(
2106121069
dialects.parse_sql_statements(sql),

‎tests/sqlparser_spark.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,22 @@ fn test_substring() {
362362
fn test_pipe_operator() {
363363
spark().verified_stmt("SELECT * FROM t |> WHERE x > 1 |> SELECT x AS y |> ORDER BY y");
364364
}
365+
366+
// Spark is not part of all_dialects, so the between low bound comparison is pinned here.
367+
368+
#[test]
369+
fn parse_comparison_in_between_low_bound() {
370+
match spark().verified_expr("a BETWEEN b > 1 AND c") {
371+
Expr::Between { low, .. } => assert!(
372+
matches!(
373+
&*low,
374+
Expr::BinaryOp {
375+
op: BinaryOperator::Gt,
376+
..
377+
}
378+
),
379+
"{low:?}"
380+
),
381+
other => panic!("expected BETWEEN, got {other:?}"),
382+
}
383+
}

0 commit comments

Comments
 (0)