@@ -42,7 +42,6 @@ SfwClauses: ast::Select = {
42
42
<limit:LimitClause?>
43
43
<offset:OffsetByClause?> => {
44
44
ast::Select {
45
- setq: None,
46
45
project,
47
46
from,
48
47
from_let: None,
@@ -69,7 +68,6 @@ FwsClauses: ast::Select = {
69
68
<offset:OffsetByClause?>
70
69
<project:SelectClause> => {
71
70
ast::Select {
72
- setq: None,
73
71
project,
74
72
from: Some(from),
75
73
from_let: None,
@@ -93,12 +91,33 @@ WithClause: () = {}
93
91
// SELECT //
94
92
// ------------------------------------------------------------------------------ //
95
93
SelectClause: ast::ProjectionAst = {
96
- <lo:@L> "SELECT" "*" <hi:@R> => ast::Projection::ProjectStar.ast(lo..hi),
97
- <lo:@L> "SELECT" <project_items:CommaSepPlus<Projection>> <hi:@R> => ast::Projection::ProjectList(project_items).ast(lo..hi),
98
- <lo:@L> "SELECT" "VALUE" <value:ExprQuery> <hi:@R> => ast::Projection::ProjectValue(value).ast(lo..hi),
99
- <lo:@L> "PIVOT" <value:ExprQuery> "AT" <key:ExprQuery> <hi:@R> => {
100
- ast::Projection::ProjectPivot { key, value }.ast(lo..hi)
101
- },
94
+ <lo:@L> "SELECT" <strategy: SetQuantifierStrategy> "*" <hi:@R> => ast::Projection {
95
+ kind: ast::ProjectionKind::ProjectStar,
96
+ setq: Some(strategy)
97
+ }.ast(lo..hi),
98
+ <lo:@L> "SELECT" <strategy: SetQuantifierStrategy> <project_items:CommaSepPlus<Projection>> <hi:@R> => ast::Projection {
99
+ kind: ast::ProjectionKind::ProjectList(project_items),
100
+ setq: Some(strategy),
101
+ }.ast(lo..hi),
102
+ <lo:@L> "SELECT" <strategy: SetQuantifierStrategy> "VALUE" <value:ExprQuery> <hi:@R> => ast::Projection {
103
+ kind: ast::ProjectionKind::ProjectValue(value),
104
+ setq: Some(strategy),
105
+ }.ast(lo..hi),
106
+ <lo:@L> "PIVOT" <value:ExprQuery> "AT" <key:ExprQuery> <hi:@R> => ast::Projection {
107
+ kind: ast::ProjectionKind::ProjectPivot { key, value },
108
+ setq: None
109
+ }.ast(lo..hi),
110
+ }
111
+
112
+ #[inline]
113
+ SetQuantifierStrategy: ast::SetQuantifier = {
114
+ "ALL" => ast::SetQuantifier::All,
115
+ <distinct: "DISTINCT"?> => {
116
+ match distinct {
117
+ Some(_) => ast::SetQuantifier::Distinct,
118
+ None => ast::SetQuantifier::All,
119
+ }
120
+ }
102
121
}
103
122
104
123
#[inline]
@@ -137,10 +156,12 @@ FromClause: ast::FromClauseAst = {
137
156
.unwrap() // safe, because we know there's at least 1 input
138
157
}
139
158
}
159
+
140
160
TableReference: ast::FromClauseAst = {
141
161
<TableNonJoin>,
142
162
<TableJoined>,
143
163
}
164
+
144
165
TableNonJoin: ast::FromClauseAst = {
145
166
<lo:@L> <t:TableBaseReference> <hi:@R> => ast::FromClause::FromLet( t ).ast(lo..hi),
146
167
<lo:@L> <t:TableUnpivot> <hi:@R> => ast::FromClause::FromLet( t ).ast(lo..hi),
@@ -669,8 +690,24 @@ ExprPair: ast::ExprPair = {
669
690
670
691
#[inline]
671
692
FunctionCall: ast::Call = {
672
- <func_name:"Identifier"> "(" <args:CommaSepPlus<ExprQuery>> ")" =>
673
- ast::Call{ func_name: ast::SymbolPrimitive{ value: func_name.to_owned() }, args }
693
+ <func_name:"Identifier"> "(" <strategy: SetQuantifierStrategy> ")" =>
694
+ ast::Call {
695
+ func_name: ast::SymbolPrimitive{ value: func_name.to_owned() },
696
+ args: Vec::new(),
697
+ setq: Some(strategy)
698
+ },
699
+ <func_name:"Identifier"> "(" <strategy: SetQuantifierStrategy> "*" ")" =>
700
+ ast::Call {
701
+ func_name: ast::SymbolPrimitive{ value: func_name.to_owned() },
702
+ args: Vec::new(),
703
+ setq: Some(strategy)
704
+ },
705
+ <func_name:"Identifier"> "(" <strategy: SetQuantifierStrategy> <args:CommaSepPlus<ExprQuery>> ")" =>
706
+ ast::Call {
707
+ func_name: ast::SymbolPrimitive{ value: func_name.to_owned() },
708
+ args,
709
+ setq: Some(strategy)
710
+ },
674
711
}
675
712
676
713
PathExpr: ast::Path = {
@@ -901,6 +938,7 @@ extern {
901
938
"BY" => lexer::Token::By,
902
939
"CROSS" => lexer::Token::Cross,
903
940
"DESC" => lexer::Token::Desc,
941
+ "DISTINCT" => lexer::Token::Distinct,
904
942
"ESCAPE" => lexer::Token::Escape,
905
943
"EXCEPT" => lexer::Token::Except,
906
944
"FALSE" => lexer::Token::False,
0 commit comments