Skip to content

Commit 5ffd8dc

Browse files
Cover comparison bounds and Spark BETWEEN behavior
1 parent d9d5031 commit 5ffd8dc

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
@@ -21392,6 +21392,14 @@ fn parse_comparison_in_between_low_bound() {
2139221392
"SELECT a BETWEEN b BETWEEN 1 AND 2 AND c",
2139321393
"Expected: AND, found: BETWEEN",
2139421394
),
21395+
(
21396+
"SELECT a BETWEEN (1 AND 2 FROM t",
21397+
"Expected: ), found: FROM",
21398+
),
21399+
(
21400+
"SELECT a BETWEEN b = (1, 2 FROM t",
21401+
"Expected: ), found: FROM",
21402+
),
2139521403
] {
2139621404
assert_eq!(
2139721405
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)