Open alancai98 opened 2 months ago
From prior discussion, the modeling of SQL set ops needs to also support LIMIT
, OFFSET
, and ORDER BY
, which is not currently supported in the parser.
For example the following does not currently parse:
PartiQL> (SELECT a FROM <<{'a': 1}>> LIMIT 1 UNION SELECT a FROM <<{'a': 2}>> LIMIT 1) LIMIT 1
| !!
Parser Error: at line 1, column 79: unexpected token found, LIMIT : LIMIT
mismatched input 'LIMIT' expecting {<EOF>, ';'}
In the AST, we can consider a modeling more similar to what partiql-lang-rust uses: https://github.com/partiql/partiql-lang-rust/blob/c91c5a4727f65523dea55fbdd9b9530d1df19d63/partiql-ast/src/ast.rs#L270-L278.
Alternatively, we can look at what another SQL parsing crate uses: https://docs.rs/sqlparser/0.48.0/sqlparser/ast/enum.SetExpr.html.
Description
main
andv1
branches, the ast's modeling ofset_op.s_f_w
does not allow for defining left associative set operations (UNION, EXCEPT, INTERSECT).Current modeling on
main
/v1
: https://github.com/partiql/partiql-lang-kotlin/blob/edef7fb8048a07fc3fef913ccb812d49434bf4c1/partiql-ast/src/main/resources/partiql_ast.ion#L494-L510Assuming SFW_1, SFW_2, SFW_3 represent 3 different SFW queries. Then the following cannot be modeled in the current AST using
set_op.s_f_w
:Set operations are by default left-associative, so
SFW_1 <set_op> SFW_2 <set_op> SFW_3
is also not representable.To Reproduce
Steps to reproduce the behavior:
Expected Behavior
Additional Context
v1
branch