Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions expected_output/core.sql
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,34 @@ WINDOW
named_window2 AS (PARTITION BY str ORDER BY int)
;

----- chained function call -----
SELECT (col).UPPER().LOWER();

SELECT
TIMESTAMP '2024-01-01'.TIMESTAMP_TRUNC(month),
CASE WHEN TRUE THEN TIMESTAMP '2024-01-01' END.TIMESTAMP_TRUNC(month),
;

SELECT (col).(safe.left)(3);

SELECT STRUCT('a' AS b).TO_JSON().b.JSON_VALUE().CONCAT('c');

SELECT
"foo"
.longfunctionname()
.longfunctionname()
.longfunctionname()
.longfunctionname()
-- comment
.longfunctionname()
.longfunctionname()
.longfunctionname()
.longfunctionname()
.longfunctionname(),
;

----- with expression -----
SELECT WITH(a AS 'a', UPPER(a));

----- template -----
SELECT {{variable}}, {variable};
18 changes: 18 additions & 0 deletions expected_output/ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ WITH CONNECTION ident
OPTIONS (dummy = 'dummy')
;

CREATE EXTERNAL TABLE tablename
WITH CONNECTION DEFAULT
OPTIONS (dummy = 'dummy')
;

----- CREATE VIEW statement -----
CREATE VIEW view_name AS SELECT * FROM t;

Expand Down Expand Up @@ -180,6 +185,10 @@ AS
SELECT 1 AS one
;

CREATE TABLE FUNCTION foo.bar(tablename TABLE<col1 INT64, col2 FLOAT64>)
AS (SELECT 1)
;

-- remote function
CREATE FUNCTION dataset.abc()
RETURNS INT64
Expand Down Expand Up @@ -247,6 +256,12 @@ STORING (a, b, c)
OPTIONS (dummy = 'dummy')
;

CREATE VECTOR INDEX new_index
ON tablename (col)
PARTITION BY foo
OPTIONS (dummy = 'dummy')
;

----- ALTER BI_CAPACITY statement -----
ALTER BI_CAPACITY `project.region-us.default`
SET OPTIONS (preferred_tables = ['table1', 'table2'])
Expand Down Expand Up @@ -375,6 +390,9 @@ ALTER VIEW viewname ALTER COLUMN colname SET OPTIONS (dummy = 'dummy');
-- MATERIALIZED
ALTER MATERIALIZED VIEW IF EXISTS example SET OPTIONS (dummy = 'dummy');

----- ALTER VECTOR INDEX statement -----
ALTER VECTOR INDEX index_name ON table_name REBUILD;

----- DROP statement -----
-- general
DROP TABLE example;
Expand Down
2 changes: 2 additions & 0 deletions expected_output/ml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ OPTIONS (endpoint = '')
AS (SELECT 1)
;

CREATE MODEL ident REMOTE WITH CONNECTION DEFAULT OPTIONS (endpoint = '');

CREATE MODEL ident
AS (
training_data AS (SELECT 1),
Expand Down
47 changes: 47 additions & 0 deletions expected_output/pipe.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ FROM table
SELECT col
;

WITH t AS (SELECT 1)
FROM t
;

SELECT *
FROM (
FROM t
|> SELECT *
)
;

----- select statement -----
SELECT 1
|> SELECT *
Expand All @@ -36,6 +47,13 @@ SELECT 2
|> SELECT *
;

FROM t
|>
SELECT col
-- break parent
WINDOW a AS (PARTITION BY b)
;

----- from statement -----
FROM tabe AS t1
INNER JOIN table AS p2 USING(col)
Expand Down Expand Up @@ -107,6 +125,11 @@ FROM t
col2
;

----- distinct pipe operator -----
FROM t
|> DISTINCT
;

----- union pipe operator -----
FROM t
|> UNION ALL (SELECT 1), (SELECT 2)
Expand Down Expand Up @@ -171,3 +194,27 @@ FROM t
FROM t
|> unpivot INCLUDE NULLS (sales FOR quarter IN (q1, q2)) AS q
;

----- match recognize pipe operator -----
FROM t
|>
MATCH_RECOGNIZE (
ORDER BY col1
PATTERN (symbol)
)
;

----- with pipe operator -----
FROM t
|> WITH u AS (SELECT 1 AS key)
|> INNER JOIN u USING(key)
;

FROM t
|>
WITH
-- CTE
u AS (SELECT 1 AS key),
v AS (SELECT 2 AS key),
|> INNER JOIN u USING(key)
;
53 changes: 53 additions & 0 deletions expected_output/select.sql
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,59 @@ FROM
) AS unpivot
;

