antlr / grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PostgreSQL parser rule mistake on cube clause

Aosilujia opened this issue · comments

I find the rule not working on sql with cube clauses, for example

Input

GROUP BY a,
      CUBE(b,c)

Output

group_clause(group_by_list[group_by_item(a_expr("a"),group_by_item(a_expr("CUBE(b,c)")))])

The problem is the cube clause is parsed as an expression.

I find the problem is likely to be caused by that a_expr has higher priority than cube_clause:

group_by_item
   : a_expr
   | empty_grouping_set
   | cube_clause
   | rollup_clause
   | grouping_sets_clause
   ;

So I moved a_expr to the bottom in my own code and it seems to work.

As a new user I'm not quite sure of the effects, so I just report this.