lava-oushudb-dt-sql-parser/test/parser/trinosql/syntax/fixtures/select_with_ unnest.sql
mumiao 9c82a5d248
feat: support trino(presto) sql language (#105)
* feat(trino): intergrate prestoGrammar to dt-sql-parser

* feat(trino): add trinoSQl test framework

* feat(trino): intergrate test files for trinoSQL

* test(trino): support alterStatement test

* test(trino): support alter table set authorization statement

* feat(trino): complete trinosql alter unit tests

* test(trino): complete dropStatement unit cases for trinosql

* test(trino): complete create statement unit cases for trinoSQL

* test(trino): complete insertStatement unit cases for trinoSQl

* test(trino): dropStatement test files changed to short line split

* test(trino): complete selectStatement unit cases and grammar check

* test(trino): complete commentStatement unit case for trinoSQL

* test(trino): complete analyze commit and call clause unit case

* test(trino): complete delete deny and describe statement unit case

* test(trino): complete explain execute and grant statement unit case

* feat(trino): improve GRANT Role grammar

* test(trino): complete show statement unit case

* test(trino): complete truncateTable startTransaction update and values  statement unit case

* test(trino): improve update statement test cases

* test(trino): complete revoke revoke roles  and rollback statement unit case

* test(trino): add set statement test case

* feat: generator new trino parser and lexer file

* feat(trino): improve alter statement grammar

* test(trino): complete alter statement unit cases

* feat(trino): support case-insensitive lexers

* fix(trino): rm unless gen files

* test(trino): complete merge and reset session statement unit cases

* test(trino): complete merge anduse statement unit cases

* test(trino): complete prepare and refresh materialized view statement unit cases

* test(trino): improve statement unit cases

* test(trino): complete match recognize statement unit cases

* test(trino): complete window with row pattern recognition statement unit cases
2023-05-24 15:07:02 +08:00

57 lines
1.3 KiB
SQL

SELECT * FROM UNNEST(ARRAY[1,2]) AS t(number);
SELECT * FROM UNNEST(
map_from_entries(
ARRAY[
('SQL',1974),
('Java', 1995)
]
)
) AS t(language, first_appeared_year);
SELECT *
FROM UNNEST(
ARRAY[
ROW('Java', 1995),
ROW('SQL' , 1974)],
ARRAY[
ROW(false),
ROW(true)]
) as t(language,first_appeared_year,declarative);
SELECT a, b, rownumber
FROM UNNEST (
ARRAY[2, 5],
ARRAY[7, 8, 9]
) WITH ORDINALITY AS t(a, b, rownumber);
SELECT * FROM UNNEST (ARRAY[]) AS t(value);
SELECT * FROM UNNEST (CAST(null AS ARRAY(integer))) AS t(number);
SELECT student, score
FROM (
VALUES
('John', ARRAY[7, 10, 9]),
('Mary', ARRAY[4, 8, 9])
) AS tests (student, scores)
CROSS JOIN UNNEST(scores) AS t(score);
SELECT numbers, animals, n, a
FROM (
VALUES
(ARRAY[2, 5], ARRAY['dog', 'cat', 'bird']),
(ARRAY[7, 8, 9], ARRAY['cow', 'pig'])
) AS x (numbers, animals)
CROSS JOIN UNNEST(numbers, animals) AS t (n, a);
SELECT runner, checkpoint
FROM (
VALUES
('Joe', ARRAY[10, 20, 30, 42]),
('Roger', ARRAY[10]),
('Dave', ARRAY[]),
('Levi', NULL)
) AS marathon (runner, checkpoints)
LEFT JOIN UNNEST(checkpoints) AS t(checkpoint) ON TRUE;