@@ -499,7 +499,7 @@ LikeClause =
499499 'like'
500500
501501WhereClause =
502- 'where'
502+ 'where' Expr
503503
504504GroupByClause =
505505 'group' 'by' ('all' | 'distinct') (GroupingRollup | GroupingCube | GroupingSets | GroupingExpr)
@@ -539,7 +539,7 @@ DistinctClause =
539539
540540Target =
541541 '*'
542- | Expr
542+ | ( Expr ('as' Name)?)
543543
544544TargetList =
545545 Target (',' Target)*
@@ -567,13 +567,13 @@ UsingClause =
567567 'using'
568568
569569Alias =
570- 'as'?
570+ 'as'? ColumnList?
571571
572572SequenceOptionList =
573573 '(' ')'
574574
575575ColumnList =
576- '(' ')'
576+ '(' (Column (',' Column)*) ')'
577577
578578ConstraintIncludeClause =
579579 'include'
@@ -613,7 +613,7 @@ JoinUsingClause =
613613 'using' ColumnList Alias?
614614
615615Join =
616- 'natural'? JoinType (using_clause:JoinUsingClause | OnClause)?
616+ 'natural'? JoinType FromItem (using_clause:JoinUsingClause | OnClause)?
617617
618618JoinExpr =
619619 (FromItem | JoinExpr) Join
@@ -625,6 +625,7 @@ ParenSelect =
625625 ')'
626626
627627Select =
628+ WithClause?
628629 SelectClause
629630 FromClause?
630631 WhereClause?
@@ -1036,8 +1037,16 @@ Materialized =
10361037NotMaterialized =
10371038 'not' 'materialized'
10381039
1040+ WithQuery =
1041+ Select
1042+ | Values
1043+ | Insert
1044+ | Update
1045+ | Delete
1046+ | Merge
1047+
10391048WithTable =
1040- 'with' (Materialized | NotMaterialized)?
1049+ Name ColumnList? 'as'? (Materialized | NotMaterialized)? '(' query:WithQuery ')'
10411050
10421051WithClause =
10431052 'with' 'recursive'? (WithTable (',' WithTable)*)
@@ -1092,7 +1101,10 @@ OrderByClause =
10921101 'order' 'by' (SortBy (',' SortBy)*)
10931102
10941103FromItem =
1095- 'only'? NameRef
1104+ 'only'? NameRef Alias?
1105+ | 'lateral'? ParenSelect Alias?
1106+ | 'lateral'? CallExpr Alias?
1107+ | 'lateral'? 'rows' 'from' '(' CallExpr ')' Alias?
10961108
10971109FromClause =
10981110 'from'
0 commit comments