Fix precendence bug in S3Select SQL IN clauses (#18708)

Fixes a precendence issue in SQL Select where `a in b and c = 3` was parsed as `a
in (b and c = 3)`.

Fixes #18682
This commit is contained in:
Aditya Manthramurthy
2023-12-22 23:19:11 -08:00
committed by GitHub
parent 8bd4f6568b
commit 496027b589
5 changed files with 57 additions and 12 deletions

View File

@@ -166,8 +166,7 @@ type Condition struct {
Not *Condition `parser:"| \"NOT\" @@"`
}
// ConditionOperand is a operand followed by an an optional operation
// expression
// ConditionOperand is a operand followed by an optional operation expression.
type ConditionOperand struct {
Operand *Operand `parser:"@@"`
ConditionRHS *ConditionRHS `parser:"@@?"`
@@ -202,9 +201,13 @@ type Between struct {
End *Operand `parser:" \"AND\" @@ "`
}
// In represents the RHS of an IN expression
// In represents the RHS of an IN expression. The RHS can be a list-literal
// (i.e. enclosed in parantheses like `IN (1,2,4)`) or it could be a JSON path
// expression (as in `8.5 IN s.nested[*][*]`). Specifically, it cannot be an
// `Expression` as an expression can never evaluate to a list.
type In struct {
ListExpression *Expression `parser:"@@ "`
JPathExpr *JSONPath `parser:"@@"`
ListExpr *ListExpr `parser:"| @@"`
}
// Grammar for Operand: