Repository navigation
PostgreSQL, DuckDB, Spark, Databricks: Accept a comparison in the BETWEEN lower bound - #2665
Open
LucaCappelletti94 wants to merge 1 commit into
Open
LucaCappelletti94 wants to merge 1 commit into
LucaCappelletti94 wants to merge 1 commit into
Conversation
LucaCappelletti94
added this pull request to stack #2666
October 17, 2026 16:57
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## sqlite-between-operand-precedence #2665 +/- ##
==================================================================
Coverage 81.25% 81.26%
==================================================================
Files 42 42
Lines 33916 33939 +23
Branches 33916 33939 +23
==================================================================
+ Hits 27560 27579 +19
- Misses 2792 2795 +3
- Partials 3564 3565 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…TWEEN` lower bound
LucaCappelletti94
force-pushed
the
between-low-bound-comparison
branch
from
October 17, 2026 18:52
ec5975a to
b39c116
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2664, which this PR is stacked on.
PostgreSQL, DuckDB and Spark accept one comparison in the lower bound of a
BETWEEN, as inx BETWEEN 1 > 0 AND y, but rejectIS,LIKEor a nestedBETWEENthere. PostgreSQL 16 and DuckDB 1.4.4 runSELECT true BETWEEN 1 > 0 AND true,true BETWEEN 1 <> 2 AND trueandtrue BETWEEN 1 + 1 >= 2 AND true, and both rejecttrue BETWEEN 1 = 1 = true AND truewith a syntax error. Spark's grammar parses the bound as avalueExpression, which includescomparison(https://github.com/apache/spark/blob/master/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4). These dialects stopped the bound before the comparison and failed withExpected: AND, found: >.A single precedence threshold cannot express this, because PostgreSQL ranks
LIKEandBETWEENabove comparisons. A new dialect method,supports_comparison_in_between_low_bound, lets the parser read one comparison after the bound, with its right side parsed atBETWEENprecedence. It is enabled for PostgreSQL, DuckDB, Spark, Databricks and the generic dialect. Tests check the parsed bound and the rejected forms in those dialects, and the unchanged error everywhere else.