-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathk8s-ddl-function.id
133 lines (96 loc) · 2 KB
/
k8s-ddl-function.id
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
!set outputformat mysql
!use k8s
create or replace view ADS."case" AS SELECT CASE WHEN "FIRST_NAME" = 'Bob' THEN ARRAY['a'] ELSE ARRAY['b'] END || CASE WHEN "FIRST_NAME" = 'Alice' THEN ARRAY['c'] ELSE ARRAY['d'] END AS arr from profile.members;
(0 rows modified)
!update
select * from ADS."case";
+--------+
| ARR |
+--------+
| [b, c] |
| [a, d] |
| [b, d] |
+--------+
(3 rows)
!ok
create or replace view ADS."json" AS SELECT JSON_VALUE('{"a": 1}', '$.a') AS json from profile.members;
(0 rows modified)
!update
select * from ADS."json";
+------+
| JSON |
+------+
| 1 |
| 1 |
| 1 |
+------+
(3 rows)
!ok
create or replace view ADS."regex" AS SELECT REGEXP_REPLACE("FIRST_NAME", '(B)ob', '$1ill') AS name from profile.members;
(0 rows modified)
!update
select * from ads."regex";
+---------+
| NAME |
+---------+
| Alice |
| Bill |
| Charlie |
+---------+
(3 rows)
!ok
create or replace view ADS."concat" AS SELECT CONCAT('_', "FIRST_NAME", '_') AS name from profile.members;
(0 rows modified)
!update
select * from ads."concat";
+-----------+
| NAME |
+-----------+
| _Alice_ |
| _Bob_ |
| _Charlie_ |
+-----------+
(3 rows)
!ok
create or replace view ADS."listagg" AS SELECT LISTAGG("FIRST_NAME") AS agg FROM profile.members;
(0 rows modified)
!update
select * from ads."listagg";
+-------------------+
| AGG |
+-------------------+
| Alice,Bob,Charlie |
+-------------------+
(1 row)
!ok
create or replace view ADS."unnested" AS SELECT * FROM UNNEST(ARRAY(SELECT "FIRST_NAME" FROM profile.members)) AS name;
(0 rows modified)
!update
select * from ADS."unnested";
+---------+
| NAME |
+---------+
| Alice |
| Bob |
| Charlie |
+---------+
(3 rows)
!ok
drop view ads."case";
(0 rows modified)
!update
drop view ads."json";
(0 rows modified)
!update
drop view ads."regex";
(0 rows modified)
!update
drop view ads."concat";
(0 rows modified)
!update
drop view ads."listagg";
(0 rows modified)
!update
drop view ads."unnested";
(0 rows modified)
!update