-- MATCH_RECOGNIZE
SELECT *
FROM
t MATCH_RECOGNIZE (
PARTITION BY col1, col2
ORDER BY col3, col4 DESC NULLS FIRST
MEASURES ANY_VALUE(col4) AS col4
AFTER MATCH SKIP TO NEXT ROW
PATTERN (symbol1)
DEFINE
symbol1 AS col3 = 'foo',
symbol2 AS col4 = 'bar'
OPTIONS (use_longest_match = TRUE)
) AS u
;

SELECT *
FROM
t MATCH_RECOGNIZE (
ORDER BY col1
PATTERN (^ ()*? symbol1{0}{1,2}{,3} $)
)
;

SELECT *
FROM
t MATCH_RECOGNIZE (
ORDER BY col1
PATTERN (symbol1 | symbol2 symbol3)
)
;

SELECT *
FROM
t MATCH_RECOGNIZE (
ORDER BY col1
PATTERN (
symbol1 symbol2
| symbol3 symbol4
-- comment
| symbol5 symbol6
)
)
;

SELECT *
FROM
t MATCH_RECOGNIZE (
ORDER BY col1
PATTERN ((symbol1 | ) ( | symbol2))
)
;

-- TABLESAMPLE
SELECT * FROM t TABLESAMPLE SYSTEM (20 PERCENT);

Expand Down
20 changes: 20 additions & 0 deletions input/core.sql
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,25 @@ window
named_window2 as (partition by str order by int)
;

----- chained function call -----
select (col).upper().lower();

select
timestamp '2024-01-01'.timestamp_trunc(month),
case when true then timestamp '2024-01-01' end.timestamp_trunc(month),
;

select (col).(safe.left)(3);

select struct('a' as b).to_json().b.json_value().concat('c');

select "foo"
.longfunctionname().longfunctionname().longfunctionname().longfunctionname()
-- comment
.longfunctionname().longfunctionname().longfunctionname().longfunctionname().longfunctionname();

----- with expression -----
select with(a as 'a', upper(a));

----- template -----
select {{variable}}, {variable};
19 changes: 19 additions & 0 deletions input/ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ create external table dataset.new_table
with connection ident
options (dummy = 'dummy');

create external table tablename
with connection default
options (dummy = 'dummy');

----- CREATE VIEW statement -----
create view view_name
as
Expand Down Expand Up @@ -182,6 +186,12 @@ as
select 1 as one
;

create table function foo.bar (
tablename table<col1 int64, col2 float64>
) as (
select 1
);

-- remote function
create function dataset.abc()
returns int64
Expand Down Expand Up @@ -245,6 +255,12 @@ storing (a, b, c)
options (dummy = 'dummy')
;

create vector index new_index
on tablename(col)
partition by foo
options(dummy='dummy')
;

----- ALTER BI_CAPACITY statement -----
alter bi_capacity `project.region-us.default`
set options(preferred_tables = ['table1', 'table2']);
Expand Down Expand Up @@ -372,6 +388,9 @@ alter column colname set options(dummy='dummy')
-- MATERIALIZED
alter materialized view if exists example set options (dummy = 'dummy');

----- ALTER VECTOR INDEX statement -----
alter vector index index_name on table_name rebuild;

----- DROP statement -----
-- general
drop table example;
Expand Down
5 changes: 5 additions & 0 deletions input/ml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ options (endpoint = '')
as (select 1)
;

create model ident
remote with connection default
options (endpoint = '')
;

create model ident
as (
training_data as (select 1),
Expand Down
39 changes: 39 additions & 0 deletions input/pipe.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ from table
-- comment before select
select col;

with t as (select 1) from t;

select * from (from t |> select *);

----- select statement -----
select 1 |> select *;

Expand All @@ -20,6 +24,12 @@ select 1 union all select 2 |> select *;

(select 1) order by 1 limit 1 |> SELECT *;

from t |>
select col
-- break parent
window a as (partition by b)
;

----- from statement -----
from tabe as t1
join table as p2 using (col);
Expand Down Expand Up @@ -64,6 +74,9 @@ from t
aggregate count(*)
group by col1 as col_a desc nulls last, col2;

----- distinct pipe operator -----
from t |> distinct;

----- union pipe operator -----
from t |> union all (select 1), (select 2);

Expand Down Expand Up @@ -108,3 +121,29 @@ sum(sales) for quarter in ('Q1', 'Q2')) as q;
from t |> unpivot (sales for quarter in (q1, q2)) as q;

from t |> unpivot include nulls (sales for quarter in (q1, q2)) as q;

----- match recognize pipe operator -----
from t |> match_recognize (
order by col1
pattern (symbol)
);

----- with pipe operator -----
from t
|> with u as (
select 1 as key
)
|> inner join u using (key)
;

from t
|> with
-- CTE
u as (
select 1 as key
),
v as (
select 2 as key
),
|> inner join u using (key)
;
Loading