Skip to content

Commit

Permalink
fix(sqlparser): fix operator precedence between '>=' and 'IN' (#7665)
Browse files Browse the repository at this point in the history
Approved-By: kwannoel

Co-Authored-By: Noel Kwan <47273164+kwannoel@users.noreply.github.com>
Co-Authored-By: aodong.qin <ioperations.c@gmail.com>
Co-Authored-By: ioperations <65484906+ioperations@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 3, 2023
1 parent 704cc4f commit 1f6b063
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/frontend/planner_test/tests/testdata/expr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,13 @@
logical_plan: |
LogicalProject { exprs: [Array(1:Int32, null:Int32)] }
└─LogicalValues { rows: [[]], schema: Schema { fields: [] } }
- name: regression (#7641) -fuzzing test failed at Bind error,types Boolean and Varchar cannot be matched
sql: |
select false >= 'LN1O0QP1yi' NOT IN (md5('4SeUPZhUbH'))
batch_plan: |
BatchProject { exprs: [(false:Boolean >= Not(In('LN1O0QP1yi':Varchar, Md5('4SeUPZhUbH':Varchar))))] }
└─BatchValues { rows: [[]] }
- name: const_eval of const expr
sql: |
create table t(v1 int);
Expand All @@ -546,4 +553,4 @@
└─BatchScan { table: t, columns: [t.v1], distribution: SomeShard }
- name: const_eval of division by 0 error
sql: |
select 1 / 0 t1;
select 1 / 0 t1;
4 changes: 2 additions & 2 deletions src/sqlparser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ pub struct Parser {
}

impl Parser {
const BETWEEN_PREC: u8 = 20;
const BETWEEN_PREC: u8 = 21;
const PLUS_MINUS_PREC: u8 = 30;
const TIME_ZONE_PREC: u8 = 20;
const TIME_ZONE_PREC: u8 = 21;
const UNARY_NOT_PREC: u8 = 15;

/// Parse the specified tokens
Expand Down

0 comments on commit 1f6b063

Please sign in to comment.