query.ebnf(select): sync with query.pest
Summarize the changes
- query.ebnf: add
scan
diagram - query.ebnf(select): sync with query.pest
- query.ebnf(update): sync with query.pest
- query.ebnf: replace with "query" where needed
В продолжение обсуждения в docs#244 (closed)
Должен быть влит после !492 (merged)
Предлагаемые изменения
- Добавить диаграмму
scan
- Изменить определение диаграммы
select
- Изменить определение диаграммы
update
- Переименовать диаграмму
cte
->query
и заменитьselect
наquery
в диаграммах — согласно определениям изquery.pest
Описание
В query.pest
есть три выражения SELECT
:
-
SelectFull = { (^"with" ~ Cte ~ ("," ~ Cte)*)? ~ SelectWithOptionalContinuation }
Подвыражения
Cte = { Identifier ~ ("(" ~ CteColumn ~ ("," ~ CteColumn)* ~ ")")? ~ ^"as" ~ "(" ~ (SelectWithOptionalContinuation | Values) ~ ")" } CteColumn = @{ Identifier }
-
SelectWithOptionalContinuation
– сокращу доSelectWOC
:SelectWithOptionalContinuation = { Select ~ (SelectOp ~ Select)* } SelectOp = _{ UnionAllOp | ExceptOp | UnionOp } UnionOp = { ^"union" } ExceptOp = { (^"except" ~ ^"distinct") | ^"except" } UnionAllOp = { ^"union" ~ ^"all" }
-
Select = { ^"select" ~ Projection ~ ^"from" ~ Scan ~ Join* ~ WhereClause? ~ (^"group" ~ ^"by" ~ GroupBy)? ~ (^"having" ~ Having)? ~ (^"order" ~ ^"by" ~ OrderBy)? }
Подвыражения
Projection
,WhereClause
,Scan
,Join
,GroupBy
,Having
,OrderBy
:Projection = { Distinct? ~ ProjectionElement ~ ("," ~ ProjectionElement)* } ProjectionElement = _{ Asterisk | Column } Column = { Expr ~ ((^"as")? ~ Identifier)? } Asterisk = { (Identifier ~ ".")? ~ "*" } WhereClause = _{ ^"where" ~ Selection } Selection = { Expr } Scan = { (ScanCteOrTable| SubQuery) ~ ((^"as")? ~ Identifier)? } Join = { JoinKind? ~ ^"join" ~ Scan ~ ^"on" ~ Expr } JoinKind = _{ ( InnerJoinKind | LeftJoinKind ) } InnerJoinKind = { ^"inner" } LeftJoinKind = { ^"left" ~ (^"outer")? } GroupBy = { Expr ~ ("," ~ Expr)* } Having = { Expr } OrderBy = { OrderByElement ~ ("," ~ OrderByElement)* } OrderByElement = { Expr ~ OrderFlag? } OrderFlag = _{ Asc | Desc } Asc = { ^"asc" } Desc = { ^"desc" } SubQuery = { "(" ~ (SelectFull | Values) ~ ")" }
Использование
-
Select
:-
INSERT —— исправлено в !492 (merged)Insert
-
SELECT, после
('UNION' 'ALL'? | 'EXCEPT' 'DISTINCT'?)
—SelectWOC
-
-
SelectWOC
:-
WITH и CTE —
SelectFull
,Cte
-
WITH и CTE —
-
SelectFull
— все остальные диаграммы
Ensure that
-
New code is covered by unit and integration tests. -
Related issues would be automatically closed with gitlab's closing pattern (Closes #1, #2
). -
Public modules are documented (check the rendered version withcargo doc --open
). -
(if PEST grammar is changed) EBNF grammar reflects these changes (check the result with railroad diagram generator.
Next steps
Cherry-pick to: none / 24.2 / 24.3Update sbroad submodule in picodata/picodata.- (if EBNF grammar is changed) create a follow-up issue in picodata/docs — docs!516 (merged)
Edited by Artur Sabirov