Skip to content

Commit 2fa01e3

Browse files
kyleconroyclaude
andcommitted
Fix negative number with cast in BETWEEN expressions
When parsing negative numbers with :: cast like `-0.11::Float32`, the expression parsing loop in parseUnaryMinus was using LOWEST precedence, which incorrectly consumed the `and` keyword from BETWEEN expressions. Fix by using MUL_PREC as the threshold, which allows casts (::) and member access (.) but stops before operators like AND. Fixes stmt42 and stmt43 in 02892_orc_filter_pushdown and stmt26 in 02841_parquet_filter_pushdown. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 17fe6ac commit 2fa01e3

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

parser/expression.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,10 @@ func (p *Parser) parseUnaryMinus() ast.Expression {
11271127
}
11281128
p.nextToken() // move past number
11291129
// Apply postfix operators like :: using the expression parsing loop
1130+
// Use MUL_PREC as the threshold to allow casts (::) and member access (.)
1131+
// but stop before operators like AND which has lower precedence
11301132
left := ast.Expression(lit)
1131-
for !p.currentIs(token.EOF) && LOWEST < p.precedenceForCurrent() {
1133+
for !p.currentIs(token.EOF) && MUL_PREC < p.precedenceForCurrent() {
11321134
startPos := p.current.Pos
11331135
left = p.parseInfixExpression(left)
11341136
if left == nil {
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt26": true
4-
}
5-
}
1+
{}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt42": true,
4-
"stmt43": true
5-
}
6-
}
1+
{}

0 commit comments

Comments
 (0)