From b3a98360d25eb3a8e774e80463f1582f0c18a99f Mon Sep 17 00:00:00 2001
From: "a.sabirov" <a.sabirov@picodata.io>
Date: Fri, 26 Jul 2024 15:27:11 +0300
Subject: [PATCH] query.ebnf: add `scan` diagram

Definition:
https://git.picodata.io/picodata/picodata/sbroad/-/blob/b1b021bff1ea23aa8d0fb74a0ed0fd409043a6bb/sbroad-core/src/frontend/sql/query.pest#L186
---
 doc/sql/query.ebnf | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/doc/sql/query.ebnf b/doc/sql/query.ebnf
index c9f9535fa0..b701c230c8 100644
--- a/doc/sql/query.ebnf
+++ b/doc/sql/query.ebnf
@@ -11,10 +11,10 @@ cte         ::= ('WITH'
                 (',' cte ('(' column (',' column)* ')')? 'AS' '(' (select | values) ')')*
                 )? select
 select      ::= 'SELECT' 'DISTINCT'?  ((projection (',' projection)*))
-                'FROM' (table | ('(' (select | values) ')')) (('AS')? name)?
+                'FROM' scan
                 (
                     ('INNER' | ('LEFT' ('OUTER')?))? 'JOIN' (
-                        ((table | ('(' (select | values) ')')) (('AS')? name)?)
+                        (scan)
                     )
                     'ON' expression
                 )*
@@ -24,6 +24,7 @@ select      ::= 'SELECT' 'DISTINCT'?  ((projection (',' projection)*))
                 ('ORDER' 'BY' (expression ('ASC' | 'DESC')?) (',' expression ('ASC' | 'DESC')?)*)?
                 ((('UNION' 'ALL'?) | ('EXCEPT' 'DISTINCT'?)) select)*
 projection  ::= (table '.')? '*' | expression (('AS')? name)? | aggregate
+scan        ::= (table | '(' (select | values) ')') ('AS'? name)?
 expression  ::= (table '.')? column
                | expression ('IS' ('NOT')? 'NULL')
                | expression ('OR' | 'AND' | '*' | '/' | '+' | '-' | '=' | '>' | '<' | '>=' | '<=' | ('<>' | '!=')) expression
@@ -73,7 +74,7 @@ update      ::= 'UPDATE' table
                     column '=' expression
                     (',' column '=' expression)*
                 )
-                ('FROM' '(' (select | values) ')' (('AS')? name)?)? ('WHERE' expression)?
+                ('FROM' scan)? ('WHERE' expression)?
 
 acl         ::= (alter_user | create_role | create_user | drop_role | drop_user | grant | revoke)
                 ('OPTION' '(' ('TIMEOUT' '=' double)')')?
-- 
GitLab