From 6dc088c04587d511ba023065e2b064dcfce0e972 Mon Sep 17 00:00:00 2001 From: Josh Pschorr Date: Wed, 31 Jul 2024 15:06:10 -0700 Subject: [PATCH] Improvements to pretty-printing for AND/OR/CASE/PIVOT (#482) --- CHANGELOG.md | 4 +- partiql-ast/src/pretty.rs | 175 ++++++++++-------- partiql/tests/pretty.rs | 34 +++- partiql/tests/snapshots/pretty__pretty.snap | 39 ++-- partiql/tests/snapshots/pretty__pretty2.snap | 35 +++- .../pretty__pretty_ands_and_ors.snap | 85 +++++++++ .../tests/snapshots/pretty__pretty_bagop.snap | 73 ++++---- .../snapshots/pretty__pretty_case_1.snap | 67 ++++--- .../snapshots/pretty__pretty_case_2.snap | 80 ++++---- .../snapshots/pretty__pretty_exclude_1.snap | 6 +- .../snapshots/pretty__pretty_exclude_2.snap | 6 +- .../snapshots/pretty__pretty_exclude_3.snap | 12 +- .../snapshots/pretty__pretty_exclude_4.snap | 15 +- .../snapshots/pretty__pretty_expr_in.snap | 10 +- .../tests/snapshots/pretty__pretty_pivot.snap | 16 +- ...retty__pretty_select_value_tuple_ctor.snap | 19 +- .../tests/snapshots/pretty__pretty_setop.snap | 50 +++-- .../snapshots/pretty__pretty_typed_lits2.snap | 16 +- 18 files changed, 485 insertions(+), 257 deletions(-) create mode 100644 partiql/tests/snapshots/pretty__pretty_ands_and_ors.snap diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d232645..bfca598e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed - +- partiql-ast: fixed pretty-printing of `PIVOT` +- partiql-ast: improved pretty-printing of `CASE` and various clauses +- ### Added ### Fixed diff --git a/partiql-ast/src/pretty.rs b/partiql-ast/src/pretty.rs index b1cb69de..ad2dffe6 100644 --- a/partiql-ast/src/pretty.rs +++ b/partiql-ast/src/pretty.rs @@ -213,6 +213,16 @@ impl PrettyDoc for Select { D::Doc: Clone, A: Clone, { + fn format<'b, C, D, A>(child: &'b C, arena: &'b D) -> DocBuilder<'b, D, A> + where + D: DocAllocator<'b, A>, + D::Doc: Clone, + A: Clone, + C: PrettyDoc, + { + child.pretty_doc(arena).group() + } + fn delegate<'b, C, D, A>(child: &'b Option, arena: &'b D) -> Option> where D: DocAllocator<'b, A>, @@ -220,7 +230,7 @@ impl PrettyDoc for Select { A: Clone, C: PrettyDoc, { - child.as_ref().map(|inner| inner.pretty_doc(arena).group()) + child.as_ref().map(|inner| format(inner, arena)) } let Select { @@ -232,25 +242,32 @@ impl PrettyDoc for Select { group_by, having, } = self; - let clauses = [ - Some(project.pretty_doc(arena).group()), + let mut clauses = [ + Some(format(project, arena)), delegate(exclude, arena), - from.as_ref().map(|inner| inner.pretty_doc(arena).group()), - from_let - .as_ref() - .map(|inner| inner.pretty_doc(arena).group()), - where_clause - .as_ref() - .map(|inner| inner.pretty_doc(arena).group()), - group_by - .as_ref() - .map(|inner| inner.pretty_doc(arena).group()), - having.as_ref().map(|inner| inner.pretty_doc(arena).group()), + delegate(from, arena), + delegate(from_let, arena), + delegate(where_clause, arena), + delegate(group_by, arena), + delegate(having, arena), ] .into_iter() .flatten(); - arena.intersperse(clauses, arena.softline()).group() + let mut result = arena.nil(); + let separator = arena.line(); + if let Some(first) = clauses.next() { + let mut curr = first; + + for clause in clauses { + result = result.append(curr.append(separator.clone()).group()); + curr = clause; + } + + result = result.append(curr); + } + + result } } @@ -282,9 +299,9 @@ impl PrettyDoc for ProjectionKind { } ProjectionKind::ProjectPivot(ProjectPivot { key, value }) => { let parts = [ - key.pretty_doc(arena), - arena.text("AT"), value.pretty_doc(arena), + arena.text("AT"), + key.pretty_doc(arena), ]; let decl = arena.intersperse(parts, arena.space()).group(); pretty_annotated_doc("PIVOT", decl, arena) @@ -401,6 +418,7 @@ impl PrettyDoc for Expr { unreachable!(); } } + .group() } } @@ -570,10 +588,13 @@ impl PrettyDoc for BinOp { let op = arena.text(sym); let lhs = lhs.pretty_doc(arena).nest(nest); let rhs = rhs.pretty_doc(arena).nest(nest); - let sep = arena.space(); + let sep = if nest == 0 { + arena.space() + } else { + arena.softline() + }; let expr = arena.intersperse([lhs, op, rhs], sep).group(); - let paren_expr = [arena.text("("), expr, arena.text(")")]; - arena.concat(paren_expr).group() + pretty_parenthesized_doc(expr, arena).group() } } @@ -698,30 +719,9 @@ impl PrettyDoc for SimpleCase { default, } = self; - let kw_case = arena.text("CASE"); let search = expr.pretty_doc(arena); - let branches = cases.iter().map(|ExprPair { first, second }| { - let kw_when = arena.text("WHEN"); - let test = first.pretty_doc(arena); - let kw_then = arena.text("THEN"); - let then = second.pretty_doc(arena); - arena - .intersperse([kw_when, test, kw_then, then], arena.space()) - .group() - }); - let branches = arena - .intersperse(branches, arena.softline()) - .group() - .nest(MINOR_NEST_INDENT); - let default = default - .as_ref() - .map(|d| arena.text("ELSE ").append(d.pretty_doc(arena))); - - if let Some(default) = default { - arena.intersperse([kw_case, search, branches, default], arena.softline()) - } else { - arena.intersperse([kw_case, search, branches], arena.softline()) - } + let branches = case_branches(arena, cases, default); + pretty_seq_doc(branches, "CASE", Some(search), "END", " ", arena) } } @@ -734,8 +734,24 @@ impl PrettyDoc for SearchedCase { { let SearchedCase { cases, default } = self; - let kw_case = arena.text("CASE"); - let branches = cases.iter().map(|ExprPair { first, second }| { + let branches = case_branches(arena, cases, default); + pretty_seq_doc(branches, "CASE", None, "END", " ", arena) + } +} + +fn case_branches<'b, D, A>( + arena: &'b D, + cases: &'b [ExprPair], + default: &'b Option>, +) -> impl Iterator> +where + D: DocAllocator<'b, A>, + D::Doc: Clone, + A: Clone + 'b, +{ + cases + .iter() + .map(|ExprPair { first, second }| { let kw_when = arena.text("WHEN"); let test = first.pretty_doc(arena); let kw_then = arena.text("THEN"); @@ -743,21 +759,12 @@ impl PrettyDoc for SearchedCase { arena .intersperse([kw_when, test, kw_then, then], arena.space()) .group() - }); - let branches = arena - .intersperse(branches, arena.softline()) - .group() - .nest(MINOR_NEST_INDENT); - let default = default - .as_ref() - .map(|d| arena.text("ELSE ").append(d.pretty_doc(arena))); - - if let Some(default) = default { - arena.intersperse([kw_case, branches, default], arena.softline()) - } else { - arena.intersperse([kw_case, branches], arena.softline()) - } - } + }) + .chain( + default + .iter() + .map(|d| arena.text("ELSE ").append(d.pretty_doc(arena)).group()), + ) } impl PrettyDoc for Struct { @@ -1258,25 +1265,20 @@ where D::Doc: Clone, A: Clone, { - arena - .text("(") - .append(arena.space()) - .append(doc) - .append(arena.space()) - .append(arena.text(")")) - .group() + arena.text("(").append(doc).append(arena.text(")")).group() } -fn pretty_seq<'i, 'b, I, P, D, A>( - list: I, +fn pretty_seq_doc<'i, 'b, I, E, D, A>( + seq: I, start: &'static str, + qualifier: Option, end: &'static str, sep: &'static str, arena: &'b D, ) -> DocBuilder<'b, D, A> where - I: IntoIterator, - P: PrettyDoc + 'b, + E: Pretty<'b, D, A>, + I: IntoIterator, D: DocAllocator<'b, A>, D::Doc: Clone, A: Clone, @@ -1284,15 +1286,40 @@ where let start = arena.text(start); let end = arena.text(end); let sep = arena.text(sep).append(arena.line()); - let seq = list.into_iter().map(|l| l.pretty_doc(arena)); - let body = arena.line().append(arena.intersperse(seq, sep)).group(); + let start = if let Some(qual) = qualifier { + start.append(arena.space()).append(qual) + } else { + start + }; + let body = arena + .line() + .append(arena.intersperse(seq, sep)) + .append(arena.line()) + .group(); start .append(body.nest(MINOR_NEST_INDENT)) - .append(arena.line()) .append(end) .group() } +fn pretty_seq<'i, 'b, I, P, D, A>( + list: I, + start: &'static str, + end: &'static str, + sep: &'static str, + arena: &'b D, +) -> DocBuilder<'b, D, A> +where + I: IntoIterator, + P: PrettyDoc + 'b, + D: DocAllocator<'b, A>, + D::Doc: Clone, + A: Clone, +{ + let seq = list.into_iter().map(|l| l.pretty_doc(arena)); + pretty_seq_doc(seq, start, None, end, sep, arena) +} + fn pretty_list<'b, I, P, D, A>(list: I, nest: isize, arena: &'b D) -> DocBuilder<'b, D, A> where I: IntoIterator, diff --git a/partiql/tests/pretty.rs b/partiql/tests/pretty.rs index ab3fddbb..cbdc045f 100644 --- a/partiql/tests/pretty.rs +++ b/partiql/tests/pretty.rs @@ -1,4 +1,5 @@ use itertools::Itertools; +use partiql_ast::ast::{AstNode, TopLevelQuery}; use partiql_ast::pretty::ToPretty; use partiql_parser::ParserResult; @@ -15,13 +16,18 @@ fn pretty_print_test(name: &str, statement: &str) { assert!(res.is_ok()); let res = res.unwrap(); - // TODO https://github.com/partiql/partiql-lang-rust/issues/473 + pretty_print_output_test(name, statement, &res.ast); + pretty_print_roundtrip_test(&res.ast); +} +#[track_caller] +fn pretty_print_output_test(name: &str, statement: &str, statement_ast: &AstNode) { + // TODO https://github.com/partiql/partiql-lang-rust/issues/473 let doc = [180, 120, 80, 40, 30, 20, 10] .into_iter() .map(|w| { let header = format!("{:-) { + let pretty = statement_ast.to_pretty_string(40).unwrap(); + + let reparsed = parse(pretty.as_str()); + assert!(reparsed.is_ok()); + + let pretty2 = reparsed.unwrap().ast.to_pretty_string(40).unwrap(); + + assert_eq!(pretty, pretty2); +} + #[test] fn pretty() { pretty_print_test( @@ -169,6 +187,18 @@ fn pretty_pivot() { ); } +#[test] +fn pretty_ands_and_ors() { + pretty_print_test( + "pretty_ands_and_ors", + " + SELECT * + FROM test_data AS test_data + WHERE ((((test_data.country_code <> 'Distinctio.') AND ((test_data.* < false) AND (NOT (test_data.description LIKE 'Esse solam.') AND NOT (test_data.transaction_id LIKE 'Esset accusata.')))) OR (test_data.test_address <> 'Potest. Sed.')) AND (test_data.* > -28.146858383543243)) + ", + ); +} + #[test] fn pretty_exclude() { pretty_print_test( diff --git a/partiql/tests/snapshots/pretty__pretty.snap b/partiql/tests/snapshots/pretty__pretty.snap index 20a40166..d8f729d5 100644 --- a/partiql/tests/snapshots/pretty__pretty.snap +++ b/partiql/tests/snapshots/pretty__pretty.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -24,7 +24,8 @@ SELECT foo, bar, baz, thud.*, grunt.a[*].b[2].*, count(1) AS n FROM << { 'foo': 'baz' }, { 'foo': 'bar' }, { 'foo': 'baz' } - >> GROUP BY foo ORDER BY n DESC + >> +GROUP BY foo ORDER BY n DESC ------------------------------------------------------------------------------------------------------------------------ SELECT foo, bar, baz, thud.*, grunt.a[*].b[2].*, count(1) AS n FROM << @@ -35,7 +36,8 @@ SELECT foo, bar, baz, thud.*, grunt.a[*].b[2].*, count(1) AS n FROM << { 'foo': 'baz' }, { 'foo': 'bar' }, { 'foo': 'baz' } - >> GROUP BY foo ORDER BY n DESC + >> +GROUP BY foo ORDER BY n DESC -------------------------------------------------------------------------------- SELECT foo, bar, baz, thud.*, grunt.a[*].b[2].*, count(1) AS n FROM << @@ -46,7 +48,8 @@ SELECT foo, bar, baz, thud.*, grunt.a[*].b[2].*, count(1) AS n FROM << { 'foo': 'baz' }, { 'foo': 'bar' }, { 'foo': 'baz' } - >> GROUP BY foo ORDER BY n DESC + >> +GROUP BY foo ORDER BY n DESC ---------------------------------------- SELECT foo, bar, baz, thud.*, @@ -64,12 +67,14 @@ FROM << { 'foo': 'baz' }, { 'foo': 'bar' }, { 'foo': 'baz' } - >> GROUP BY foo ORDER BY n DESC + >> +GROUP BY foo ORDER BY n DESC ------------------------------ SELECT foo, bar, baz, thud.*, grunt.a[*].b[2].*, - count(1) AS n FROM << + count(1) AS n +FROM << { 'foo': 'foo', 'x': 9, @@ -82,8 +87,8 @@ SELECT foo, bar, baz, thud.*, { 'foo': 'baz' }, { 'foo': 'bar' }, { 'foo': 'baz' } - >> GROUP BY foo -ORDER BY n DESC + >> +GROUP BY foo ORDER BY n DESC -------------------- SELECT foo, bar, @@ -97,18 +102,24 @@ FROM << 'y': 5, z: -11 }, - { 'foo': 'bar' + { + 'foo': 'bar' }, - { 'foo': 'qux' + { + 'foo': 'qux' }, - { 'foo': 'bar' + { + 'foo': 'bar' }, - { 'foo': 'baz' + { + 'foo': 'baz' }, - { 'foo': 'bar' + { + 'foo': 'bar' }, { 'foo': 'baz' } - >> GROUP BY foo + >> +GROUP BY foo ORDER BY n DESC ---------- diff --git a/partiql/tests/snapshots/pretty__pretty2.snap b/partiql/tests/snapshots/pretty__pretty2.snap index ef85961e..c5c97d41 100644 --- a/partiql/tests/snapshots/pretty__pretty2.snap +++ b/partiql/tests/snapshots/pretty__pretty2.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -15,26 +15,33 @@ SELECT foo, bar, baz, thud, grunt, count(1) AS n FROM (SELECT * FROM table1) WHE ORDER BY n DESC ------------------------------------------------------------------------------------------------------------------------ -SELECT foo, bar, baz, thud, grunt, count(1) AS n FROM (SELECT * FROM table1) -WHERE ((bar BETWEEN 3 AND 25 AND NOT (baz LIKE 'example%')) OR (foo.a.b[*] IS MISSING)) GROUP BY foo ORDER BY n DESC +SELECT foo, bar, baz, thud, grunt, count(1) AS n FROM (SELECT * FROM table1) WHERE ((bar BETWEEN 3 AND 25 AND + NOT (baz LIKE 'example%')) OR (foo.a.b[*] IS MISSING)) +GROUP BY foo ORDER BY n DESC -------------------------------------------------------------------------------- SELECT foo, bar, baz, thud, grunt, count(1) AS n FROM (SELECT * FROM table1) -WHERE ((bar BETWEEN 3 AND 25 AND NOT (baz LIKE 'example%')) OR (foo.a.b[*] IS MISSING)) +WHERE ((bar BETWEEN 3 AND 25 AND NOT (baz LIKE 'example%')) OR + (foo.a.b[*] IS MISSING)) GROUP BY foo ORDER BY n DESC ---------------------------------------- SELECT foo, bar, baz, thud, grunt, - count(1) AS n FROM (SELECT * - FROM table1) -WHERE ((bar BETWEEN 3 AND 25 AND NOT (baz LIKE 'example%')) OR (foo.a.b[*] IS MISSING)) + count(1) AS n +FROM (SELECT * FROM table1) +WHERE ((bar BETWEEN 3 AND 25 AND + NOT (baz LIKE 'example%')) OR + (foo.a.b[*] IS MISSING)) GROUP BY foo ORDER BY n DESC ------------------------------ SELECT foo, bar, baz, thud, grunt, count(1) AS n FROM (SELECT * FROM table1) -WHERE ((bar BETWEEN 3 AND 25 AND NOT (baz LIKE 'example%')) OR (foo.a.b[*] IS MISSING)) +WHERE ((bar BETWEEN 3 AND 25 + AND + NOT (baz LIKE 'example%')) + OR (foo.a.b[*] IS MISSING)) GROUP BY foo ORDER BY n DESC -------------------- @@ -43,7 +50,11 @@ SELECT foo, bar, count(1) AS n FROM (SELECT * FROM table1) -WHERE ((bar BETWEEN 3 AND 25 AND NOT (baz LIKE 'example%')) OR (foo.a.b[*] IS MISSING)) +WHERE ((bar BETWEEN 3 AND 25 + AND + NOT (baz LIKE 'example%')) + OR + (foo.a.b[*] IS MISSING)) GROUP BY foo ORDER BY n DESC @@ -56,7 +67,11 @@ SELECT foo, count(1) AS n FROM (SELECT * FROM table1) -WHERE ((bar BETWEEN 3 AND 25 AND NOT (baz LIKE 'example%')) OR (foo.a.b[*] IS MISSING)) +WHERE ((bar BETWEEN 3 AND 25 + AND + NOT (baz LIKE 'example%')) + OR + (foo.a.b[*] IS MISSING)) GROUP BY foo ORDER BY n DESC diff --git a/partiql/tests/snapshots/pretty__pretty_ands_and_ors.snap b/partiql/tests/snapshots/pretty__pretty_ands_and_ors.snap new file mode 100644 index 00000000..2caa3265 --- /dev/null +++ b/partiql/tests/snapshots/pretty__pretty_ands_and_ors.snap @@ -0,0 +1,85 @@ +--- +source: partiql/tests/pretty.rs +expression: doc +--- +======================================================================================================================================================================================================== + + SELECT * + FROM test_data AS test_data + WHERE ((((test_data.country_code <> 'Distinctio.') AND ((test_data.* < false) AND (NOT (test_data.description LIKE 'Esse solam.') AND NOT (test_data.transaction_id LIKE 'Esset accusata.')))) OR (test_data.test_address <> 'Potest. Sed.')) AND (test_data.* > -28.146858383543243)) + +======================================================================================================================================================================================================== + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SELECT * FROM test_data AS test_data WHERE ((((test_data.country_code <> 'Distinctio.') AND ((test_data.* < false) AND (NOT (test_data.description LIKE 'Esse solam.') AND + NOT (test_data.transaction_id LIKE 'Esset accusata.')))) OR (test_data.test_address <> 'Potest. Sed.')) AND (test_data.* > -28.146858383543243)) + +------------------------------------------------------------------------------------------------------------------------ +SELECT * FROM test_data AS test_data WHERE ((((test_data.country_code <> 'Distinctio.') AND ((test_data.* < false) AND + (NOT (test_data.description LIKE 'Esse solam.') AND NOT (test_data.transaction_id LIKE 'Esset accusata.')))) OR + (test_data.test_address <> 'Potest. Sed.')) AND (test_data.* > -28.146858383543243)) + +-------------------------------------------------------------------------------- +SELECT * FROM test_data AS test_data +WHERE ((((test_data.country_code <> 'Distinctio.') AND ((test_data.* < false) + AND (NOT (test_data.description LIKE 'Esse solam.') AND + NOT (test_data.transaction_id LIKE 'Esset accusata.')))) OR + (test_data.test_address <> 'Potest. Sed.')) AND + (test_data.* > -28.146858383543243)) + +---------------------------------------- +SELECT * FROM test_data AS test_data +WHERE ((((test_data.country_code <> 'Distinctio.') + AND ((test_data.* < false) AND + (NOT (test_data.description LIKE 'Esse solam.') + AND + NOT (test_data.transaction_id LIKE 'Esset accusata.')))) + OR + (test_data.test_address <> 'Potest. Sed.')) + AND + (test_data.* > -28.146858383543243)) + +------------------------------ +SELECT * +FROM test_data AS test_data +WHERE ((((test_data.country_code <> 'Distinctio.') + AND + ((test_data.* < false) + AND + (NOT (test_data.description LIKE 'Esse solam.') + AND + NOT (test_data.transaction_id LIKE 'Esset accusata.')))) + OR + (test_data.test_address <> 'Potest. Sed.')) + AND + (test_data.* > -28.146858383543243)) + +-------------------- +SELECT * +FROM test_data AS test_data +WHERE ((((test_data.country_code <> 'Distinctio.') + AND + ((test_data.* < false) + AND + (NOT (test_data.description LIKE 'Esse solam.') + AND + NOT (test_data.transaction_id LIKE 'Esset accusata.')))) + OR + (test_data.test_address <> 'Potest. Sed.')) + AND + (test_data.* > -28.146858383543243)) + +---------- +SELECT * +FROM test_data AS test_data +WHERE ((((test_data.country_code <> 'Distinctio.') + AND + ((test_data.* < false) + AND + (NOT (test_data.description LIKE 'Esse solam.') + AND + NOT (test_data.transaction_id LIKE 'Esset accusata.')))) + OR + (test_data.test_address <> 'Potest. Sed.')) + AND + (test_data.* > -28.146858383543243)) diff --git a/partiql/tests/snapshots/pretty__pretty_bagop.snap b/partiql/tests/snapshots/pretty__pretty_bagop.snap index b1841f94..a2659fdb 100644 --- a/partiql/tests/snapshots/pretty__pretty_bagop.snap +++ b/partiql/tests/snapshots/pretty__pretty_bagop.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -15,90 +15,87 @@ expression: doc ======================================================================================================================================================================================================== ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -( ( SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1 ) +((SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1) UNION DISTINCT - ( SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2 ) ) + (SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2)) OUTER UNION ALL -( SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 OFFSET e3 ) ORDER BY c4 LIMIT d4 OFFSET e4 +(SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 OFFSET e3) ORDER BY c4 LIMIT d4 OFFSET e4 ------------------------------------------------------------------------------------------------------------------------ -( ( SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1 ) +((SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1) UNION DISTINCT - ( SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2 ) ) + (SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2)) OUTER UNION ALL -( SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 OFFSET e3 ) ORDER BY c4 LIMIT d4 OFFSET e4 +(SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 OFFSET e3) ORDER BY c4 LIMIT d4 OFFSET e4 -------------------------------------------------------------------------------- -( ( SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1 ) +((SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1) UNION DISTINCT - ( SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2 ) ) + (SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2)) OUTER UNION ALL -( SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 OFFSET e3 ) ORDER BY c4 LIMIT d4 +(SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 OFFSET e3) ORDER BY c4 LIMIT d4 OFFSET e4 ---------------------------------------- -( ( SELECT a1 FROM b1 ORDER BY c1 - LIMIT d1 OFFSET e1 ) +((SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 + OFFSET e1) UNION DISTINCT - ( SELECT a2 FROM b2 ORDER BY c2 - LIMIT d2 OFFSET e2 ) ) + (SELECT a2 FROM b2 ORDER BY c2 + LIMIT d2 OFFSET e2)) OUTER UNION ALL -( SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 - OFFSET e3 ) ORDER BY c4 LIMIT d4 +(SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 + OFFSET e3) ORDER BY c4 LIMIT d4 OFFSET e4 ------------------------------ -( ( SELECT a1 FROM b1 +((SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 - OFFSET e1 ) + OFFSET e1) UNION DISTINCT - ( SELECT a2 FROM b2 + (SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 - OFFSET e2 ) ) + OFFSET e2)) OUTER UNION ALL -( SELECT a3 FROM b3 - ORDER BY c3 LIMIT d3 - OFFSET e3 ) ORDER BY c4 -LIMIT d4 OFFSET e4 +(SELECT a3 FROM b3 ORDER BY c3 + LIMIT d3 OFFSET e3) +ORDER BY c4 LIMIT d4 OFFSET e4 -------------------- -( ( SELECT a1 - FROM b1 +((SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 - OFFSET e1 ) + OFFSET e1) UNION DISTINCT - ( SELECT a2 - FROM b2 + (SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 - OFFSET e2 ) ) + OFFSET e2)) OUTER UNION ALL -( SELECT a3 FROM b3 +(SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 - OFFSET e3 ) + OFFSET e3) ORDER BY c4 LIMIT d4 OFFSET e4 ---------- -( ( SELECT a1 +((SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 - OFFSET e1 ) + OFFSET e1) UNION DISTINCT - ( SELECT a2 + (SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 - OFFSET e2 ) ) + OFFSET e2)) OUTER UNION ALL -( SELECT a3 +(SELECT a3 FROM b3 ORDER BY c3 LIMIT d3 - OFFSET e3 ) + OFFSET e3) ORDER BY c4 LIMIT d4 OFFSET e4 diff --git a/partiql/tests/snapshots/pretty__pretty_case_1.snap b/partiql/tests/snapshots/pretty__pretty_case_1.snap index 5aa8e7b3..384dd7f8 100644 --- a/partiql/tests/snapshots/pretty__pretty_case_1.snap +++ b/partiql/tests/snapshots/pretty__pretty_case_1.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -7,7 +7,7 @@ SELECT VALUE CASE WHEN x + 1 < i THEN '< ONE' WHEN x + 1 = f THEN 'TWO' WHEN (x ======================================================================================================================================================================================================== ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -SELECT VALUE CASE WHEN ((x + 1) < i) THEN '< ONE' WHEN ((x + 1) = f) THEN 'TWO' WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' ELSE '?' FROM << +SELECT VALUE CASE WHEN ((x + 1) < i) THEN '< ONE' WHEN ((x + 1) = f) THEN 'TWO' WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' ELSE '?' END FROM << -1.0000, i, f, @@ -18,21 +18,32 @@ SELECT VALUE CASE WHEN ((x + 1) < i) THEN '< ONE' WHEN ((x + 1) = f) THEN 'TWO' >> AS x ------------------------------------------------------------------------------------------------------------------------ -SELECT VALUE CASE WHEN ((x + 1) < i) THEN '< ONE' WHEN ((x + 1) = f) THEN 'TWO' - WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' ELSE '?' FROM << -1.0000, i, f, d, 100, NULL, MISSING - >> AS x +SELECT VALUE CASE + WHEN ((x + 1) < i) THEN '< ONE' + WHEN ((x + 1) = f) THEN 'TWO' + WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' + ELSE '?' + END +FROM << -1.0000, i, f, d, 100, NULL, MISSING >> AS x -------------------------------------------------------------------------------- -SELECT VALUE CASE WHEN ((x + 1) < i) THEN '< ONE' WHEN ((x + 1) = f) THEN 'TWO' - WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' ELSE '?' +SELECT VALUE CASE + WHEN ((x + 1) < i) THEN '< ONE' + WHEN ((x + 1) = f) THEN 'TWO' + WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' + ELSE '?' + END FROM << -1.0000, i, f, d, 100, NULL, MISSING >> AS x ---------------------------------------- SELECT VALUE CASE - WHEN ((x + 1) < i) THEN '< ONE' - WHEN ((x + 1) = f) THEN 'TWO' - WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' - ELSE '?' FROM << + WHEN ((x + 1) < i) THEN '< ONE' + WHEN ((x + 1) = f) THEN 'TWO' + WHEN (((x + 1) > d) AND + ((x + 1) < 100)) THEN '>= THREE < 100' + ELSE '?' + END +FROM << -1.0000, i, f, @@ -44,10 +55,13 @@ SELECT VALUE CASE ------------------------------ SELECT VALUE CASE - WHEN ((x + 1) < i) THEN '< ONE' - WHEN ((x + 1) = f) THEN 'TWO' - WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' - ELSE '?' FROM << + WHEN ((x + 1) < i) THEN '< ONE' + WHEN ((x + 1) = f) THEN 'TWO' + WHEN (((x + 1) > d) AND + ((x + 1) < 100)) THEN '>= THREE < 100' + ELSE '?' + END +FROM << -1.0000, i, f, @@ -59,10 +73,14 @@ SELECT VALUE CASE -------------------- SELECT VALUE CASE - WHEN ((x + 1) < i) THEN '< ONE' - WHEN ((x + 1) = f) THEN 'TWO' - WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' - ELSE '?' FROM << + WHEN ((x + 1) < i) THEN '< ONE' + WHEN ((x + 1) = f) THEN 'TWO' + WHEN (((x + 1) > d) + AND + ((x + 1) < 100)) THEN '>= THREE < 100' + ELSE '?' + END +FROM << -1.0000, i, f, @@ -74,10 +92,13 @@ SELECT VALUE CASE ---------- SELECT VALUE CASE - WHEN ((x + 1) < i) THEN '< ONE' - WHEN ((x + 1) = f) THEN 'TWO' - WHEN (((x + 1) > d) AND ((x + 1) < 100)) THEN '>= THREE < 100' - ELSE '?' + WHEN ((x + 1) < i) THEN '< ONE' + WHEN ((x + 1) = f) THEN 'TWO' + WHEN (((x + 1) > d) + AND + ((x + 1) < 100)) THEN '>= THREE < 100' + ELSE '?' + END FROM << -1.0000, i, diff --git a/partiql/tests/snapshots/pretty__pretty_case_2.snap b/partiql/tests/snapshots/pretty__pretty_case_2.snap index ed115ee4..93585213 100644 --- a/partiql/tests/snapshots/pretty__pretty_case_2.snap +++ b/partiql/tests/snapshots/pretty__pretty_case_2.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -7,7 +7,7 @@ SELECT VALUE CASE x + 1 WHEN NULL THEN 'shouldnt be null' WHEN MISSING THEN 'sho ======================================================================================================================================================================================================== ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -SELECT VALUE CASE (x + 1) WHEN NULL THEN 'shouldnt be null' WHEN MISSING THEN 'shouldnt be missing' WHEN i THEN 'ONE' WHEN f THEN 'TWO' WHEN d THEN 'THREE' FROM << +SELECT VALUE CASE (x + 1) WHEN NULL THEN 'shouldnt be null' WHEN MISSING THEN 'shouldnt be missing' WHEN i THEN 'ONE' WHEN f THEN 'TWO' WHEN d THEN 'THREE' END FROM << i, f, d, @@ -16,20 +16,44 @@ SELECT VALUE CASE (x + 1) WHEN NULL THEN 'shouldnt be null' WHEN MISSING THEN 's >> AS x ------------------------------------------------------------------------------------------------------------------------ -SELECT VALUE CASE (x + 1) WHEN NULL THEN 'shouldnt be null' WHEN MISSING THEN 'shouldnt be missing' WHEN i THEN 'ONE' - WHEN f THEN 'TWO' WHEN d THEN 'THREE' FROM << i, f, d, NULL, MISSING >> AS x +SELECT VALUE CASE (x + 1) + WHEN NULL THEN 'shouldnt be null' + WHEN MISSING THEN 'shouldnt be missing' + WHEN i THEN 'ONE' + WHEN f THEN 'TWO' + WHEN d THEN 'THREE' + END +FROM << i, f, d, NULL, MISSING >> AS x -------------------------------------------------------------------------------- -SELECT VALUE CASE (x + 1) WHEN NULL THEN 'shouldnt be null' - WHEN MISSING THEN 'shouldnt be missing' WHEN i THEN 'ONE' WHEN f THEN 'TWO' - WHEN d THEN 'THREE' FROM << i, f, d, NULL, MISSING >> AS x +SELECT VALUE CASE (x + 1) + WHEN NULL THEN 'shouldnt be null' + WHEN MISSING THEN 'shouldnt be missing' + WHEN i THEN 'ONE' + WHEN f THEN 'TWO' + WHEN d THEN 'THREE' + END +FROM << i, f, d, NULL, MISSING >> AS x ---------------------------------------- SELECT VALUE CASE (x + 1) - WHEN NULL THEN 'shouldnt be null' - WHEN MISSING THEN 'shouldnt be missing' - WHEN i THEN 'ONE' WHEN f THEN 'TWO' - WHEN d THEN 'THREE' FROM << + WHEN NULL THEN 'shouldnt be null' + WHEN MISSING THEN 'shouldnt be missing' + WHEN i THEN 'ONE' + WHEN f THEN 'TWO' + WHEN d THEN 'THREE' + END +FROM << i, f, d, NULL, MISSING >> AS x + +------------------------------ +SELECT VALUE CASE (x + 1) + WHEN NULL THEN 'shouldnt be null' + WHEN MISSING THEN 'shouldnt be missing' + WHEN i THEN 'ONE' + WHEN f THEN 'TWO' + WHEN d THEN 'THREE' + END +FROM << i, f, d, @@ -37,24 +61,14 @@ SELECT VALUE CASE (x + 1) MISSING >> AS x ------------------------------- -SELECT VALUE CASE (x + 1) - WHEN NULL THEN 'shouldnt be null' - WHEN MISSING THEN 'shouldnt be missing' - WHEN i THEN 'ONE' - WHEN f THEN 'TWO' - WHEN d THEN 'THREE' -FROM << i, f, d, NULL, MISSING - >> AS x - -------------------- -SELECT VALUE CASE - (x + 1) - WHEN NULL THEN 'shouldnt be null' - WHEN MISSING THEN 'shouldnt be missing' - WHEN i THEN 'ONE' - WHEN f THEN 'TWO' +SELECT VALUE CASE (x + 1) + WHEN NULL THEN 'shouldnt be null' + WHEN MISSING THEN 'shouldnt be missing' + WHEN i THEN 'ONE' + WHEN f THEN 'TWO' WHEN d THEN 'THREE' + END FROM << i, f, @@ -64,13 +78,13 @@ FROM << >> AS x ---------- -SELECT VALUE CASE - (x + 1) - WHEN NULL THEN 'shouldnt be null' - WHEN MISSING THEN 'shouldnt be missing' - WHEN i THEN 'ONE' - WHEN f THEN 'TWO' +SELECT VALUE CASE (x + 1) + WHEN NULL THEN 'shouldnt be null' + WHEN MISSING THEN 'shouldnt be missing' + WHEN i THEN 'ONE' + WHEN f THEN 'TWO' WHEN d THEN 'THREE' + END FROM << i, f, diff --git a/partiql/tests/snapshots/pretty__pretty_exclude_1.snap b/partiql/tests/snapshots/pretty__pretty_exclude_1.snap index 561fda27..f34b4e27 100644 --- a/partiql/tests/snapshots/pretty__pretty_exclude_1.snap +++ b/partiql/tests/snapshots/pretty__pretty_exclude_1.snap @@ -18,7 +18,8 @@ expression: doc ======================================================================================================================================================================================================== ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -SELECT * EXCLUDE c.ssn, c.address.street FROM [ { 'name': 'Alan', 'custId': 1, 'address': { 'city': 'Seattle', 'zipcode': 98109, 'street': '123 Seaplane Dr.' }, 'ssn': 123456789 } +SELECT * EXCLUDE c.ssn, c.address.street FROM [ + { 'name': 'Alan', 'custId': 1, 'address': { 'city': 'Seattle', 'zipcode': 98109, 'street': '123 Seaplane Dr.' }, 'ssn': 123456789 } ] AS c ------------------------------------------------------------------------------------------------------------------------ @@ -62,7 +63,8 @@ FROM [ ------------------------------ SELECT * EXCLUDE c.ssn, - c.address.street FROM [ + c.address.street +FROM [ { 'name': 'Alan', 'custId': 1, diff --git a/partiql/tests/snapshots/pretty__pretty_exclude_2.snap b/partiql/tests/snapshots/pretty__pretty_exclude_2.snap index 22641bcc..c7aa78dd 100644 --- a/partiql/tests/snapshots/pretty__pretty_exclude_2.snap +++ b/partiql/tests/snapshots/pretty__pretty_exclude_2.snap @@ -44,7 +44,8 @@ SELECT * EXCLUDE t.a.b.c[0], t.a.b.c[1].field FROM [ ---------------------------------------- SELECT * EXCLUDE t.a.b.c[0], - t.a.b.c[1].field FROM [ + t.a.b.c[1].field +FROM [ { 'a': { 'b': { @@ -61,7 +62,8 @@ SELECT * EXCLUDE t.a.b.c[0], ------------------------------ SELECT * EXCLUDE t.a.b.c[0], - t.a.b.c[1].field FROM [ + t.a.b.c[1].field +FROM [ { 'a': { 'b': { diff --git a/partiql/tests/snapshots/pretty__pretty_exclude_3.snap b/partiql/tests/snapshots/pretty__pretty_exclude_3.snap index c0ff4c88..a2fbe9e8 100644 --- a/partiql/tests/snapshots/pretty__pretty_exclude_3.snap +++ b/partiql/tests/snapshots/pretty__pretty_exclude_3.snap @@ -69,11 +69,17 @@ FROM [ 'a': { 'b': { 'c': [ - { 'field_x': 0, 'field_y': 0 + { + 'field_x': 0, + 'field_y': 0 }, - { 'field_x': 1, 'field_y': 1 + { + 'field_x': 1, + 'field_y': 1 }, - { 'field_x': 2, 'field_y': 2 + { + 'field_x': 2, + 'field_y': 2 } ] } diff --git a/partiql/tests/snapshots/pretty__pretty_exclude_4.snap b/partiql/tests/snapshots/pretty__pretty_exclude_4.snap index 729de7f2..6f895cc6 100644 --- a/partiql/tests/snapshots/pretty__pretty_exclude_4.snap +++ b/partiql/tests/snapshots/pretty__pretty_exclude_4.snap @@ -32,7 +32,8 @@ expression: doc ======================================================================================================================================================================================================== ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -SELECT * EXCLUDE t.a.b.c[*].* FROM [ { 'a': { 'b': { 'c': [ { 'field_x': 0, 'field_y': 0 }, { 'field_x': 1, 'field_y': 1 }, { 'field_x': 2, 'field_y': 2 } ] } }, 'foo': 'bar' } +SELECT * EXCLUDE t.a.b.c[*].* FROM [ + { 'a': { 'b': { 'c': [ { 'field_x': 0, 'field_y': 0 }, { 'field_x': 1, 'field_y': 1 }, { 'field_x': 2, 'field_y': 2 } ] } }, 'foo': 'bar' } ] AS t ------------------------------------------------------------------------------------------------------------------------ @@ -67,11 +68,17 @@ SELECT * EXCLUDE t.a.b.c[*].* FROM [ 'a': { 'b': { 'c': [ - { 'field_x': 0, 'field_y': 0 + { + 'field_x': 0, + 'field_y': 0 }, - { 'field_x': 1, 'field_y': 1 + { + 'field_x': 1, + 'field_y': 1 }, - { 'field_x': 2, 'field_y': 2 + { + 'field_x': 2, + 'field_y': 2 } ] } diff --git a/partiql/tests/snapshots/pretty__pretty_expr_in.snap b/partiql/tests/snapshots/pretty__pretty_expr_in.snap index cb931e4f..51d10a09 100644 --- a/partiql/tests/snapshots/pretty__pretty_expr_in.snap +++ b/partiql/tests/snapshots/pretty__pretty_expr_in.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -31,9 +31,13 @@ expression: doc ] ---------- -[ a, b +[ + a, + b ] IN [ - [ 1, 2 + [ + 1, + 2 ], [ 3, 4 ] ] diff --git a/partiql/tests/snapshots/pretty__pretty_pivot.snap b/partiql/tests/snapshots/pretty__pretty_pivot.snap index 3588dde7..9320ca91 100644 --- a/partiql/tests/snapshots/pretty__pretty_pivot.snap +++ b/partiql/tests/snapshots/pretty__pretty_pivot.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -12,28 +12,28 @@ expression: doc ======================================================================================================================================================================================================== ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -PIVOT foo.b AT foo.a FROM << { 'a': 1, 'b': 'I' }, { 'a': 2, 'b': 'II' }, { 'a': 3, 'b': 'III' } >> AS foo ORDER BY a LIMIT 1 OFFSET 1 +PIVOT foo.a AT foo.b FROM << { 'a': 1, 'b': 'I' }, { 'a': 2, 'b': 'II' }, { 'a': 3, 'b': 'III' } >> AS foo ORDER BY a LIMIT 1 OFFSET 1 ------------------------------------------------------------------------------------------------------------------------ -PIVOT foo.b AT foo.a FROM << { 'a': 1, 'b': 'I' }, { 'a': 2, 'b': 'II' }, { 'a': 3, 'b': 'III' } >> AS foo ORDER BY a +PIVOT foo.a AT foo.b FROM << { 'a': 1, 'b': 'I' }, { 'a': 2, 'b': 'II' }, { 'a': 3, 'b': 'III' } >> AS foo ORDER BY a LIMIT 1 OFFSET 1 -------------------------------------------------------------------------------- -PIVOT foo.b AT foo.a FROM << +PIVOT foo.a AT foo.b FROM << { 'a': 1, 'b': 'I' }, { 'a': 2, 'b': 'II' }, { 'a': 3, 'b': 'III' } >> AS foo ORDER BY a LIMIT 1 OFFSET 1 ---------------------------------------- -PIVOT foo.b AT foo.a FROM << +PIVOT foo.a AT foo.b FROM << { 'a': 1, 'b': 'I' }, { 'a': 2, 'b': 'II' }, { 'a': 3, 'b': 'III' } >> AS foo ORDER BY a LIMIT 1 OFFSET 1 ------------------------------ -PIVOT foo.b AT foo.a FROM << +PIVOT foo.a AT foo.b FROM << { 'a': 1, 'b': 'I' }, { 'a': 2, 'b': 'II' }, { 'a': 3, 'b': 'III' } @@ -41,7 +41,7 @@ PIVOT foo.b AT foo.a FROM << OFFSET 1 -------------------- -PIVOT foo.b AT foo.a +PIVOT foo.a AT foo.b FROM << { 'a': 1, @@ -60,7 +60,7 @@ ORDER BY a LIMIT 1 OFFSET 1 ---------- -PIVOT foo.b AT foo.a +PIVOT foo.a AT foo.b FROM << { 'a': 1, diff --git a/partiql/tests/snapshots/pretty__pretty_select_value_tuple_ctor.snap b/partiql/tests/snapshots/pretty__pretty_select_value_tuple_ctor.snap index 3a00243a..cbcce367 100644 --- a/partiql/tests/snapshots/pretty__pretty_select_value_tuple_ctor.snap +++ b/partiql/tests/snapshots/pretty__pretty_select_value_tuple_ctor.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -29,7 +29,8 @@ FROM [ SELECT VALUE { 'a': v.a, 'b': v.b - } FROM [ + } +FROM [ { 'a': 1, 'b': 1 }, { 'a': 2, 'b': 2 } ] AS v @@ -38,10 +39,15 @@ SELECT VALUE { SELECT VALUE { 'a': v.a, 'b': v.b - } FROM [ - { 'a': 1, 'b': 1 + } +FROM [ + { + 'a': 1, + 'b': 1 }, - { 'a': 2, 'b': 2 + { + 'a': 2, + 'b': 2 } ] AS v @@ -49,7 +55,8 @@ SELECT VALUE { SELECT VALUE { 'a': v.a, 'b': v.b - } FROM [ + } +FROM [ { 'a': 1, 'b': 1 diff --git a/partiql/tests/snapshots/pretty__pretty_setop.snap b/partiql/tests/snapshots/pretty__pretty_setop.snap index 674006cc..9138a039 100644 --- a/partiql/tests/snapshots/pretty__pretty_setop.snap +++ b/partiql/tests/snapshots/pretty__pretty_setop.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -10,64 +10,62 @@ expression: doc ======================================================================================================================================================================================================== ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -( SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1 ) +(SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1) UNION -( SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2 ) ORDER BY c3 LIMIT d3 OFFSET e3 +(SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2) ORDER BY c3 LIMIT d3 OFFSET e3 ------------------------------------------------------------------------------------------------------------------------ -( SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1 ) +(SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1) UNION -( SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2 ) ORDER BY c3 LIMIT d3 OFFSET e3 +(SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2) ORDER BY c3 LIMIT d3 OFFSET e3 -------------------------------------------------------------------------------- -( SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1 ) +(SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 OFFSET e1) UNION -( SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2 ) ORDER BY c3 LIMIT d3 +(SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 OFFSET e2) ORDER BY c3 LIMIT d3 OFFSET e3 ---------------------------------------- -( SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 - OFFSET e1 ) +(SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 + OFFSET e1) UNION -( SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 - OFFSET e2 ) ORDER BY c3 LIMIT d3 +(SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 + OFFSET e2) ORDER BY c3 LIMIT d3 OFFSET e3 ------------------------------ -( SELECT a1 FROM b1 - ORDER BY c1 LIMIT d1 - OFFSET e1 ) +(SELECT a1 FROM b1 ORDER BY c1 + LIMIT d1 OFFSET e1) UNION -( SELECT a2 FROM b2 - ORDER BY c2 LIMIT d2 - OFFSET e2 ) ORDER BY c3 -LIMIT d3 OFFSET e3 +(SELECT a2 FROM b2 ORDER BY c2 + LIMIT d2 OFFSET e2) +ORDER BY c3 LIMIT d3 OFFSET e3 -------------------- -( SELECT a1 FROM b1 +(SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 - OFFSET e1 ) + OFFSET e1) UNION -( SELECT a2 FROM b2 +(SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 - OFFSET e2 ) + OFFSET e2) ORDER BY c3 LIMIT d3 OFFSET e3 ---------- -( SELECT a1 +(SELECT a1 FROM b1 ORDER BY c1 LIMIT d1 - OFFSET e1 ) + OFFSET e1) UNION -( SELECT a2 +(SELECT a2 FROM b2 ORDER BY c2 LIMIT d2 - OFFSET e2 ) + OFFSET e2) ORDER BY c3 LIMIT d3 OFFSET e3 diff --git a/partiql/tests/snapshots/pretty__pretty_typed_lits2.snap b/partiql/tests/snapshots/pretty__pretty_typed_lits2.snap index ba2f4302..4a7fb7d8 100644 --- a/partiql/tests/snapshots/pretty__pretty_typed_lits2.snap +++ b/partiql/tests/snapshots/pretty__pretty_typed_lits2.snap @@ -1,5 +1,5 @@ --- -source: partiql-ast/tests/pretty.rs +source: partiql/tests/pretty.rs expression: doc --- ======================================================================================================================================================================================================== @@ -7,22 +7,22 @@ TIME (3) WITH TIME ZONE '12:59:31' ======================================================================================================================================================================================================== ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -TIME( 3 ) WITH TIME ZONE '12:59:31' +TIME(3) WITH TIME ZONE '12:59:31' ------------------------------------------------------------------------------------------------------------------------ -TIME( 3 ) WITH TIME ZONE '12:59:31' +TIME(3) WITH TIME ZONE '12:59:31' -------------------------------------------------------------------------------- -TIME( 3 ) WITH TIME ZONE '12:59:31' +TIME(3) WITH TIME ZONE '12:59:31' ---------------------------------------- -TIME( 3 ) WITH TIME ZONE '12:59:31' +TIME(3) WITH TIME ZONE '12:59:31' ------------------------------ -TIME( 3 ) WITH TIME ZONE '12:59:31' +TIME(3) WITH TIME ZONE '12:59:31' -------------------- -TIME( 3 ) WITH TIME ZONE '12:59:31' +TIME(3) WITH TIME ZONE '12:59:31' ---------- -TIME( 3 ) WITH TIME ZONE '12:59:31' +TIME(3) WITH TIME ZONE '12:59:31'