-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathselect.sql
More file actions
116 lines (86 loc) · 2.09 KB
/
select.sql
File metadata and controls
116 lines (86 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
--- via https://duckdb.org/docs/stable/sql/dialect/friendly_sql.html#trailing-commas
select
42 as x,
array['a', 'b', 'c',] as y,
'hello world' as z,
;
-- trailing comma in column list
select * from t as u(a,);
-- missing comma
select a, b c d, e from t;
-- ^ ^ comma missing
-- \-- this is a label
-- distinct on missing a comma
SELECT DISTINCT ON (a b) a, b, c
FROM t
order by a, b desc;
-- group bys with missing commas
select * from t group by rollup (1 2 3);
select * from t group by cube (1 2 3);
select * from u
group by grouping sets((1 2) grouping sets((), grouping sets(())));
-- trailing comma in args
select f(1,);
-- missing args
select f(a,,,,,);
-- in can only be used with tuples / sub queries
select 1 in c;
-- type cast must use a string literal
select numeric 1234;
-- missing comma
select array[1 2,3];
-- extra comma
select array[1, ,3];
-- trailing comma
select array[1,2,3,];
-- group by all, order by all
select * from t group by all order by all;
-- cast with malformed type mod args
select cast(x as varchar(100 200));
select cast(x as varchar(100, , 200));
select cast(x as t(a, b,));
-- regression test: this would cause the parser to get stuck & panic, now it
-- warns about a missing semicolon
select select;
-- extra comma
select a, from t;
-- case missing then expr
select case when 1 then end;
-- case missing when expr
select case when then x end;
-- case missing else expr
select case when 1 then 2 else end;
-- select without semi and trailing create table
select
create table users ();
-- select do
select
do 'begin null; end';
-- select grant
select
grant select on t to u;
-- where with missing expr
select from t where and c > 10;
select from t where or c != 'b';
select having and c > 10;
select having or c != 'b';
select from t join u on and true;
select from t join u on or true;
-- join after the where
select * from t
where x > 1
join k on true;
-- select end
select
end;
-- select analyze/analyse
select
analyze;
select
analyse;
-- select with
select
with t as (select 1)
select * from t;
-- trailing comma at EOF
select 1,