From e487965c5a962cf0ec5df12b6ce826cd2e299cef Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Mon, 9 Jun 2025 20:59:18 -0400 Subject: [PATCH] parser: fix json_table, table, values, group by clause & more --- .gitignore | 1 + .../src/generated/syntax_kind.rs | 5 + crates/squawk_parser/src/grammar.rs | 220 +++--- .../tests/data/ok/select_funcs.sql | 4 + .../regression_suite/sqljson_jsontable.sql | 4 +- .../tests/data/regression_suite/update.sql | 58 +- .../tests/data/regression_suite/window.sql | 2 +- .../tests/snapshots/tests__delete_ok.snap | 5 +- .../tests/snapshots/tests__explain_ok.snap | 15 +- .../tests/snapshots/tests__misc_ok.snap | 118 ++-- .../tests__regression_groupingsets.snap | 17 +- .../snapshots/tests__regression_inherit.snap | 12 +- .../tests__regression_partition_prune.snap | 42 +- .../tests__regression_privileges.snap | 70 -- .../tests__regression_rangefuncs.snap | 282 +------- .../tests__regression_sqljson_jsontable.snap | 186 +---- .../tests__regression_subselect.snap | 45 +- .../tests__regression_suite_errors.snap | 15 +- .../snapshots/tests__regression_update.snap | 30 +- .../snapshots/tests__regression_window.snap | 73 +- .../snapshots/tests__regression_with.snap | 10 +- .../snapshots/tests__regression_xml.snap | 9 +- .../snapshots/tests__select_funcs_ok.snap | 56 ++ .../tests__select_funcs_pg17_ok.snap | 662 +++++++++--------- .../tests/snapshots/tests__select_ok.snap | 190 ++--- .../squawk_syntax/src/ast/generated/nodes.rs | 221 ++++++ crates/squawk_syntax/src/postgresql.ungram | 18 +- 27 files changed, 1029 insertions(+), 1341 deletions(-) diff --git a/.gitignore b/.gitignore index 316bdc4e..f1d95ef3 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ dist .DS_Store +temp.sql diff --git a/crates/squawk_parser/src/generated/syntax_kind.rs b/crates/squawk_parser/src/generated/syntax_kind.rs index a7ad1ee9..91d4e22c 100644 --- a/crates/squawk_parser/src/generated/syntax_kind.rs +++ b/crates/squawk_parser/src/generated/syntax_kind.rs @@ -765,6 +765,10 @@ pub enum SyntaxKind { FUNC_OPTION_LIST, GENERATED_CONSTRAINT, GRANT, + GROUPING_CUBE, + GROUPING_EXPR, + GROUPING_ROLLUP, + GROUPING_SETS, GROUP_BY_CLAUSE, GTEQ, HAVING_CLAUSE, @@ -804,6 +808,7 @@ pub enum SyntaxKind { JSON_PASSING_CLAUSE, JSON_QUOTES_CLAUSE, JSON_RETURNING_CLAUSE, + JSON_TABLE_COLUMN, JSON_VALUE_EXPR, JSON_WRAPPER_BEHAVIOR_CLAUSE, LANGUAGE_FUNC_OPTION, diff --git a/crates/squawk_parser/src/grammar.rs b/crates/squawk_parser/src/grammar.rs index 01525b08..60d4dd7f 100644 --- a/crates/squawk_parser/src/grammar.rs +++ b/crates/squawk_parser/src/grammar.rs @@ -584,20 +584,7 @@ fn json_table_arg_list(p: &mut Parser<'_>) { name(p); } // [ PASSING { value AS varname } [, ...] ] - if p.eat(PASSING_KW) { - while !p.at(EOF) { - // value - if expr(p).is_none() { - p.error("expected expression"); - } - opt_json_format_clause(p); - p.expect(AS_KW); - col_label(p); - if !p.eat(COMMA) { - break; - } - } - } + opt_json_passing_clause(p); // COLUMNS ( json_table_column [, ...] ) if p.eat(COLUMNS_KW) { p.expect(L_PAREN); @@ -609,12 +596,7 @@ fn json_table_arg_list(p: &mut Parser<'_>) { } p.expect(R_PAREN); } - // [ { ERROR | EMPTY [ARRAY]} ON ERROR ] - if p.eat(ERROR_KW) { - p.expect(ON_KW); - p.expect(ERROR_KW); - } else if p.eat(EMPTY_KW) { - p.eat(ARRAY_KW); + if opt_json_behavior(p) { p.expect(ON_KW); p.expect(ERROR_KW); } @@ -633,6 +615,7 @@ fn json_table_arg_list(p: &mut Parser<'_>) { // [ { ERROR | TRUE | FALSE | UNKNOWN } ON ERROR ] // | NESTED [ PATH ] path_expression [ AS json_path_name ] COLUMNS ( json_table_column [, ...] ) fn json_table_column(p: &mut Parser<'_>) { + let m = p.start(); // NESTED [ PATH ] path_expression [ AS json_path_name ] COLUMNS ( json_table_column [, ...] ) if p.eat(NESTED_KW) { p.eat(PATH_KW); @@ -669,60 +652,22 @@ fn json_table_column(p: &mut Parser<'_>) { p.error("expected expression"); } } - // [ { ERROR | TRUE | FALSE | UNKNOWN } ON ERROR ] - if p.at(ERROR_KW) || p.at(TRUE_KW) || p.at(FALSE_KW) || p.at(UNKNOWN_KW) { - p.expect(ON_KW); - p.expect(ERROR_KW); - } + opt_json_behavior_clause(p); } else { // [ FORMAT JSON [ENCODING UTF8]] opt_json_format_clause(p); // [ PATH path_expression ] if p.eat(PATH_KW) { // path_expression - if expr(p).is_none() { - p.error("expected expression"); - } - } - // [ { WITHOUT | WITH { CONDITIONAL | [UNCONDITIONAL] } } [ ARRAY ] WRAPPER ] - if p.at(WITHOUT_KW) || p.at(WITH_KW) { - if p.eat(WITH_KW) { - let _ = p.eat(CONDITIONAL_KW) || p.eat(UNCONDITIONAL_KW); - } else { - p.bump(WITHOUT_KW); - } - p.eat(ARRAY_KW); - p.expect(WRAPPER_KW); - } - // [ { KEEP | OMIT } QUOTES [ ON SCALAR STRING ] ] - if p.eat(KEEP_KW) || p.eat(OMIT_KW) { - p.expect(QUOTES_KW); - if p.eat(ON_KW) { - p.expect(SCALAR_KW); - p.expect(STRING_KW); - } - } - // [ { ERROR | NULL | EMPTY { [ARRAY] | OBJECT } | DEFAULT expression } ON EMPTY ] - // [ { ERROR | NULL | EMPTY { [ARRAY] | OBJECT } | DEFAULT expression } ON ERROR ] - if p.at(ERROR_KW) || p.at(NULL_KW) || p.at(EMPTY_KW) || p.at(DEFAULT_KW) { - // EMPTY { [ARRAY] | OBJECT } - if p.eat(EMPTY_KW) { - let _ = p.eat(ARRAY_KW) || p.expect(OBJECT_KW); - // DEFAULT - } else if p.eat(DEFAULT_KW) { - if expr(p).is_none() { - p.error("expected an expression"); - } - // ERROR | NULL - } else { - p.bump_any(); - } - p.expect(ON_KW); - let _ = p.eat(EMPTY_KW) || p.expect(ERROR_KW); + string_literal(p); } + opt_json_wrapper_behavior(p); + opt_json_quotes_clause(p); + opt_json_behavior_clause(p); } } } + m.complete(p, JSON_TABLE_COLUMN); } // json_array ( @@ -2508,11 +2453,9 @@ fn compound_select(p: &mut Parser<'_>, cm: CompletedMarker) -> CompletedMarker { fn select(p: &mut Parser, m: Option) -> Option { assert!(p.at_ts(SELECT_FIRST)); let m = m.unwrap_or_else(|| p.start()); - // table [only] name [*] - if p.eat(TABLE_KW) { - relation_name(p); - return Some(m.complete(p, TABLE)); - } + + let mut out_kind = SELECT; + // with aka cte // [ WITH [ RECURSIVE ] with_query [, ...] ] if p.at(WITH_KW) { @@ -2526,8 +2469,16 @@ fn select(p: &mut Parser, m: Option) -> Option { return Some(cm); } } - select_clause(p); - let is_select_into = opt_into_clause(p).is_some(); + // table [only] name [*] + if p.eat(TABLE_KW) { + relation_name(p); + out_kind = TABLE; + } else { + select_clause(p); + } + if opt_into_clause(p).is_some() { + out_kind = SELECT_INTO; + } opt_from_clause(p); opt_where_clause(p); opt_group_by_clause(p); @@ -2554,7 +2505,7 @@ fn select(p: &mut Parser, m: Option) -> Option { opt_locking_clause(p); } } - Some(m.complete(p, if is_select_into { SELECT_INTO } else { SELECT })) + Some(m.complete(p, out_kind)) } // INTO [ TEMPORARY | TEMP | UNLOGGED ] [ TABLE ] new_table @@ -2918,8 +2869,11 @@ fn data_source(p: &mut Parser<'_>) { p.expect(FROM_KW); p.expect(L_PAREN); call_expr(p); - // TODO: we should restrict this more opt_alias(p); + while !p.at(EOF) && p.eat(COMMA) { + call_expr(p); + opt_alias(p); + } p.expect(R_PAREN); // [ WITH ORDINALITY ] if p.eat(WITH_KW) { @@ -4153,6 +4107,12 @@ fn opt_group_by_clause(p: &mut Parser<'_>) -> Option { if p.at(ALL_KW) || p.at(DISTINCT_KW) { p.bump_any(); } + group_by_list(p); + + Some(m.complete(p, GROUP_BY_CLAUSE)) +} + +fn group_by_list(p: &mut Parser<'_>) { // From pg docs: // An expression used inside a grouping_element can be an input column name, // or the name or ordinal number of an output column (SELECT list item), or @@ -4160,20 +4120,46 @@ fn opt_group_by_clause(p: &mut Parser<'_>) -> Option { // ambiguity, a GROUP BY name will be interpreted as an input-column name // rather than an output column name. while !p.at(EOF) && !p.at(SEMICOLON) { - // TODO: handle errors? - p.eat(ROLLUP_KW); - p.eat(CUBE_KW); - if p.eat(GROUPING_KW) { - p.expect(SETS_KW); - } - if expr(p).is_none() { - p.error("expected an expression"); - } + let m = p.start(); + let kind = match p.current() { + ROLLUP_KW => { + p.bump_any(); + p.expect(L_PAREN); + if !expr_list(p) { + p.error("expected expression list"); + }; + p.expect(R_PAREN); + GROUPING_ROLLUP + } + CUBE_KW => { + p.bump_any(); + p.expect(L_PAREN); + if !expr_list(p) { + p.error("expected expression list"); + }; + p.expect(R_PAREN); + GROUPING_CUBE + } + GROUPING_KW if p.nth_at(1, SETS_KW) => { + p.bump(GROUPING_KW); + p.bump(SETS_KW); + p.expect(L_PAREN); + group_by_list(p); + p.expect(R_PAREN); + GROUPING_SETS + } + _ => { + if expr(p).is_none() { + p.error("expected an expression"); + } + GROUPING_EXPR + } + }; + m.complete(p, kind); if !p.eat(COMMA) { break; } } - Some(m.complete(p, GROUP_BY_CLAUSE)) } /// @@ -4196,22 +4182,20 @@ fn opt_having_clause(p: &mut Parser<'_>) -> Option { // offset PRECEDING // offset FOLLOWING fn frame_start_end(p: &mut Parser<'_>) { - if p.eat(UNBOUNDED_KW) { - if p.at(PRECEDING_KW) || p.at(FOLLOWING_KW) { + match (p.current(), p.nth(1)) { + (CURRENT_KW, ROW_KW) | (UNBOUNDED_KW, PRECEDING_KW | FOLLOWING_KW) => { p.bump_any(); - } else { - p.err_and_bump("expected preceding or following"); - } - } else if p.eat(CURRENT_KW) { - p.expect(ROW_KW); - } else { - if expr(p).is_none() { - p.error("expected an expression"); - } - if p.at(PRECEDING_KW) || p.at(FOLLOWING_KW) { p.bump_any(); - } else { - p.err_and_bump("expected preceding or following"); + } + _ => { + if expr(p).is_none() { + p.error("expected an expression"); + } + if p.at(PRECEDING_KW) || p.at(FOLLOWING_KW) { + p.bump_any(); + } else { + p.err_and_bump("expected preceding or following"); + } } } } @@ -4290,12 +4274,19 @@ fn opt_window_clause(p: &mut Parser<'_>) -> Option { } let m = p.start(); p.bump(WINDOW_KW); - p.expect(IDENT); + window_def(p); + while !p.at(EOF) && p.eat(COMMA) { + window_def(p); + } + Some(m.complete(p, WINDOW_CLAUSE)) +} + +fn window_def(p: &mut Parser<'_>) { + name(p); p.expect(AS_KW); p.expect(L_PAREN); window_definition(p); p.expect(R_PAREN); - Some(m.complete(p, WINDOW_CLAUSE)) } // [ LIMIT { count | ALL } ] @@ -4848,13 +4839,20 @@ fn create_table(p: &mut Parser<'_>) -> CompletedMarker { // AS query // [ WITH [ NO ] DATA ] if p.eat(AS_KW) { - // query - if p.at_ts(SELECT_FIRST) { - select(p, None); - } else if p.at(EXECUTE_KW) { - execute(p); - } else { - p.error("expected SELECT, TABLE, VALUES, or EXECUTE"); + match stmt( + p, + &StmtRestrictions { + begin_end_allowed: false, + }, + ) + .map(|x| x.kind()) + { + Some( + SELECT | COMPOUND_SELECT | SELECT_INTO | PAREN_SELECT | TABLE | VALUES | EXECUTE, + ) => (), + _ => { + p.error("expected SELECT, TABLE, VALUES, or EXECUTE"); + } } if p.eat(WITH_KW) { p.eat(NO_KW); @@ -5272,7 +5270,7 @@ fn stmt(p: &mut Parser, r: &StmtRestrictions) -> Option { (GRANT_KW, _) => Some(grant(p)), (IMPORT_KW, FOREIGN_KW) => Some(import_foreign_schema(p)), (INSERT_KW, _) => Some(insert(p, None)), - (L_PAREN, L_PAREN | SELECT_KW) => { + (L_PAREN, _) if p.nth_at_ts(1, SELECT_FIRST) || p.at(L_PAREN) => { // can have select nested in parens, i.e., ((select 1)); let cm = paren_select(p)?; let cm = if p.at_ts(COMPOUND_SELECT_FIRST) { @@ -6913,11 +6911,15 @@ fn alter_default_privileges(p: &mut Parser<'_>) -> CompletedMarker { fn privilege_target_type(p: &mut Parser<'_>) { match p.current() { + LARGE_KW => { + p.bump(LARGE_KW); + p.expect(OBJECTS_KW); + } TABLES_KW | FUNCTIONS_KW | ROUTINES_KW | SEQUENCES_KW | TYPES_KW | SCHEMAS_KW => { p.bump_any(); } _ => p.error( - "expected privilege target, TABLES, FUNCTIONS, ROUTINES, SEQEUNCES, TYPES, SCHEMAS", + "expected privilege target, TABLES, FUNCTIONS, ROUTINES, SEQEUNCES, TYPES, SCHEMAS, LARGE OBJECTS", ), } } @@ -10387,7 +10389,7 @@ fn grant_role_option_list(p: &mut Parser<'_>) { p.error("expected OPTION, TRUE, or FALSE") } if !p.eat(COMMA) { - if p.at_ts(COL_LABEL_FIRST) { + if p.at_ts(COL_LABEL_FIRST) && !p.at(GRANTED_KW) { p.error("missing comma"); } else { break; diff --git a/crates/squawk_parser/tests/data/ok/select_funcs.sql b/crates/squawk_parser/tests/data/ok/select_funcs.sql index 6ed0cb3a..b2c74146 100644 --- a/crates/squawk_parser/tests/data/ok/select_funcs.sql +++ b/crates/squawk_parser/tests/data/ok/select_funcs.sql @@ -249,3 +249,7 @@ select max(a) over (partition by b) as c from t; -- window name select max(a) over w_name from t; + +-- window clause +select * from t window owner as (order by a), w2 as (order by b); +-- ^^^^^ make sure we allow using keywords diff --git a/crates/squawk_parser/tests/data/regression_suite/sqljson_jsontable.sql b/crates/squawk_parser/tests/data/regression_suite/sqljson_jsontable.sql index 80d7f34c..d461fee5 100644 --- a/crates/squawk_parser/tests/data/regression_suite/sqljson_jsontable.sql +++ b/crates/squawk_parser/tests/data/regression_suite/sqljson_jsontable.sql @@ -13,9 +13,9 @@ SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') ERROR ON SELECT * FROM JSON_TABLE(jsonb'"1.23"', '$.a' as js2 COLUMNS (js2 int path '$')); -- Should fail (no columns) -SELECT * FROM JSON_TABLE(NULL, '$' COLUMNS ()); +-- SELECT * FROM JSON_TABLE(NULL, '$' COLUMNS ()); -SELECT * FROM JSON_TABLE (NULL::jsonb, '$' COLUMNS (v1 timestamp)) AS f (v1, v2); +-- SELECT * FROM JSON_TABLE (NULL::jsonb, '$' COLUMNS (v1 timestamp)) AS f (v1, v2); --duplicated column name SELECT * FROM JSON_TABLE(jsonb'"1.23"', '$.a' COLUMNS (js2 int path '$', js2 int path '$')); diff --git a/crates/squawk_parser/tests/data/regression_suite/update.sql b/crates/squawk_parser/tests/data/regression_suite/update.sql index 8ab5f60a..2f1cba7b 100644 --- a/crates/squawk_parser/tests/data/regression_suite/update.sql +++ b/crates/squawk_parser/tests/data/regression_suite/update.sql @@ -207,8 +207,8 @@ ALTER TABLE part_b_10_b_20 ATTACH PARTITION part_c_100_200 FOR VALUES FROM (100) CREATE TABLE part_c_1_100 (e varchar, d int, c numeric, b bigint, a text); ALTER TABLE part_b_10_b_20 ATTACH PARTITION part_c_1_100 FOR VALUES FROM (1) TO (100); -'init_range_parted'; -'show_data'; +-- 'init_range_parted'; +-- 'show_data'; -- The order of subplans should be in bound order EXPLAIN (costs off) UPDATE range_parted set c = c - 50 WHERE c > 97; @@ -226,14 +226,14 @@ UPDATE range_parted set e = d; UPDATE part_c_1_100 set c = c + 20 WHERE c = 98; -- ok, row movement UPDATE part_b_10_b_20 set c = c + 20 returning c, b, a; -'show_data'; +-- 'show_data'; -- fail, row movement happens only within the partition subtree. UPDATE part_b_10_b_20 set b = b - 6 WHERE c > 116 returning *; -- ok, row movement, with subset of rows moved into different partition. UPDATE range_parted set b = b - 6 WHERE c > 116 returning a, b + c; -'show_data'; +-- 'show_data'; -- Common table needed for multiple test scenarios. CREATE TABLE mintab(c1 int); @@ -250,19 +250,19 @@ UPDATE upview set a = 'b', b = 15, c = 120 WHERE b = 4; -- ok, row movement, check option passes UPDATE upview set a = 'b', b = 15 WHERE b = 4; -'show_data'; +-- 'show_data'; -- cleanup DROP VIEW upview; -- RETURNING having whole-row vars. -'init_range_parted'; +-- 'init_range_parted'; UPDATE range_parted set c = 95 WHERE a = 'b' and b > 10 and c > 100 returning (range_parted), *; -'show_data'; +-- 'show_data'; -- Transition tables with update row movement -'init_range_parted'; +-- 'init_range_parted'; CREATE FUNCTION trans_updatetrigfunc() RETURNS trigger LANGUAGE plpgsql AS $$ @@ -280,8 +280,8 @@ CREATE TRIGGER trans_updatetrig FOR EACH STATEMENT EXECUTE PROCEDURE trans_updatetrigfunc(); UPDATE range_parted set c = (case when c = 96 then 110 else c + 1 end ) WHERE a = 'b' and b > 10 and c >= 96; -'show_data'; -'init_range_parted'; +-- 'show_data'; +-- 'init_range_parted'; -- Enabling OLD TABLE capture for both DELETE as well as UPDATE stmt triggers -- should not cause DELETEd rows to be captured twice. Similar thing for @@ -293,7 +293,7 @@ CREATE TRIGGER trans_inserttrig AFTER INSERT ON range_parted REFERENCING NEW TABLE AS new_table FOR EACH STATEMENT EXECUTE PROCEDURE trans_updatetrigfunc(); UPDATE range_parted set c = c + 50 WHERE a = 'b' and b > 10 and c >= 96; -'show_data'; +-- 'show_data'; DROP TRIGGER trans_deletetrig ON range_parted; DROP TRIGGER trans_inserttrig ON range_parted; -- Don't drop trans_updatetrig yet. It is required below. @@ -316,19 +316,19 @@ CREATE TRIGGER trig_d1_15 BEFORE UPDATE OR INSERT ON part_d_1_15 FOR EACH ROW EXECUTE PROCEDURE func_parted_mod_b(); CREATE TRIGGER trig_d15_20 BEFORE UPDATE OR INSERT ON part_d_15_20 FOR EACH ROW EXECUTE PROCEDURE func_parted_mod_b(); -'init_range_parted'; +-- 'init_range_parted'; UPDATE range_parted set c = (case when c = 96 then 110 else c + 1 end) WHERE a = 'b' and b > 10 and c >= 96; -'show_data'; -'init_range_parted'; +-- 'show_data'; +-- 'init_range_parted'; UPDATE range_parted set c = c + 50 WHERE a = 'b' and b > 10 and c >= 96; -'show_data'; +-- 'show_data'; -- Case where per-partition tuple conversion map array is allocated, but the -- map is not required for the particular tuple that is routed, thanks to -- matching table attributes of the partition and the target table. -'init_range_parted'; +-- 'init_range_parted'; UPDATE range_parted set b = 15 WHERE b = 1; -'show_data'; +-- 'show_data'; DROP TRIGGER trans_updatetrig ON range_parted; DROP TRIGGER trig_c1_100 ON part_c_1_100; @@ -345,7 +345,7 @@ GRANT ALL ON range_parted, mintab TO regress_range_parted_user; CREATE POLICY seeall ON range_parted AS PERMISSIVE FOR SELECT USING (true); CREATE POLICY policy_range_parted ON range_parted for UPDATE USING (true) WITH CHECK (c % 2 = 0); -'init_range_parted'; +-- 'init_range_parted'; SET SESSION AUTHORIZATION regress_range_parted_user; -- This should fail with RLS violation error while moving row from -- part_a_10_a_20 to part_d_1_15, because we are setting 'c' to an odd number. @@ -361,7 +361,7 @@ END $$ LANGUAGE plpgsql; CREATE TRIGGER trig_d_1_15 BEFORE INSERT ON part_d_1_15 FOR EACH ROW EXECUTE PROCEDURE func_d_1_15(); -'init_range_parted'; +-- 'init_range_parted'; SET SESSION AUTHORIZATION regress_range_parted_user; -- Here, RLS checks should succeed while moving row from part_a_10_a_20 to @@ -370,7 +370,7 @@ SET SESSION AUTHORIZATION regress_range_parted_user; UPDATE range_parted set a = 'b', c = 151 WHERE a = 'a' and c = 200; RESET SESSION AUTHORIZATION; -'init_range_parted'; +-- 'init_range_parted'; SET SESSION AUTHORIZATION regress_range_parted_user; -- This should fail with RLS violation error. Even though the UPDATE is setting -- 'c' to an even number, the trigger at the destination partition again makes @@ -384,7 +384,7 @@ DROP FUNCTION func_d_1_15(); -- Policy expression contains SubPlan RESET SESSION AUTHORIZATION; -'init_range_parted'; +-- 'init_range_parted'; CREATE POLICY policy_range_parted_subplan on range_parted AS RESTRICTIVE for UPDATE USING (true) WITH CHECK ((SELECT range_parted.c <= c1 FROM mintab)); @@ -397,14 +397,14 @@ UPDATE range_parted set a = 'b', c = 120 WHERE a = 'a' and c = 200; -- RLS policy expression contains whole row. RESET SESSION AUTHORIZATION; -'init_range_parted'; +-- 'init_range_parted'; CREATE POLICY policy_range_parted_wholerow on range_parted AS RESTRICTIVE for UPDATE USING (true) WITH CHECK (range_parted = row('b', 10, 112, 1, NULL)::range_parted); SET SESSION AUTHORIZATION regress_range_parted_user; -- ok, should pass the RLS check UPDATE range_parted set a = 'b', c = 112 WHERE a = 'a' and c = 200; RESET SESSION AUTHORIZATION; -'init_range_parted'; +-- 'init_range_parted'; SET SESSION AUTHORIZATION regress_range_parted_user; -- fail, the whole row RLS check should fail UPDATE range_parted set a = 'b', c = 116 WHERE a = 'a' and c = 200; @@ -422,7 +422,7 @@ DROP TABLE mintab; -- statement triggers with update row movement --------------------------------------------------- -'init_range_parted'; +-- 'init_range_parted'; CREATE FUNCTION trigfunc() returns trigger language plpgsql as $$ @@ -466,7 +466,7 @@ CREATE TRIGGER d15_insert_trig -- Move all rows from part_c_100_200 to part_c_1_100. None of the delete or -- insert statement triggers should be fired. UPDATE range_parted set c = c - 50 WHERE c > 97; -'show_data'; +-- 'show_data'; DROP TRIGGER parent_delete_trig ON range_parted; DROP TRIGGER parent_update_trig ON range_parted; @@ -483,7 +483,7 @@ DROP TRIGGER d15_insert_trig ON part_d_15_20; -- Creating default partition for range -'init_range_parted'; +-- 'init_range_parted'; create table part_def partition of range_parted default; insert into range_parted values ('c', 9); -- ok @@ -491,7 +491,7 @@ update part_def set a = 'd' where a = 'c'; -- fail update part_def set a = 'a' where a = 'd'; -'show_data'; +-- 'show_data'; -- Update row movement from non-default to default partition. -- fail, default partition is not under part_a_10_a_20; @@ -499,12 +499,12 @@ UPDATE part_a_10_a_20 set a = 'ad' WHERE a = 'a'; -- ok UPDATE range_parted set a = 'ad' WHERE a = 'a'; UPDATE range_parted set a = 'bd' WHERE a = 'b'; -'show_data'; +-- 'show_data'; -- Update row movement from default to non-default partitions. -- ok UPDATE range_parted set a = 'a' WHERE a = 'ad'; UPDATE range_parted set a = 'b' WHERE a = 'bd'; -'show_data'; +-- 'show_data'; -- Cleanup: range_parted no longer needed. DROP TABLE range_parted; diff --git a/crates/squawk_parser/tests/data/regression_suite/window.sql b/crates/squawk_parser/tests/data/regression_suite/window.sql index 02f105f0..66edb349 100644 --- a/crates/squawk_parser/tests/data/regression_suite/window.sql +++ b/crates/squawk_parser/tests/data/regression_suite/window.sql @@ -1086,7 +1086,7 @@ DELETE FROM empsalary RETURNING rank() OVER (ORDER BY random()); SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1); -SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1; +-- SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1; SELECT count() OVER () FROM tenk1; diff --git a/crates/squawk_parser/tests/snapshots/tests__delete_ok.snap b/crates/squawk_parser/tests/snapshots/tests__delete_ok.snap index e31d5653..20535e34 100644 --- a/crates/squawk_parser/tests/snapshots/tests__delete_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__delete_ok.snap @@ -314,8 +314,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - NAME_REF - IDENT "user_id" + GROUPING_EXPR + NAME_REF + IDENT "user_id" R_PAREN ")" WHITESPACE " " ALIAS diff --git a/crates/squawk_parser/tests/snapshots/tests__explain_ok.snap b/crates/squawk_parser/tests/snapshots/tests__explain_ok.snap index f0d6aee9..414dccf7 100644 --- a/crates/squawk_parser/tests/snapshots/tests__explain_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__explain_ok.snap @@ -398,8 +398,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - IDENT "foo" + GROUPING_EXPR + NAME_REF + IDENT "foo" SEMICOLON ";" WHITESPACE "\n\n" EXPLAIN @@ -483,8 +484,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - IDENT "foo" + GROUPING_EXPR + NAME_REF + IDENT "foo" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- doc_example_8" @@ -559,8 +561,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - IDENT "foo" + GROUPING_EXPR + NAME_REF + IDENT "foo" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- parens_select" diff --git a/crates/squawk_parser/tests/snapshots/tests__misc_ok.snap b/crates/squawk_parser/tests/snapshots/tests__misc_ok.snap index d842d4ad..be263685 100644 --- a/crates/squawk_parser/tests/snapshots/tests__misc_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__misc_ok.snap @@ -1089,16 +1089,19 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" COMMA "," WHITESPACE " " - LITERAL - INT_NUMBER "2" + GROUPING_EXPR + LITERAL + INT_NUMBER "2" COMMA "," WHITESPACE " " - LITERAL - INT_NUMBER "3" + GROUPING_EXPR + LITERAL + INT_NUMBER "3" WHITESPACE "\n" ORDER_BY_CLAUSE ORDER_KW "ORDER" @@ -2515,8 +2518,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" WHITESPACE " " ORDER_BY_CLAUSE ORDER_KW "order" @@ -3689,8 +3693,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" SEMICOLON ";" WHITESPACE "\n" CREATE_INDEX @@ -4781,12 +4786,14 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" COMMA "," WHITESPACE " " - LITERAL - INT_NUMBER "2" + GROUPING_EXPR + LITERAL + INT_NUMBER "2" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- Use CTEs to break down complex analytics" @@ -4899,8 +4906,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" WHITESPACE "\n" R_PAREN ")" COMMA "," @@ -5079,12 +5087,14 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" COMMA "," WHITESPACE " " - LITERAL - INT_NUMBER "2" + GROUPING_EXPR + LITERAL + INT_NUMBER "2" SEMICOLON ";" WHITESPACE "\n\n" EXPLAIN @@ -5161,8 +5171,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- Key settings for parallel queries" @@ -5326,8 +5337,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- Remove unnecessary ORDER BY" @@ -5388,8 +5400,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- Gets all rows then filters" @@ -5466,8 +5479,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - IDENT "user_id" + GROUPING_EXPR + NAME_REF + IDENT "user_id" WHITESPACE "\n" R_PAREN ")" SEMICOLON ";" @@ -5789,12 +5803,13 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE "\n " - FIELD_EXPR - NAME_REF - IDENT "p" - DOT "." - NAME_REF - IDENT "sku" + GROUPING_EXPR + FIELD_EXPR + NAME_REF + IDENT "p" + DOT "." + NAME_REF + IDENT "sku" WHITESPACE "\n" ORDER_BY_CLAUSE ORDER_KW "ORDER" @@ -6155,16 +6170,19 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - DAY_KW "day" + GROUPING_EXPR + NAME_REF + DAY_KW "day" COMMA "," WHITESPACE " " - NAME_REF - IDENT "panel_id" + GROUPING_EXPR + NAME_REF + IDENT "panel_id" COMMA "," WHITESPACE " " - NAME_REF - IDENT "expected_power" + GROUPING_EXPR + NAME_REF + IDENT "expected_power" WHITESPACE "\n" HAVING_CLAUSE HAVING_KW "HAVING" @@ -6272,8 +6290,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - IDENT "turbine_id" + GROUPING_EXPR + NAME_REF + IDENT "turbine_id" WHITESPACE "\n" R_PAREN ")" WHITESPACE "\n" @@ -6528,12 +6547,14 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - INTERVAL_KW "interval" + GROUPING_EXPR + NAME_REF + INTERVAL_KW "interval" COMMA "," WHITESPACE " " - NAME_REF - IDENT "resource_type" + GROUPING_EXPR + NAME_REF + IDENT "resource_type" WHITESPACE "\n" ORDER_BY_CLAUSE ORDER_KW "ORDER" @@ -6669,8 +6690,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - HOUR_KW "hour" + GROUPING_EXPR + NAME_REF + HOUR_KW "hour" WHITESPACE "\n" R_PAREN ")" WHITESPACE "\n" diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_groupingsets.snap b/crates/squawk_parser/tests/snapshots/tests__regression_groupingsets.snap index b79e6f7a..fb4713d4 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_groupingsets.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_groupingsets.snap @@ -2,19 +2,4 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/groupingsets.sql --- -ERROR@2795: expected COMMA -ERROR@2813: expected COMMA -ERROR@2908: expected COMMA -ERROR@2926: expected COMMA -ERROR@3023: expected COMMA -ERROR@3048: expected COMMA -ERROR@3147: expected COMMA -ERROR@3245: expected COMMA -ERROR@3341: expected COMMA -ERROR@3435: expected COMMA -ERROR@3452: expected COMMA -ERROR@3545: expected COMMA -ERROR@3562: expected COMMA -ERROR@3579: expected COMMA -ERROR@3607: expected COMMA -ERROR@3717: expected COMMA + diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_inherit.snap b/crates/squawk_parser/tests/snapshots/tests__regression_inherit.snap index 5b743909..1149b92b 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_inherit.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_inherit.snap @@ -8,13 +8,15 @@ ERROR@30455: expected SEMICOLON ERROR@30455: expected command, found R_PAREN ERROR@30457: expected command, found FROM_KW ERROR@30462: expected command, found IDENT -ERROR@30477: expected command, found L_PAREN +ERROR@30478: expected R_PAREN +ERROR@30478: expected SEMICOLON ERROR@30478: expected command, found INT_NUMBER ERROR@30479: expected command, found COMMA ERROR@30481: expected command, found INT_NUMBER ERROR@30482: expected command, found R_PAREN ERROR@30484: expected command, found IDENT -ERROR@30485: expected command, found L_PAREN +ERROR@30486: expected R_PAREN +ERROR@30486: expected SEMICOLON ERROR@30486: expected command, found IDENT ERROR@30487: expected command, found R_PAREN ERROR@30594: expected R_PAREN @@ -23,12 +25,14 @@ ERROR@30718: expected SEMICOLON ERROR@30718: expected command, found R_PAREN ERROR@30720: expected command, found FROM_KW ERROR@30725: expected command, found IDENT -ERROR@30740: expected command, found L_PAREN +ERROR@30741: expected R_PAREN +ERROR@30741: expected SEMICOLON ERROR@30741: expected command, found INT_NUMBER ERROR@30742: expected command, found COMMA ERROR@30744: expected command, found INT_NUMBER ERROR@30745: expected command, found R_PAREN ERROR@30747: expected command, found IDENT -ERROR@30748: expected command, found L_PAREN +ERROR@30749: expected R_PAREN +ERROR@30749: expected SEMICOLON ERROR@30749: expected command, found IDENT ERROR@30750: expected command, found R_PAREN diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_partition_prune.snap b/crates/squawk_parser/tests/snapshots/tests__regression_partition_prune.snap index cac3872a..fb7da063 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_partition_prune.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_partition_prune.snap @@ -11,7 +11,8 @@ ERROR@60955: expected SEMICOLON ERROR@60956: expected command, found IDENT ERROR@60967: expected command, found IDENT ERROR@60971: expected command, found ON_KW -ERROR@60974: expected command, found L_PAREN +ERROR@60975: expected R_PAREN +ERROR@60975: expected SEMICOLON ERROR@60975: expected command, found IDENT ERROR@60976: expected command, found DOT ERROR@60977: expected command, found IDENT @@ -44,7 +45,8 @@ ERROR@61119: expected SEMICOLON ERROR@61120: expected command, found IDENT ERROR@61131: expected command, found IDENT ERROR@61135: expected command, found ON_KW -ERROR@61138: expected command, found L_PAREN +ERROR@61139: expected R_PAREN +ERROR@61139: expected SEMICOLON ERROR@61139: expected command, found IDENT ERROR@61140: expected command, found DOT ERROR@61141: expected command, found IDENT @@ -77,7 +79,8 @@ ERROR@61344: expected SEMICOLON ERROR@61345: expected command, found IDENT ERROR@61356: expected command, found IDENT ERROR@61360: expected command, found ON_KW -ERROR@61363: expected command, found L_PAREN +ERROR@61364: expected R_PAREN +ERROR@61364: expected SEMICOLON ERROR@61364: expected command, found IDENT ERROR@61365: expected command, found DOT ERROR@61366: expected command, found IDENT @@ -110,7 +113,8 @@ ERROR@61512: expected SEMICOLON ERROR@61513: expected command, found IDENT ERROR@61524: expected command, found IDENT ERROR@61528: expected command, found ON_KW -ERROR@61531: expected command, found L_PAREN +ERROR@61532: expected R_PAREN +ERROR@61532: expected SEMICOLON ERROR@61532: expected command, found IDENT ERROR@61533: expected command, found DOT ERROR@61534: expected command, found IDENT @@ -143,7 +147,8 @@ ERROR@61784: expected SEMICOLON ERROR@61785: expected command, found IDENT ERROR@61796: expected command, found IDENT ERROR@61800: expected command, found ON_KW -ERROR@61803: expected command, found L_PAREN +ERROR@61804: expected R_PAREN +ERROR@61804: expected SEMICOLON ERROR@61804: expected command, found IDENT ERROR@61805: expected command, found DOT ERROR@61806: expected command, found IDENT @@ -158,8 +163,7 @@ ERROR@61824: expected command, found DOT ERROR@61825: expected command, found IDENT ERROR@61827: expected command, found EQ ERROR@61829: expected command, found IDENT -ERROR@61839: expected command, found L_PAREN -ERROR@61840: expected command, found R_PAREN +ERROR@61841: expected SEMICOLON ERROR@61842: expected command, found PLUS ERROR@61844: expected command, found INT_NUMBER ERROR@61846: expected command, found WHEN_KW @@ -188,7 +192,8 @@ ERROR@61990: expected SEMICOLON ERROR@61991: expected command, found IDENT ERROR@62002: expected command, found IDENT ERROR@62006: expected command, found ON_KW -ERROR@62009: expected command, found L_PAREN +ERROR@62010: expected R_PAREN +ERROR@62010: expected SEMICOLON ERROR@62010: expected command, found IDENT ERROR@62011: expected command, found DOT ERROR@62012: expected command, found IDENT @@ -203,8 +208,7 @@ ERROR@62030: expected command, found DOT ERROR@62031: expected command, found IDENT ERROR@62033: expected command, found EQ ERROR@62035: expected command, found IDENT -ERROR@62045: expected command, found L_PAREN -ERROR@62046: expected command, found R_PAREN +ERROR@62047: expected SEMICOLON ERROR@62048: expected command, found PLUS ERROR@62050: expected command, found INT_NUMBER ERROR@62052: expected command, found WHEN_KW @@ -236,7 +240,8 @@ ERROR@62378: expected SEMICOLON ERROR@62379: expected command, found IDENT ERROR@62390: expected command, found IDENT ERROR@62394: expected command, found ON_KW -ERROR@62397: expected command, found L_PAREN +ERROR@62398: expected R_PAREN +ERROR@62398: expected SEMICOLON ERROR@62398: expected command, found IDENT ERROR@62399: expected command, found DOT ERROR@62400: expected command, found IDENT @@ -251,8 +256,7 @@ ERROR@62418: expected command, found DOT ERROR@62419: expected command, found IDENT ERROR@62421: expected command, found EQ ERROR@62423: expected command, found IDENT -ERROR@62433: expected command, found L_PAREN -ERROR@62434: expected command, found R_PAREN +ERROR@62435: expected SEMICOLON ERROR@62436: expected command, found PLUS ERROR@62438: expected command, found INT_NUMBER ERROR@62442: expected command, found WHEN_KW @@ -270,8 +274,7 @@ ERROR@62487: expected command, found FALSE_KW ERROR@62492: expected command, found R_PAREN ERROR@62494: expected command, found RETURNING_KW ERROR@62504: expected command, found MERGE_ACTION_KW -ERROR@62516: expected command, found L_PAREN -ERROR@62517: expected command, found R_PAREN +ERROR@62518: expected SEMICOLON ERROR@62518: expected command, found COMMA ERROR@62520: expected command, found IDENT ERROR@62522: expected command, found DOT @@ -287,7 +290,8 @@ ERROR@62673: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: IDEN ERROR@62674: expected command, found IDENT ERROR@62685: expected command, found IDENT ERROR@62689: expected command, found ON_KW -ERROR@62692: expected command, found L_PAREN +ERROR@62693: expected R_PAREN +ERROR@62693: expected SEMICOLON ERROR@62693: expected command, found IDENT ERROR@62694: expected command, found DOT ERROR@62695: expected command, found IDENT @@ -302,8 +306,7 @@ ERROR@62713: expected command, found DOT ERROR@62714: expected command, found IDENT ERROR@62716: expected command, found EQ ERROR@62718: expected command, found IDENT -ERROR@62728: expected command, found L_PAREN -ERROR@62729: expected command, found R_PAREN +ERROR@62730: expected SEMICOLON ERROR@62731: expected command, found PLUS ERROR@62733: expected command, found INT_NUMBER ERROR@62737: expected command, found WHEN_KW @@ -321,8 +324,7 @@ ERROR@62782: expected command, found FALSE_KW ERROR@62787: expected command, found R_PAREN ERROR@62789: expected command, found RETURNING_KW ERROR@62799: expected command, found MERGE_ACTION_KW -ERROR@62811: expected command, found L_PAREN -ERROR@62812: expected command, found R_PAREN +ERROR@62813: expected SEMICOLON ERROR@62813: expected command, found COMMA ERROR@62815: expected command, found IDENT ERROR@62817: expected command, found DOT diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_privileges.snap b/crates/squawk_parser/tests/snapshots/tests__regression_privileges.snap index 18eee777..e5d35748 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_privileges.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_privileges.snap @@ -2,30 +2,6 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/privileges.sql --- -ERROR@1281: missing comma -ERROR@1289: expected OPTION, TRUE, or FALSE -ERROR@1289: missing comma -ERROR@1292: expected OPTION, TRUE, or FALSE -ERROR@1292: missing comma -ERROR@1311: expected OPTION, TRUE, or FALSE -ERROR@1377: missing comma -ERROR@1385: expected OPTION, TRUE, or FALSE -ERROR@1385: missing comma -ERROR@1388: expected OPTION, TRUE, or FALSE -ERROR@1388: missing comma -ERROR@1407: expected OPTION, TRUE, or FALSE -ERROR@8877: missing comma -ERROR@8885: expected OPTION, TRUE, or FALSE -ERROR@8885: missing comma -ERROR@8888: expected OPTION, TRUE, or FALSE -ERROR@8888: missing comma -ERROR@8906: expected OPTION, TRUE, or FALSE -ERROR@9007: missing comma -ERROR@9015: expected OPTION, TRUE, or FALSE -ERROR@9015: missing comma -ERROR@9018: expected OPTION, TRUE, or FALSE -ERROR@9018: missing comma -ERROR@9031: expected OPTION, TRUE, or FALSE ERROR@17722: expected R_PAREN ERROR@17782: expected SEMICOLON ERROR@17782: expected command, found R_PAREN @@ -40,49 +16,3 @@ ERROR@17985: expected command, found WHERE_KW ERROR@17991: expected command, found IDENT ERROR@17993: expected command, found L_ANGLE ERROR@17995: expected command, found INT_NUMBER -ERROR@37160: expected SELECT, TABLE, VALUES, or EXECUTE -ERROR@37160: expected SEMICOLON -ERROR@38499: expected SELECT, TABLE, VALUES, or EXECUTE -ERROR@38499: expected SEMICOLON -ERROR@56850: expected SEMICOLON -ERROR@56851: expected command, found ORDER_KW -ERROR@56857: expected command, found BY_KW -ERROR@56860: expected command, found IDENT -ERROR@56870: expected command, found COLLATE_KW -ERROR@56878: expected command, found IDENT -ERROR@56924: expected SEMICOLON -ERROR@56925: expected command, found ORDER_KW -ERROR@56931: expected command, found BY_KW -ERROR@56934: expected command, found IDENT -ERROR@56944: expected command, found COLLATE_KW -ERROR@56952: expected command, found IDENT -ERROR@61439: expected privilege target, TABLES, FUNCTIONS, ROUTINES, SEQEUNCES, TYPES, SCHEMAS -ERROR@61439: expected TO_KW -ERROR@61445: expected SEMICOLON -ERROR@61446: expected command, found OBJECTS_KW -ERROR@61454: expected command, found TO_KW -ERROR@61457: expected command, found IDENT -ERROR@61775: expected privilege target, TABLES, FUNCTIONS, ROUTINES, SEQEUNCES, TYPES, SCHEMAS -ERROR@61775: expected TO_KW -ERROR@61781: expected SEMICOLON -ERROR@61782: expected command, found OBJECTS_KW -ERROR@61790: expected command, found TO_KW -ERROR@61793: expected command, found IDENT -ERROR@62039: expected privilege target, TABLES, FUNCTIONS, ROUTINES, SEQEUNCES, TYPES, SCHEMAS -ERROR@62039: expected FROM_KW -ERROR@62045: expected SEMICOLON -ERROR@62046: expected command, found OBJECTS_KW -ERROR@62054: expected command, found FROM_KW -ERROR@62059: expected command, found IDENT -ERROR@62330: expected privilege target, TABLES, FUNCTIONS, ROUTINES, SEQEUNCES, TYPES, SCHEMAS -ERROR@62330: expected TO_KW -ERROR@62336: expected SEMICOLON -ERROR@62337: expected command, found OBJECTS_KW -ERROR@62345: expected command, found TO_KW -ERROR@62348: expected command, found IDENT -ERROR@62646: expected privilege target, TABLES, FUNCTIONS, ROUTINES, SEQEUNCES, TYPES, SCHEMAS -ERROR@62646: expected TO_KW -ERROR@62652: expected SEMICOLON -ERROR@62653: expected command, found OBJECTS_KW -ERROR@62661: expected command, found TO_KW -ERROR@62664: expected command, found IDENT diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_rangefuncs.snap b/crates/squawk_parser/tests/snapshots/tests__regression_rangefuncs.snap index 55bbae8e..f4c209e2 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_rangefuncs.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_rangefuncs.snap @@ -2,284 +2,4 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/rangefuncs.sql --- -ERROR@1221: expected R_PAREN -ERROR@1233: expected SEMICOLON -ERROR@1233: expected command, found R_PAREN -ERROR@1253: expected L_PAREN -ERROR@1254: expected command, found IDENT -ERROR@1255: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@1255: expected R_PAREN -ERROR@1255: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: L_PAREN -ERROR@1255: expected command, found L_PAREN -ERROR@1256: expected command, found IDENT -ERROR@1257: expected command, found COMMA -ERROR@1258: expected command, found IDENT -ERROR@1259: expected command, found COMMA -ERROR@1260: expected command, found IDENT -ERROR@1261: expected command, found COMMA -ERROR@1262: expected command, found IDENT -ERROR@1263: expected command, found COMMA -ERROR@1264: expected command, found IDENT -ERROR@1267: expected command, found R_PAREN -ERROR@1360: expected R_PAREN -ERROR@1360: expected USING_KW -ERROR@1360: expected L_PAREN -ERROR@1372: expected SEMICOLON -ERROR@1372: expected command, found R_PAREN -ERROR@1392: expected L_PAREN -ERROR@1393: expected command, found IDENT -ERROR@1394: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@1394: expected R_PAREN -ERROR@1394: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: L_PAREN -ERROR@1394: expected command, found L_PAREN -ERROR@1395: expected command, found IDENT -ERROR@1396: expected command, found COMMA -ERROR@1397: expected command, found IDENT -ERROR@1398: expected command, found COMMA -ERROR@1399: expected command, found IDENT -ERROR@1400: expected command, found COMMA -ERROR@1401: expected command, found IDENT -ERROR@1402: expected command, found COMMA -ERROR@1403: expected command, found IDENT -ERROR@1406: expected command, found R_PAREN -ERROR@1408: expected command, found ON_KW -ERROR@1411: expected command, found L_PAREN -ERROR@1412: expected command, found IDENT -ERROR@1413: expected command, found EQ -ERROR@1414: expected command, found IDENT -ERROR@1417: expected command, found R_PAREN -ERROR@1880: expected R_PAREN -ERROR@1906: expected SEMICOLON -ERROR@1906: expected command, found R_PAREN -ERROR@1926: expected L_PAREN -ERROR@1927: expected command, found IDENT -ERROR@1928: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@1928: expected R_PAREN -ERROR@1928: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: L_PAREN -ERROR@1928: expected command, found L_PAREN -ERROR@1929: expected command, found IDENT -ERROR@1930: expected command, found COMMA -ERROR@1931: expected command, found IDENT -ERROR@1932: expected command, found COMMA -ERROR@1933: expected command, found IDENT -ERROR@1934: expected command, found COMMA -ERROR@1935: expected command, found IDENT -ERROR@1938: expected command, found R_PAREN -ERROR@2461: expected R_PAREN -ERROR@2483: expected SEMICOLON -ERROR@2483: expected command, found R_PAREN -ERROR@2485: expected command, found AS_KW -ERROR@2488: expected command, found IDENT -ERROR@2489: expected command, found L_PAREN -ERROR@2490: expected command, found IDENT -ERROR@2491: expected command, found COMMA -ERROR@2492: expected command, found IDENT -ERROR@2493: expected command, found COMMA -ERROR@2494: expected command, found IDENT -ERROR@2495: expected command, found R_PAREN -ERROR@2745: expected R_PAREN -ERROR@2766: expected SEMICOLON -ERROR@2766: expected command, found R_PAREN -ERROR@2786: expected L_PAREN -ERROR@2787: expected command, found IDENT -ERROR@2788: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@2788: expected R_PAREN -ERROR@2788: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: L_PAREN -ERROR@2788: expected command, found L_PAREN -ERROR@2789: expected command, found IDENT -ERROR@2790: expected command, found COMMA -ERROR@2791: expected command, found IDENT -ERROR@2792: expected command, found COMMA -ERROR@2793: expected command, found IDENT -ERROR@2794: expected command, found R_PAREN -ERROR@9467: expected R_PAREN -ERROR@9760: expected SEMICOLON -ERROR@9760: expected command, found R_PAREN -ERROR@9794: expected L_PAREN -ERROR@9795: expected command, found IDENT -ERROR@9797: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@9797: expected R_PAREN -ERROR@9797: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: L_PAREN -ERROR@9797: expected command, found L_PAREN -ERROR@9798: expected command, found IDENT -ERROR@9799: expected command, found COMMA -ERROR@9800: expected command, found IDENT -ERROR@9801: expected command, found COMMA -ERROR@9802: expected command, found IDENT -ERROR@9803: expected command, found COMMA -ERROR@9804: expected command, found IDENT -ERROR@9805: expected command, found COMMA -ERROR@9806: expected command, found IDENT -ERROR@9807: expected command, found COMMA -ERROR@9808: expected command, found IDENT -ERROR@9809: expected command, found COMMA -ERROR@9810: expected command, found IDENT -ERROR@9811: expected command, found COMMA -ERROR@9812: expected command, found IDENT -ERROR@9813: expected command, found COMMA -ERROR@9814: expected command, found IDENT -ERROR@9815: expected command, found COMMA -ERROR@9816: expected command, found IDENT -ERROR@9817: expected command, found COMMA -ERROR@9818: expected command, found IDENT -ERROR@9819: expected command, found COMMA -ERROR@9820: expected command, found IDENT -ERROR@9821: expected command, found COMMA -ERROR@9822: expected command, found IDENT -ERROR@9823: expected command, found COMMA -ERROR@9824: expected command, found IDENT -ERROR@9825: expected command, found COMMA -ERROR@9826: expected command, found IDENT -ERROR@9827: expected command, found COMMA -ERROR@9828: expected command, found IDENT -ERROR@9829: expected command, found COMMA -ERROR@9830: expected command, found IDENT -ERROR@9831: expected command, found COMMA -ERROR@9832: expected command, found IDENT -ERROR@9833: expected command, found COMMA -ERROR@9834: expected command, found IDENT -ERROR@9835: expected command, found COMMA -ERROR@9836: expected command, found IDENT -ERROR@9837: expected command, found R_PAREN -ERROR@9878: expected R_PAREN -ERROR@10171: expected SEMICOLON -ERROR@10171: expected command, found R_PAREN -ERROR@10205: expected L_PAREN -ERROR@10206: expected command, found IDENT -ERROR@10208: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@10208: expected R_PAREN -ERROR@10208: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: L_PAREN -ERROR@10208: expected command, found L_PAREN -ERROR@10209: expected command, found IDENT -ERROR@10210: expected command, found COMMA -ERROR@10211: expected command, found IDENT -ERROR@10212: expected command, found COMMA -ERROR@10213: expected command, found IDENT -ERROR@10214: expected command, found COMMA -ERROR@10215: expected command, found IDENT -ERROR@10216: expected command, found COMMA -ERROR@10217: expected command, found IDENT -ERROR@10218: expected command, found COMMA -ERROR@10219: expected command, found IDENT -ERROR@10220: expected command, found COMMA -ERROR@10221: expected command, found IDENT -ERROR@10222: expected command, found COMMA -ERROR@10223: expected command, found IDENT -ERROR@10224: expected command, found COMMA -ERROR@10225: expected command, found IDENT -ERROR@10226: expected command, found COMMA -ERROR@10227: expected command, found IDENT -ERROR@10228: expected command, found COMMA -ERROR@10229: expected command, found IDENT -ERROR@10230: expected command, found COMMA -ERROR@10231: expected command, found IDENT -ERROR@10232: expected command, found COMMA -ERROR@10233: expected command, found IDENT -ERROR@10234: expected command, found COMMA -ERROR@10235: expected command, found IDENT -ERROR@10236: expected command, found COMMA -ERROR@10237: expected command, found IDENT -ERROR@10238: expected command, found COMMA -ERROR@10239: expected command, found IDENT -ERROR@10240: expected command, found COMMA -ERROR@10241: expected command, found IDENT -ERROR@10242: expected command, found COMMA -ERROR@10243: expected command, found IDENT -ERROR@10244: expected command, found COMMA -ERROR@10245: expected command, found IDENT -ERROR@10246: expected command, found COMMA -ERROR@10247: expected command, found IDENT -ERROR@10248: expected command, found R_PAREN -ERROR@10328: expected R_PAREN -ERROR@10459: expected SEMICOLON -ERROR@10459: expected command, found R_PAREN -ERROR@10495: expected L_PAREN -ERROR@10496: expected command, found IDENT -ERROR@10498: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@10498: expected R_PAREN -ERROR@10498: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: L_PAREN -ERROR@10498: expected command, found L_PAREN -ERROR@10499: expected command, found IDENT -ERROR@10500: expected command, found COMMA -ERROR@10501: expected command, found IDENT -ERROR@10502: expected command, found COMMA -ERROR@10503: expected command, found IDENT -ERROR@10504: expected command, found COMMA -ERROR@10505: expected command, found IDENT -ERROR@10506: expected command, found COMMA -ERROR@10507: expected command, found IDENT -ERROR@10508: expected command, found COMMA -ERROR@10509: expected command, found IDENT -ERROR@10510: expected command, found COMMA -ERROR@10511: expected command, found IDENT -ERROR@10512: expected command, found COMMA -ERROR@10513: expected command, found IDENT -ERROR@10514: expected command, found R_PAREN -ERROR@12643: expected R_PAREN -ERROR@12643: expected USING_KW -ERROR@12643: expected L_PAREN -ERROR@12663: expected SEMICOLON -ERROR@12664: expected command, found R_PAREN -ERROR@12684: expected L_PAREN -ERROR@12685: expected command, found IDENT -ERROR@12686: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@12686: expected R_PAREN -ERROR@12686: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: L_PAREN -ERROR@12686: expected command, found L_PAREN -ERROR@12687: expected command, found IDENT -ERROR@12689: expected command, found COMMA -ERROR@12690: expected command, found IDENT -ERROR@12692: expected command, found COMMA -ERROR@12693: expected command, found IDENT -ERROR@12695: expected command, found COMMA -ERROR@12696: expected command, found IDENT -ERROR@12698: expected command, found COMMA -ERROR@12699: expected command, found IDENT -ERROR@12700: expected command, found R_PAREN -ERROR@12702: expected command, found ON_KW -ERROR@12705: expected command, found L_PAREN -ERROR@12706: expected command, found IDENT -ERROR@12707: expected command, found PLUS -ERROR@12708: expected command, found IDENT -ERROR@12710: expected command, found PLUS -ERROR@12711: expected command, found IDENT -ERROR@12713: expected command, found R_PAREN -ERROR@12714: expected command, found L_ANGLE -ERROR@12715: expected command, found INT_NUMBER -ERROR@15403: expected R_PAREN -ERROR@15425: expected SEMICOLON -ERROR@15426: expected command, found R_PAREN -ERROR@15585: expected R_PAREN -ERROR@15605: expected SEMICOLON -ERROR@15606: expected command, found R_PAREN -ERROR@15765: expected R_PAREN -ERROR@15787: expected SEMICOLON -ERROR@15788: expected command, found R_PAREN -ERROR@15973: expected R_PAREN -ERROR@15996: expected SEMICOLON -ERROR@15997: expected command, found R_PAREN -ERROR@28655: expected R_PAREN -ERROR@28668: expected SEMICOLON -ERROR@28668: expected command, found R_PAREN -ERROR@28685: expected AS_KW -ERROR@28685: expected L_PAREN -ERROR@28685: expected command, found SEMICOLON -ERROR@28686: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@28686: expected R_PAREN -ERROR@28722: expected R_PAREN -ERROR@28746: expected SEMICOLON -ERROR@28746: expected command, found R_PAREN -ERROR@28763: expected AS_KW -ERROR@28763: expected L_PAREN -ERROR@28763: expected command, found SEMICOLON -ERROR@28764: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@28764: expected R_PAREN -ERROR@28764: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: CREATE_KW -ERROR@28895: expected R_PAREN -ERROR@28919: expected SEMICOLON -ERROR@28919: expected command, found R_PAREN -ERROR@28936: expected AS_KW -ERROR@28936: expected L_PAREN -ERROR@28936: expected command, found SEMICOLON -ERROR@28937: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@28937: expected R_PAREN + diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_sqljson_jsontable.snap b/crates/squawk_parser/tests/snapshots/tests__regression_sqljson_jsontable.snap index e0ec3058..485b3fcd 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_sqljson_jsontable.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_sqljson_jsontable.snap @@ -2,188 +2,4 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/sqljson_jsontable.sql --- -ERROR@219: expected R_PAREN -ERROR@219: expected SEMICOLON -ERROR@220: expected command, found DEFAULT_KW -ERROR@228: expected command, found INT_NUMBER -ERROR@230: expected command, found ON_KW -ERROR@233: expected command, found ERROR_KW -ERROR@238: expected command, found R_PAREN -ERROR@311: expected R_PAREN -ERROR@311: expected SEMICOLON -ERROR@312: expected command, found NULL_KW -ERROR@317: expected command, found ON_KW -ERROR@320: expected command, found ERROR_KW -ERROR@325: expected command, found R_PAREN -ERROR@702: expected name -ERROR@702: expected type name -ERROR@1518: expected SELECT, TABLE, VALUES, or EXECUTE -ERROR@1518: expected SEMICOLON -ERROR@1520: expected command, found L_PAREN -ERROR@1648: expected SEMICOLON -ERROR@1650: expected command, found R_PAREN -ERROR@2684: expected ON_KW -ERROR@2684: expected ERROR_KW -ERROR@2684: expected R_PAREN -ERROR@2684: expected R_PAREN -ERROR@2718: expected SEMICOLON -ERROR@2719: expected command, found EXISTS_KW -ERROR@2726: expected command, found PATH_KW -ERROR@2731: expected command, found STRING -ERROR@2746: expected command, found FALSE_KW -ERROR@2752: expected command, found ON_KW -ERROR@2755: expected command, found ERROR_KW -ERROR@2763: expected command, found R_PAREN -ERROR@2766: expected command, found R_PAREN -ERROR@2768: expected command, found IDENT -ERROR@2772: expected command, found ON_KW -ERROR@2775: expected command, found TRUE_KW -ERROR@5161: expected ON_KW -ERROR@5161: expected ERROR_KW -ERROR@5161: expected R_PAREN -ERROR@5161: expected R_PAREN -ERROR@5161: expected SEMICOLON -ERROR@5162: expected command, found TRUE_KW -ERROR@5167: expected command, found ON_KW -ERROR@5170: expected command, found ERROR_KW -ERROR@5175: expected command, found COMMA -ERROR@5180: expected command, found IDENT -ERROR@5188: expected command, found TEXT_KW -ERROR@5193: expected command, found EXISTS_KW -ERROR@5200: expected command, found PATH_KW -ERROR@5205: expected command, found STRING -ERROR@5220: expected command, found UNKNOWN_KW -ERROR@5228: expected command, found ON_KW -ERROR@5231: expected command, found ERROR_KW -ERROR@5236: expected command, found R_PAREN -ERROR@5237: expected command, found R_PAREN -ERROR@7739: expected R_PAREN -ERROR@7739: expected R_PAREN -ERROR@7739: expected SEMICOLON -ERROR@7740: expected command, found DEFAULT_KW -ERROR@7748: expected command, found INT_NUMBER -ERROR@7750: expected command, found ON_KW -ERROR@7753: expected command, found ERROR_KW -ERROR@7758: expected command, found R_PAREN -ERROR@7759: expected command, found R_PAREN -ERROR@7761: expected command, found IDENT -ERROR@7858: expected R_PAREN -ERROR@7858: expected R_PAREN -ERROR@7858: expected SEMICOLON -ERROR@7859: expected command, found DEFAULT_KW -ERROR@7867: expected command, found INT_NUMBER -ERROR@7869: expected command, found ON_KW -ERROR@7872: expected command, found ERROR_KW -ERROR@7877: expected command, found R_PAREN -ERROR@7878: expected command, found R_PAREN -ERROR@7880: expected command, found IDENT -ERROR@7974: expected R_PAREN -ERROR@7974: expected R_PAREN -ERROR@7974: expected SEMICOLON -ERROR@7975: expected command, found DEFAULT_KW -ERROR@7983: expected command, found INT_NUMBER -ERROR@7985: expected command, found ON_KW -ERROR@7988: expected command, found ERROR_KW -ERROR@7993: expected command, found R_PAREN -ERROR@7994: expected command, found R_PAREN -ERROR@7996: expected command, found IDENT -ERROR@8109: expected ON_KW -ERROR@8115: expected R_PAREN -ERROR@8115: expected R_PAREN -ERROR@8115: expected SEMICOLON -ERROR@8116: expected command, found ON_KW -ERROR@8119: expected command, found ERROR_KW -ERROR@8124: expected command, found R_PAREN -ERROR@8125: expected command, found R_PAREN -ERROR@8225: expected ON_KW -ERROR@8231: expected R_PAREN -ERROR@8231: expected R_PAREN -ERROR@8231: expected SEMICOLON -ERROR@8232: expected command, found ON_KW -ERROR@8235: expected command, found ERROR_KW -ERROR@8240: expected command, found R_PAREN -ERROR@8241: expected command, found R_PAREN -ERROR@8715: expected ON_KW -ERROR@8721: expected R_PAREN -ERROR@8721: expected R_PAREN -ERROR@8721: expected SEMICOLON -ERROR@8722: expected command, found ON_KW -ERROR@8725: expected command, found ERROR_KW -ERROR@8730: expected command, found R_PAREN -ERROR@8731: expected command, found R_PAREN -ERROR@8812: expected ON_KW -ERROR@8818: expected R_PAREN -ERROR@8818: expected R_PAREN -ERROR@8818: expected SEMICOLON -ERROR@8819: expected command, found ON_KW -ERROR@8822: expected command, found ERROR_KW -ERROR@8827: expected command, found R_PAREN -ERROR@8828: expected command, found R_PAREN -ERROR@9376: expected ON_KW -ERROR@9382: expected R_PAREN -ERROR@9382: expected R_PAREN -ERROR@9382: expected SEMICOLON -ERROR@9383: expected command, found ON_KW -ERROR@9386: expected command, found ERROR_KW -ERROR@9391: expected command, found R_PAREN -ERROR@9392: expected command, found R_PAREN -ERROR@9486: expected ON_KW -ERROR@9486: expected ERROR_KW -ERROR@9486: expected R_PAREN -ERROR@9486: expected R_PAREN -ERROR@9486: expected SEMICOLON -ERROR@9487: expected command, found FALSE_KW -ERROR@9493: expected command, found ON_KW -ERROR@9496: expected command, found ERROR_KW -ERROR@9501: expected command, found R_PAREN -ERROR@9502: expected command, found R_PAREN -ERROR@9596: expected ON_KW -ERROR@9596: expected ERROR_KW -ERROR@9596: expected R_PAREN -ERROR@9596: expected R_PAREN -ERROR@9596: expected SEMICOLON -ERROR@9597: expected command, found TRUE_KW -ERROR@9602: expected command, found ON_KW -ERROR@9605: expected command, found ERROR_KW -ERROR@9610: expected command, found R_PAREN -ERROR@9611: expected command, found R_PAREN -ERROR@17135: expected R_PAREN -ERROR@17141: expected ON_KW -ERROR@17141: expected ERROR_KW -ERROR@17141: expected R_PAREN -ERROR@17148: expected SEMICOLON -ERROR@17149: expected command, found ON_KW -ERROR@17152: expected command, found EMPTY_KW -ERROR@17157: expected command, found R_PAREN -ERROR@17158: expected command, found R_PAREN -ERROR@17304: expected R_PAREN -ERROR@17304: expected SEMICOLON -ERROR@17305: expected command, found NULL_KW -ERROR@17310: expected command, found ON_KW -ERROR@17313: expected command, found ERROR_KW -ERROR@17318: expected command, found R_PAREN -ERROR@17375: expected R_PAREN -ERROR@17375: expected R_PAREN -ERROR@17375: expected SEMICOLON -ERROR@17376: expected command, found TRUE_KW -ERROR@17381: expected command, found ON_KW -ERROR@17384: expected command, found EMPTY_KW -ERROR@17389: expected command, found R_PAREN -ERROR@17390: expected command, found R_PAREN -ERROR@17459: expected R_PAREN -ERROR@17459: expected R_PAREN -ERROR@17459: expected SEMICOLON -ERROR@17460: expected command, found TRUE_KW -ERROR@17465: expected command, found ON_KW -ERROR@17468: expected command, found ERROR_KW -ERROR@17473: expected command, found R_PAREN -ERROR@17474: expected command, found R_PAREN -ERROR@17538: expected R_PAREN -ERROR@17544: expected ON_KW -ERROR@17544: expected ERROR_KW -ERROR@17544: expected R_PAREN -ERROR@17551: expected SEMICOLON -ERROR@17552: expected command, found ON_KW -ERROR@17555: expected command, found ERROR_KW -ERROR@17560: expected command, found R_PAREN -ERROR@17561: expected command, found R_PAREN + diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_subselect.snap b/crates/squawk_parser/tests/snapshots/tests__regression_subselect.snap index bb0ccb44..a1b81751 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_subselect.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_subselect.snap @@ -2,47 +2,4 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/subselect.sql --- -ERROR@31606: expected command, found L_PAREN -ERROR@31607: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@31607: expected R_PAREN -ERROR@31626: expected SEMICOLON -ERROR@31626: expected command, found R_PAREN -ERROR@31631: expected command, found UNION_KW -ERROR@31637: expected command, found ALL_KW -ERROR@31644: expected command, found L_PAREN -ERROR@31777: expected SEMICOLON -ERROR@31777: expected command, found R_PAREN -ERROR@31778: expected command, found R_PAREN -ERROR@31824: expected command, found L_PAREN -ERROR@31825: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@31825: expected R_PAREN -ERROR@31844: expected SEMICOLON -ERROR@31844: expected command, found R_PAREN -ERROR@31849: expected command, found UNION_KW -ERROR@31855: expected command, found ALL_KW -ERROR@31862: expected command, found L_PAREN -ERROR@31995: expected SEMICOLON -ERROR@31995: expected command, found R_PAREN -ERROR@31996: expected command, found R_PAREN -ERROR@32071: expected command, found L_PAREN -ERROR@32072: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@32072: expected R_PAREN -ERROR@32091: expected SEMICOLON -ERROR@32091: expected command, found R_PAREN -ERROR@32096: expected command, found UNION_KW -ERROR@32102: expected command, found ALL_KW -ERROR@32109: expected command, found L_PAREN -ERROR@32221: expected SEMICOLON -ERROR@32221: expected command, found R_PAREN -ERROR@32222: expected command, found R_PAREN -ERROR@32268: expected command, found L_PAREN -ERROR@32269: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@32269: expected R_PAREN -ERROR@32288: expected SEMICOLON -ERROR@32288: expected command, found R_PAREN -ERROR@32293: expected command, found UNION_KW -ERROR@32299: expected command, found ALL_KW -ERROR@32306: expected command, found L_PAREN -ERROR@32418: expected SEMICOLON -ERROR@32418: expected command, found R_PAREN -ERROR@32419: expected command, found R_PAREN + diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap b/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap index ea81ef7d..90bea2a2 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_suite_errors.snap @@ -2,19 +2,12 @@ source: crates/squawk_parser/tests/tests.rs expression: "out.join(\"\\n\")" --- -tests/snapshots/tests__regression_groupingsets.snap:16 -tests/snapshots/tests__regression_inherit.snap:30 +tests/snapshots/tests__regression_inherit.snap:34 tests/snapshots/tests__regression_join.snap:20 tests/snapshots/tests__regression_merge.snap:250 -tests/snapshots/tests__regression_partition_prune.snap:326 -tests/snapshots/tests__regression_privileges.snap:84 -tests/snapshots/tests__regression_rangefuncs.snap:281 -tests/snapshots/tests__regression_sqljson_jsontable.snap:185 +tests/snapshots/tests__regression_partition_prune.snap:328 +tests/snapshots/tests__regression_privileges.snap:14 tests/snapshots/tests__regression_strings.snap:49 -tests/snapshots/tests__regression_subselect.snap:44 tests/snapshots/tests__regression_tuplesort.snap:6 tests/snapshots/tests__regression_union.snap:15 -tests/snapshots/tests__regression_update.snap:29 -tests/snapshots/tests__regression_window.snap:72 -tests/snapshots/tests__regression_with.snap:9 -tests/snapshots/tests__regression_xml.snap:379 +tests/snapshots/tests__regression_xml.snap:382 diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_update.snap b/crates/squawk_parser/tests/snapshots/tests__regression_update.snap index 926671e5..0277de3e 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_update.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_update.snap @@ -2,32 +2,4 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/update.sql --- -ERROR@8287: expected command, found STRING -ERROR@8308: expected command, found STRING -ERROR@9069: expected command, found STRING -ERROR@9353: expected command, found STRING -ERROR@9941: expected command, found STRING -ERROR@10021: expected command, found STRING -ERROR@10139: expected command, found STRING -ERROR@10200: expected command, found STRING -ERROR@10894: expected command, found STRING -ERROR@10907: expected command, found STRING -ERROR@11513: expected command, found STRING -ERROR@12698: expected command, found STRING -ERROR@12828: expected command, found STRING -ERROR@12841: expected command, found STRING -ERROR@12935: expected command, found STRING -ERROR@13168: expected command, found STRING -ERROR@13233: expected command, found STRING -ERROR@13868: expected command, found STRING -ERROR@14487: expected command, found STRING -ERROR@14882: expected command, found STRING -ERROR@15383: expected command, found STRING -ERROR@15874: expected command, found STRING -ERROR@16249: expected command, found STRING -ERROR@16866: expected command, found STRING -ERROR@18760: expected command, found STRING -ERROR@19368: expected command, found STRING -ERROR@19589: expected command, found STRING -ERROR@19873: expected command, found STRING -ERROR@20051: expected command, found STRING + diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_window.snap b/crates/squawk_parser/tests/snapshots/tests__regression_window.snap index 3c6954d7..10555a5a 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_window.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_window.snap @@ -2,75 +2,4 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/window.sql --- -ERROR@4919: expected SEMICOLON -ERROR@4919: expected command, found COMMA -ERROR@4921: expected command, found IDENT -ERROR@4924: expected command, found AS_KW -ERROR@4927: expected command, found L_PAREN -ERROR@4928: expected command, found ORDER_KW -ERROR@4934: expected command, found BY_KW -ERROR@4937: expected command, found IDENT -ERROR@4943: expected command, found R_PAREN -ERROR@20873: expected preceding or following -ERROR@20874: expected AND_KW -ERROR@20875: expected preceding or following -ERROR@20876: expected R_PAREN -ERROR@20886: expected SEMICOLON -ERROR@20887: expected command, found AND_KW -ERROR@20891: expected command, found UNBOUNDED_KW -ERROR@20900: expected command, found L_PAREN -ERROR@20901: expected command, found INT_NUMBER -ERROR@20902: expected command, found R_PAREN -ERROR@20904: expected command, found FOLLOWING_KW -ERROR@20913: expected command, found R_PAREN -ERROR@20914: expected command, found COMMA -ERROR@20923: expected command, found IDENT -ERROR@20930: expected command, found COMMA -ERROR@20932: expected command, found IDENT -ERROR@20937: expected command, found FROM_KW -ERROR@20942: expected command, found IDENT -ERROR@20948: expected command, found WHERE_KW -ERROR@20954: expected command, found IDENT -ERROR@20962: expected command, found L_ANGLE -ERROR@20964: expected command, found INT_NUMBER -ERROR@21017: expected preceding or following -ERROR@21018: expected AND_KW -ERROR@21029: expected R_PAREN -ERROR@21055: expected SEMICOLON -ERROR@21055: expected command, found R_PAREN -ERROR@21056: expected command, found COMMA -ERROR@21065: expected command, found IDENT -ERROR@21072: expected command, found COMMA -ERROR@21074: expected command, found IDENT -ERROR@21079: expected command, found FROM_KW -ERROR@21084: expected command, found IDENT -ERROR@21089: expected command, found COMMA -ERROR@21091: expected command, found L_PAREN -ERROR@21102: expected SEMICOLON -ERROR@21102: expected command, found R_PAREN -ERROR@21104: expected command, found AS_KW -ERROR@21107: expected command, found UNBOUNDED_KW -ERROR@21116: expected command, found L_PAREN -ERROR@21117: expected command, found IDENT -ERROR@21118: expected command, found R_PAREN -ERROR@21120: expected command, found WHERE_KW -ERROR@21126: expected command, found IDENT -ERROR@21134: expected command, found L_ANGLE -ERROR@21136: expected command, found INT_NUMBER -ERROR@43531: expected SEMICOLON -ERROR@43531: expected command, found COMMA -ERROR@43533: expected command, found IDENT -ERROR@43535: expected command, found AS_KW -ERROR@43538: expected command, found L_PAREN -ERROR@43539: expected command, found ORDER_KW -ERROR@43545: expected command, found BY_KW -ERROR@43548: expected command, found IDENT -ERROR@43555: expected command, found R_PAREN -ERROR@43598: expected an expression, found ORDER_KW -ERROR@43603: expected an expression -ERROR@43603: expected R_PAREN -ERROR@43606: missing comma -ERROR@43610: expected SEMICOLON -ERROR@43610: expected command, found R_PAREN -ERROR@43612: expected command, found FROM_KW -ERROR@43617: expected command, found IDENT + diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_with.snap b/crates/squawk_parser/tests/snapshots/tests__regression_with.snap index 7a0ac0fe..155f4dba 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_with.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_with.snap @@ -2,12 +2,4 @@ source: crates/squawk_parser/tests/tests.rs input_file: crates/squawk_parser/tests/data/regression_suite/with.sql --- -ERROR@23242: expected command, found L_PAREN -ERROR@23243: expected SELECT, TABLE, VALUES, INSERT, UPDATE, DELETE, or MERGE statement -ERROR@23243: expected R_PAREN -ERROR@23243: expected DELETE, SELECT, TABLE, UPDATE, VALUES, or MERGE, got: WITH_KW -ERROR@23288: expected SEMICOLON -ERROR@23288: expected command, found R_PAREN -ERROR@23292: expected command, found UNION_KW -ERROR@23308: expected SEMICOLON -ERROR@23308: expected command, found R_PAREN + diff --git a/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap b/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap index 1db11172..9c69fdcc 100644 --- a/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap +++ b/crates/squawk_parser/tests/snapshots/tests__regression_xml.snap @@ -89,7 +89,8 @@ ERROR@19874: expected PASSING_KW ERROR@19901: expected SEMICOLON ERROR@19902: expected command, found AS_KW ERROR@19905: expected command, found IDENT -ERROR@19907: expected command, found L_PAREN +ERROR@19908: expected R_PAREN +ERROR@19908: expected SEMICOLON ERROR@19908: expected command, found IDENT ERROR@19910: expected command, found COMMA ERROR@19912: expected command, found IDENT @@ -98,7 +99,8 @@ ERROR@19956: expected PASSING_KW ERROR@20003: expected SEMICOLON ERROR@20004: expected command, found AS_KW ERROR@20007: expected command, found IDENT -ERROR@20009: expected command, found L_PAREN +ERROR@20010: expected R_PAREN +ERROR@20010: expected SEMICOLON ERROR@20010: expected command, found IDENT ERROR@20012: expected command, found R_PAREN ERROR@20095: expected an expression, found COMMA @@ -370,7 +372,8 @@ ERROR@31566: expected R_PAREN ERROR@31566: expected SEMICOLON ERROR@31567: expected command, found DEFAULT_KW ERROR@31575: expected command, found IDENT -ERROR@31580: expected command, found L_PAREN +ERROR@31581: expected R_PAREN +ERROR@31581: expected SEMICOLON ERROR@31581: expected command, found IDENT ERROR@31586: expected command, found R_PAREN ERROR@31588: expected command, found MINUS diff --git a/crates/squawk_parser/tests/snapshots/tests__select_funcs_ok.snap b/crates/squawk_parser/tests/snapshots/tests__select_funcs_ok.snap index 0d3c8652..520e3ee1 100644 --- a/crates/squawk_parser/tests/snapshots/tests__select_funcs_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__select_funcs_ok.snap @@ -3809,4 +3809,60 @@ SOURCE_FILE NAME_REF IDENT "t" SEMICOLON ";" + WHITESPACE "\n\n" + COMMENT "-- window clause" + WHITESPACE "\n" + SELECT + SELECT_CLAUSE + SELECT_KW "select" + WHITESPACE " " + TARGET_LIST + TARGET + STAR "*" + WHITESPACE " " + FROM_CLAUSE + FROM_KW "from" + WHITESPACE " " + FROM_ITEM + NAME_REF + IDENT "t" + WHITESPACE " " + WINDOW_CLAUSE + WINDOW_KW "window" + WHITESPACE " " + NAME + OWNER_KW "owner" + WHITESPACE " " + AS_KW "as" + WHITESPACE " " + L_PAREN "(" + WINDOW_DEF + ORDER_BY_CLAUSE + ORDER_KW "order" + WHITESPACE " " + BY_KW "by" + WHITESPACE " " + NAME_REF + IDENT "a" + R_PAREN ")" + COMMA "," + WHITESPACE " " + NAME + IDENT "w2" + WHITESPACE " " + AS_KW "as" + WHITESPACE " " + L_PAREN "(" + WINDOW_DEF + ORDER_BY_CLAUSE + ORDER_KW "order" + WHITESPACE " " + BY_KW "by" + WHITESPACE " " + NAME_REF + IDENT "b" + R_PAREN ")" + SEMICOLON ";" + WHITESPACE "\n" + COMMENT "-- ^^^^^ make sure we allow using keywords" WHITESPACE "\n" diff --git a/crates/squawk_parser/tests/snapshots/tests__select_funcs_pg17_ok.snap b/crates/squawk_parser/tests/snapshots/tests__select_funcs_pg17_ok.snap index 2c4b2532..77dbe624 100644 --- a/crates/squawk_parser/tests/snapshots/tests__select_funcs_pg17_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__select_funcs_pg17_ok.snap @@ -44,65 +44,71 @@ SOURCE_FILE WHITESPACE " " L_PAREN "(" WHITESPACE "\n " - NAME - IDENT "id" - WHITESPACE " " - FOR_KW "FOR" - WHITESPACE " " - ORDINALITY_KW "ORDINALITY" + JSON_TABLE_COLUMN + NAME + IDENT "id" + WHITESPACE " " + FOR_KW "FOR" + WHITESPACE " " + ORDINALITY_KW "ORDINALITY" COMMA "," WHITESPACE "\n " - NAME - IDENT "kind" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.kind'" + JSON_TABLE_COLUMN + NAME + IDENT "kind" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.kind'" COMMA "," WHITESPACE "\n " - NAME - IDENT "title" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.films[*].title'" - WHITESPACE " " - WITH_KW "WITH" - WHITESPACE " " - WRAPPER_KW "WRAPPER" + JSON_TABLE_COLUMN + NAME + IDENT "title" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.films[*].title'" + WHITESPACE " " + JSON_WRAPPER_BEHAVIOR_CLAUSE + WITH_KW "WITH" + WHITESPACE " " + WRAPPER_KW "WRAPPER" COMMA "," WHITESPACE "\n " - NAME - IDENT "director" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.films[*].director'" - WHITESPACE " " - WITH_KW "WITH" - WHITESPACE " " - WRAPPER_KW "WRAPPER" + JSON_TABLE_COLUMN + NAME + IDENT "director" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.films[*].director'" + WHITESPACE " " + JSON_WRAPPER_BEHAVIOR_CLAUSE + WITH_KW "WITH" + WHITESPACE " " + WRAPPER_KW "WRAPPER" R_PAREN ")" R_PAREN ")" WHITESPACE " " @@ -150,96 +156,104 @@ SOURCE_FILE LITERAL STRING "'$.favorites[*] ? (@.films[*].director == $filter)'" WHITESPACE "\n " - PASSING_KW "PASSING" - WHITESPACE " " - LITERAL - STRING "'Alfred Hitchcock'" - WHITESPACE " " - AS_KW "AS" - WHITESPACE " " - NAME - FILTER_KW "filter" + JSON_PASSING_CLAUSE + PASSING_KW "PASSING" + WHITESPACE " " + LITERAL + STRING "'Alfred Hitchcock'" + WHITESPACE " " + AS_KW "AS" + WHITESPACE " " + NAME + FILTER_KW "filter" WHITESPACE "\n " COLUMNS_KW "COLUMNS" WHITESPACE " " L_PAREN "(" WHITESPACE "\n " - NAME - IDENT "id" - WHITESPACE " " - FOR_KW "FOR" - WHITESPACE " " - ORDINALITY_KW "ORDINALITY" + JSON_TABLE_COLUMN + NAME + IDENT "id" + WHITESPACE " " + FOR_KW "FOR" + WHITESPACE " " + ORDINALITY_KW "ORDINALITY" COMMA "," WHITESPACE "\n " - NAME - IDENT "kind" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.kind'" + JSON_TABLE_COLUMN + NAME + IDENT "kind" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.kind'" COMMA "," WHITESPACE "\n " - NESTED_KW "NESTED" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.films[*]'" - WHITESPACE " " - COLUMNS_KW "COLUMNS" - WHITESPACE " " - L_PAREN "(" - WHITESPACE "\n " - NAME - IDENT "title" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - JSON_FORMAT_CLAUSE - FORMAT_KW "FORMAT" + JSON_TABLE_COLUMN + NESTED_KW "NESTED" WHITESPACE " " - JSON_KW "JSON" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.title'" - WHITESPACE " " - OMIT_KW "OMIT" - WHITESPACE " " - QUOTES_KW "QUOTES" - COMMA "," - WHITESPACE "\n " - NAME - IDENT "director" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.director'" - WHITESPACE " " - KEEP_KW "KEEP" - WHITESPACE " " - QUOTES_KW "QUOTES" - R_PAREN ")" + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.films[*]'" + WHITESPACE " " + COLUMNS_KW "COLUMNS" + WHITESPACE " " + L_PAREN "(" + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "title" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + JSON_FORMAT_CLAUSE + FORMAT_KW "FORMAT" + WHITESPACE " " + JSON_KW "JSON" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.title'" + WHITESPACE " " + JSON_QUOTES_CLAUSE + OMIT_KW "OMIT" + WHITESPACE " " + QUOTES_KW "QUOTES" + COMMA "," + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "director" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.director'" + WHITESPACE " " + JSON_QUOTES_CLAUSE + KEEP_KW "KEEP" + WHITESPACE " " + QUOTES_KW "QUOTES" + R_PAREN ")" R_PAREN ")" R_PAREN ")" WHITESPACE " " @@ -291,82 +305,89 @@ SOURCE_FILE WHITESPACE " " L_PAREN "(" WHITESPACE "\n " - NAME - IDENT "id" - WHITESPACE " " - FOR_KW "FOR" - WHITESPACE " " - ORDINALITY_KW "ORDINALITY" + JSON_TABLE_COLUMN + NAME + IDENT "id" + WHITESPACE " " + FOR_KW "FOR" + WHITESPACE " " + ORDINALITY_KW "ORDINALITY" COMMA "," WHITESPACE "\n " - NAME - IDENT "kind" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.kind'" + JSON_TABLE_COLUMN + NAME + IDENT "kind" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.kind'" COMMA "," WHITESPACE "\n " - NESTED_KW "NESTED" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.films[*]'" - WHITESPACE " " - COLUMNS_KW "COLUMNS" - WHITESPACE " " - L_PAREN "(" - WHITESPACE "\n " - NAME - IDENT "title" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - JSON_FORMAT_CLAUSE - FORMAT_KW "FORMAT" + JSON_TABLE_COLUMN + NESTED_KW "NESTED" WHITESPACE " " - JSON_KW "JSON" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.title'" - WHITESPACE " " - OMIT_KW "OMIT" - WHITESPACE " " - QUOTES_KW "QUOTES" - COMMA "," - WHITESPACE "\n " - NAME - IDENT "director" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.director'" - WHITESPACE " " - KEEP_KW "KEEP" - WHITESPACE " " - QUOTES_KW "QUOTES" - R_PAREN ")" + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.films[*]'" + WHITESPACE " " + COLUMNS_KW "COLUMNS" + WHITESPACE " " + L_PAREN "(" + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "title" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + JSON_FORMAT_CLAUSE + FORMAT_KW "FORMAT" + WHITESPACE " " + JSON_KW "JSON" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.title'" + WHITESPACE " " + JSON_QUOTES_CLAUSE + OMIT_KW "OMIT" + WHITESPACE " " + QUOTES_KW "QUOTES" + COMMA "," + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "director" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.director'" + WHITESPACE " " + JSON_QUOTES_CLAUSE + KEEP_KW "KEEP" + WHITESPACE " " + QUOTES_KW "QUOTES" + R_PAREN ")" R_PAREN ")" R_PAREN ")" WHITESPACE " " @@ -415,121 +436,132 @@ SOURCE_FILE WHITESPACE " " L_PAREN "(" WHITESPACE "\n " - NAME - IDENT "user_id" - WHITESPACE " " - FOR_KW "FOR" - WHITESPACE " " - ORDINALITY_KW "ORDINALITY" + JSON_TABLE_COLUMN + NAME + IDENT "user_id" + WHITESPACE " " + FOR_KW "FOR" + WHITESPACE " " + ORDINALITY_KW "ORDINALITY" COMMA "," WHITESPACE "\n " - NESTED_KW "NESTED" - WHITESPACE " " - LITERAL - STRING "'$.movies[*]'" - WHITESPACE "\n " - COLUMNS_KW "COLUMNS" - WHITESPACE " " - L_PAREN "(" - WHITESPACE "\n " - NAME - IDENT "movie_id" - WHITESPACE " " - FOR_KW "FOR" - WHITESPACE " " - ORDINALITY_KW "ORDINALITY" - COMMA "," - WHITESPACE "\n " - NAME - IDENT "mname" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.name'" - COMMA "," - WHITESPACE "\n " - NAME - IDENT "director" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - R_PAREN ")" + JSON_TABLE_COLUMN + NESTED_KW "NESTED" + WHITESPACE " " + LITERAL + STRING "'$.movies[*]'" + WHITESPACE "\n " + COLUMNS_KW "COLUMNS" + WHITESPACE " " + L_PAREN "(" + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "movie_id" + WHITESPACE " " + FOR_KW "FOR" + WHITESPACE " " + ORDINALITY_KW "ORDINALITY" + COMMA "," + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "mname" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.name'" + COMMA "," + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "director" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + R_PAREN ")" COMMA "," WHITESPACE "\n " - NESTED_KW "NESTED" - WHITESPACE " " - LITERAL - STRING "'$.books[*]'" - WHITESPACE "\n " - COLUMNS_KW "COLUMNS" - WHITESPACE " " - L_PAREN "(" - WHITESPACE "\n " - NAME - IDENT "book_id" - WHITESPACE " " - FOR_KW "FOR" - WHITESPACE " " - ORDINALITY_KW "ORDINALITY" - COMMA "," - WHITESPACE "\n " - NAME - IDENT "bname" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.name'" - COMMA "," - WHITESPACE "\n " - NESTED_KW "NESTED" - WHITESPACE " " - LITERAL - STRING "'$.authors[*]'" - WHITESPACE "\n " - COLUMNS_KW "COLUMNS" - WHITESPACE " " - L_PAREN "(" - WHITESPACE "\n " - NAME - IDENT "author_id" - WHITESPACE " " - FOR_KW "FOR" - WHITESPACE " " - ORDINALITY_KW "ORDINALITY" - COMMA "," - WHITESPACE "\n " - NAME - IDENT "author_name" - WHITESPACE " " - PATH_TYPE - PATH - PATH_SEGMENT - NAME_REF - TEXT_KW "text" - WHITESPACE " " - PATH_KW "PATH" - WHITESPACE " " - LITERAL - STRING "'$.name'" - R_PAREN ")" - R_PAREN ")" + JSON_TABLE_COLUMN + NESTED_KW "NESTED" + WHITESPACE " " + LITERAL + STRING "'$.books[*]'" + WHITESPACE "\n " + COLUMNS_KW "COLUMNS" + WHITESPACE " " + L_PAREN "(" + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "book_id" + WHITESPACE " " + FOR_KW "FOR" + WHITESPACE " " + ORDINALITY_KW "ORDINALITY" + COMMA "," + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "bname" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.name'" + COMMA "," + WHITESPACE "\n " + JSON_TABLE_COLUMN + NESTED_KW "NESTED" + WHITESPACE " " + LITERAL + STRING "'$.authors[*]'" + WHITESPACE "\n " + COLUMNS_KW "COLUMNS" + WHITESPACE " " + L_PAREN "(" + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "author_id" + WHITESPACE " " + FOR_KW "FOR" + WHITESPACE " " + ORDINALITY_KW "ORDINALITY" + COMMA "," + WHITESPACE "\n " + JSON_TABLE_COLUMN + NAME + IDENT "author_name" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + TEXT_KW "text" + WHITESPACE " " + PATH_KW "PATH" + WHITESPACE " " + LITERAL + STRING "'$.name'" + R_PAREN ")" + R_PAREN ")" R_PAREN ")" R_PAREN ")" SEMICOLON ";" diff --git a/crates/squawk_parser/tests/snapshots/tests__select_ok.snap b/crates/squawk_parser/tests/snapshots/tests__select_ok.snap index 6265d6f9..459e3710 100644 --- a/crates/squawk_parser/tests/snapshots/tests__select_ok.snap +++ b/crates/squawk_parser/tests/snapshots/tests__select_ok.snap @@ -3486,7 +3486,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3508,7 +3509,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3538,7 +3540,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3565,7 +3568,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3592,7 +3596,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3621,7 +3626,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3654,7 +3660,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3685,7 +3692,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3716,7 +3724,8 @@ SOURCE_FILE WINDOW_CLAUSE WINDOW_KW "window" WHITESPACE " " - IDENT "w" + NAME + IDENT "w" WHITESPACE " " AS_KW "as" WHITESPACE " " @@ -3775,9 +3784,10 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - TUPLE_EXPR - L_PAREN "(" - R_PAREN ")" + GROUPING_EXPR + TUPLE_EXPR + L_PAREN "(" + R_PAREN ")" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- simple expr" @@ -3796,8 +3806,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- multi expr" @@ -3821,12 +3832,14 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" COMMA "," WHITESPACE " " - LITERAL - INT_NUMBER "2" + GROUPING_EXPR + LITERAL + INT_NUMBER "2" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- all" @@ -3847,8 +3860,9 @@ SOURCE_FILE WHITESPACE " " ALL_KW "all" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- distinct" @@ -3869,8 +3883,9 @@ SOURCE_FILE WHITESPACE " " DISTINCT_KW "distinct" WHITESPACE " " - LITERAL - INT_NUMBER "1" + GROUPING_EXPR + LITERAL + INT_NUMBER "1" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- rollup" @@ -3889,9 +3904,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - ROLLUP_KW "rollup" - WHITESPACE " " - TUPLE_EXPR + GROUPING_ROLLUP + ROLLUP_KW "rollup" + WHITESPACE " " L_PAREN "(" LITERAL INT_NUMBER "1" @@ -3918,9 +3933,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - ROLLUP_KW "rollup" - WHITESPACE " " - TUPLE_EXPR + GROUPING_ROLLUP + ROLLUP_KW "rollup" + WHITESPACE " " L_PAREN "(" LITERAL INT_NUMBER "1" @@ -3931,9 +3946,9 @@ SOURCE_FILE R_PAREN ")" COMMA "," WHITESPACE " " - ROLLUP_KW "rollup" - WHITESPACE " " - PAREN_EXPR + GROUPING_ROLLUP + ROLLUP_KW "rollup" + WHITESPACE " " L_PAREN "(" LITERAL INT_NUMBER "3" @@ -3958,9 +3973,9 @@ SOURCE_FILE WHITESPACE " " DISTINCT_KW "distinct" WHITESPACE " " - CUBE_KW "cube" - WHITESPACE " " - TUPLE_EXPR + GROUPING_CUBE + CUBE_KW "cube" + WHITESPACE " " L_PAREN "(" LITERAL INT_NUMBER "1" @@ -3991,49 +4006,53 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - GROUPING_KW "grouping" - WHITESPACE " " - SETS_KW "sets" - WHITESPACE " " - TUPLE_EXPR + GROUPING_SETS + GROUPING_KW "grouping" + WHITESPACE " " + SETS_KW "sets" + WHITESPACE " " L_PAREN "(" WHITESPACE "\n " - TUPLE_EXPR - L_PAREN "(" - LITERAL - INT_NUMBER "1" - COMMA "," - WHITESPACE " " - LITERAL - INT_NUMBER "2" - COMMA "," - WHITESPACE " " - LITERAL - INT_NUMBER "3" - R_PAREN ")" + GROUPING_EXPR + TUPLE_EXPR + L_PAREN "(" + LITERAL + INT_NUMBER "1" + COMMA "," + WHITESPACE " " + LITERAL + INT_NUMBER "2" + COMMA "," + WHITESPACE " " + LITERAL + INT_NUMBER "3" + R_PAREN ")" COMMA "," WHITESPACE "\n " - TUPLE_EXPR - L_PAREN "(" - LITERAL - INT_NUMBER "1" - COMMA "," - WHITESPACE " " - LITERAL - INT_NUMBER "2" - R_PAREN ")" + GROUPING_EXPR + TUPLE_EXPR + L_PAREN "(" + LITERAL + INT_NUMBER "1" + COMMA "," + WHITESPACE " " + LITERAL + INT_NUMBER "2" + R_PAREN ")" COMMA "," WHITESPACE "\n " - PAREN_EXPR - L_PAREN "(" - LITERAL - INT_NUMBER "1" - R_PAREN ")" + GROUPING_EXPR + PAREN_EXPR + L_PAREN "(" + LITERAL + INT_NUMBER "1" + R_PAREN ")" COMMA "," WHITESPACE "\n " - TUPLE_EXPR - L_PAREN "(" - R_PAREN ")" + GROUPING_EXPR + TUPLE_EXPR + L_PAREN "(" + R_PAREN ")" WHITESPACE "\n" R_PAREN ")" SEMICOLON ";" @@ -4725,8 +4744,9 @@ SOURCE_FILE WHITESPACE " " BY_KW "by" WHITESPACE " " - NAME_REF - IDENT "f1" + GROUPING_EXPR + NAME_REF + IDENT "f1" SEMICOLON ";" WHITESPACE "\n\n" COMMENT "-- using w/ join alias" @@ -5930,22 +5950,24 @@ SOURCE_FILE WHITESPACE " " BY_KW "BY" WHITESPACE " " - NAME_REF - IDENT "sensor_id" + GROUPING_EXPR + NAME_REF + IDENT "sensor_id" COMMA "," WHITESPACE " " - CALL_EXPR - NAME_REF - IDENT "DATE_TRUNC" - ARG_LIST - L_PAREN "(" - LITERAL - STRING "'day'" - COMMA "," - WHITESPACE " " + GROUPING_EXPR + CALL_EXPR NAME_REF - IDENT "ts" - R_PAREN ")" + IDENT "DATE_TRUNC" + ARG_LIST + L_PAREN "(" + LITERAL + STRING "'day'" + COMMA "," + WHITESPACE " " + NAME_REF + IDENT "ts" + R_PAREN ")" WHITESPACE "\n" ORDER_BY_CLAUSE ORDER_KW "ORDER" diff --git a/crates/squawk_syntax/src/ast/generated/nodes.rs b/crates/squawk_syntax/src/ast/generated/nodes.rs index 5c460655..6ebc9a0c 100644 --- a/crates/squawk_syntax/src/ast/generated/nodes.rs +++ b/crates/squawk_syntax/src/ast/generated/nodes.rs @@ -4679,12 +4679,108 @@ pub struct GroupByClause { pub(crate) syntax: SyntaxNode, } impl GroupByClause { + #[inline] + pub fn grouping_cube(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn grouping_expr(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn grouping_rollup(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn grouping_sets(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn all_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::ALL_KW) + } + #[inline] + pub fn by_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::BY_KW) + } + #[inline] + pub fn distinct_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::DISTINCT_KW) + } #[inline] pub fn group_token(&self) -> Option { support::token(&self.syntax, SyntaxKind::GROUP_KW) } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct GroupingCube { + pub(crate) syntax: SyntaxNode, +} +impl GroupingCube { + #[inline] + pub fn expr(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn cube_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::CUBE_KW) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct GroupingExpr { + pub(crate) syntax: SyntaxNode, +} +impl GroupingExpr { + #[inline] + pub fn expr(&self) -> Option { + support::child(&self.syntax) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct GroupingRollup { + pub(crate) syntax: SyntaxNode, +} +impl GroupingRollup { + #[inline] + pub fn expr(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn rollup_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::ROLLUP_KW) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct GroupingSets { + pub(crate) syntax: SyntaxNode, +} +impl GroupingSets { + #[inline] + pub fn expr(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn l_paren_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::L_PAREN) + } + #[inline] + pub fn r_paren_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::R_PAREN) + } + #[inline] + pub fn grouping_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::GROUPING_KW) + } + #[inline] + pub fn sets_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::SETS_KW) + } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Gteq { pub(crate) syntax: SyntaxNode, @@ -5483,6 +5579,41 @@ impl JsonReturningClause { } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct JsonTableColumn { + pub(crate) syntax: SyntaxNode, +} +impl JsonTableColumn { + #[inline] + pub fn expr(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn name(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn ty(&self) -> Option { + support::child(&self.syntax) + } + #[inline] + pub fn for_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::FOR_KW) + } + #[inline] + pub fn nested_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::NESTED_KW) + } + #[inline] + pub fn ordinality_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::ORDINALITY_KW) + } + #[inline] + pub fn path_token(&self) -> Option { + support::token(&self.syntax, SyntaxKind::PATH_KW) + } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct JsonValueExpr { pub(crate) syntax: SyntaxNode, @@ -12863,6 +12994,78 @@ impl AstNode for GroupByClause { &self.syntax } } +impl AstNode for GroupingCube { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::GROUPING_CUBE + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} +impl AstNode for GroupingExpr { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::GROUPING_EXPR + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} +impl AstNode for GroupingRollup { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::GROUPING_ROLLUP + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} +impl AstNode for GroupingSets { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::GROUPING_SETS + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} impl AstNode for Gteq { #[inline] fn can_cast(kind: SyntaxKind) -> bool { @@ -13547,6 +13750,24 @@ impl AstNode for JsonReturningClause { &self.syntax } } +impl AstNode for JsonTableColumn { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == SyntaxKind::JSON_TABLE_COLUMN + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } +} impl AstNode for JsonValueExpr { #[inline] fn can_cast(kind: SyntaxKind) -> bool { diff --git a/crates/squawk_syntax/src/postgresql.ungram b/crates/squawk_syntax/src/postgresql.ungram index 7aa36402..97cb6d77 100644 --- a/crates/squawk_syntax/src/postgresql.ungram +++ b/crates/squawk_syntax/src/postgresql.ungram @@ -481,7 +481,19 @@ WhereClause = 'where' GroupByClause = - 'group' + 'group' 'by' ('all' | 'distinct') (GroupingRollup | GroupingCube | GroupingSets | GroupingExpr) + +GroupingRollup = + 'rollup' Expr + +GroupingSets = + 'grouping' 'sets' '(' Expr ')' + +GroupingCube = + 'cube' Expr + +GroupingExpr = + Expr HavingClause = 'having' @@ -830,6 +842,10 @@ IndexExpr = BetweenExpr = target:Expr 'between' (start:Expr) 'and' (end:Expr) +JsonTableColumn = + Name 'for' 'ordinality' +| Name Type +| 'nested' 'path'? Expr JsonReturningClause = 'returning' Type