66class illarg_date_trunc_legal (TstView ):
77 def __init__ (self ):
88 # checked manually
9- self .data = [{' tmestmp' : ' 2020-06-01T00:00:00' , ' datee' : ' 2020-06-01' }]
9+ self .data = [{" tmestmp" : " 2020-06-01T00:00:00" , " datee" : " 2020-06-01" }]
1010 self .sql = """CREATE MATERIALIZED VIEW date_trunc_legal AS SELECT
1111 DATE_TRUNC(tmestmp, MONTH) AS tmestmp,
1212 DATE_TRUNC(datee, MONTH) AS datee
@@ -29,7 +29,24 @@ def __init__(self):
2929class illarg_extract_legal (TstView ):
3030 def __init__ (self ):
3131 # checked manually
32- self .data = [{'yr' : 2020 , 'yr1' : 2020 , 'mth' : 6 , 'mth1' : 6 , 'day' : 21 , 'day1' : 21 , 'dow' : 1 , 'dow1' : 1 , 'hr' : 14 , 'hr1' : 0 , 'min' : 23 , 'min1' : 0 , 'sec' : 44 , 'sec1' : 0 }]
32+ self .data = [
33+ {
34+ "yr" : 2020 ,
35+ "yr1" : 2020 ,
36+ "mth" : 6 ,
37+ "mth1" : 6 ,
38+ "day" : 21 ,
39+ "day1" : 21 ,
40+ "dow" : 1 ,
41+ "dow1" : 1 ,
42+ "hr" : 14 ,
43+ "hr1" : 0 ,
44+ "min" : 23 ,
45+ "min1" : 0 ,
46+ "sec" : 44 ,
47+ "sec1" : 0 ,
48+ }
49+ ]
3350 self .sql = """CREATE MATERIALIZED VIEW extract_legal AS SELECT
3451 EXTRACT(YEAR FROM tmestmp) AS yr,
3552 EXTRACT(YEAR FROM datee) AS yr1,
@@ -64,7 +81,24 @@ def __init__(self):
6481class illarg_extract_abrv_legal (TstView ):
6582 def __init__ (self ):
6683 # checked manually
67- self .data = [{'yr' : 2020 , 'yr1' : 2020 , 'mth' : 6 , 'mth1' : 6 , 'day' : 21 , 'day1' : 21 , 'dow' : 1 , 'dow1' : 1 , 'hr' : 14 , 'hr1' : 0 , 'min' : 23 , 'min1' : 0 , 'sec' : 44 , 'sec1' : 0 }]
84+ self .data = [
85+ {
86+ "yr" : 2020 ,
87+ "yr1" : 2020 ,
88+ "mth" : 6 ,
89+ "mth1" : 6 ,
90+ "day" : 21 ,
91+ "day1" : 21 ,
92+ "dow" : 1 ,
93+ "dow1" : 1 ,
94+ "hr" : 14 ,
95+ "hr1" : 0 ,
96+ "min" : 23 ,
97+ "min1" : 0 ,
98+ "sec" : 44 ,
99+ "sec1" : 0 ,
100+ }
101+ ]
68102 self .sql = """CREATE MATERIALIZED VIEW extract_abrv_legal AS SELECT
69103 YEAR(tmestmp) AS yr,
70104 YEAR(datee) AS yr1,
@@ -87,7 +121,24 @@ def __init__(self):
87121class illarg_extract_abrv1_legal (TstView ):
88122 def __init__ (self ):
89123 # checked manually
90- self .data = [{'yr' : 2020 , 'yr1' : 2020 , 'mth' : 6 , 'mth1' : 6 , 'day' : 21 , 'day1' : 21 , 'dow' : 1 , 'dow1' : 1 , 'hr' : 14 , 'hr1' : 0 , 'min' : 23 , 'min1' : 0 , 'sec' : 44 , 'sec1' : 0 }]
124+ self .data = [
125+ {
126+ "yr" : 2020 ,
127+ "yr1" : 2020 ,
128+ "mth" : 6 ,
129+ "mth1" : 6 ,
130+ "day" : 21 ,
131+ "day1" : 21 ,
132+ "dow" : 1 ,
133+ "dow1" : 1 ,
134+ "hr" : 14 ,
135+ "hr1" : 0 ,
136+ "min" : 23 ,
137+ "min1" : 0 ,
138+ "sec" : 44 ,
139+ "sec1" : 0 ,
140+ }
141+ ]
91142 self .sql = """CREATE MATERIALIZED VIEW extract_abrv1_legal AS SELECT
92143 DATE_PART(YEAR, tmestmp) AS yr,
93144 DATE_PART(YEAR, datee) AS yr1,
@@ -111,7 +162,9 @@ def __init__(self):
111162class illarg_floor_legal (TstView ):
112163 def __init__ (self ):
113164 # checked manually
114- self .data = [{'yr' : '2020-01-01T00:00:00' , 'mth' : '2020-06-01' , 'hr' : '14:00:00' }]
165+ self .data = [
166+ {"yr" : "2020-01-01T00:00:00" , "mth" : "2020-06-01" , "hr" : "14:00:00" }
167+ ]
115168 self .sql = """CREATE MATERIALIZED VIEW floor_legal AS SELECT
116169 FLOOR(tmestmp TO YEAR) AS yr,
117170 FLOOR(datee TO MONTH) AS mth,
@@ -135,7 +188,9 @@ def __init__(self):
135188class illarg_ceil_legal (TstView ):
136189 def __init__ (self ):
137190 # checked manually
138- self .data = [{'yr' : '2021-01-01T00:00:00' , 'mth' : '2020-07-01' , 'hr' : '15:00:00' }]
191+ self .data = [
192+ {"yr" : "2021-01-01T00:00:00" , "mth" : "2020-07-01" , "hr" : "15:00:00" }
193+ ]
139194 self .sql = """CREATE MATERIALIZED VIEW ceil_legal AS SELECT
140195 CEIL(tmestmp TO YEAR) AS yr,
141196 CEIL(datee TO MONTH) AS mth,
@@ -159,7 +214,7 @@ def __init__(self):
159214class illarg_tsdiff_legal (TstView ):
160215 def __init__ (self ):
161216 # checked manually
162- self .data = [{'yr' : 1 , ' mth' : 19 , 'hr' : 6 }]
217+ self .data = [{"yr" : 1 , " mth" : 19 , "hr" : 6 }]
163218 self .sql = """CREATE MATERIALIZED VIEW tsdiff_legal AS SELECT
164219 TIMESTAMPDIFF(YEAR, tmestmp, '2022-01-22 20:24:44'::TIMESTAMP) AS yr,
165220 TIMESTAMPDIFF(MONTH, datee, '2022-01-22'::DATE) AS mth,
@@ -183,7 +238,9 @@ def __init__(self):
183238class illarg_tsadd_legal (TstView ):
184239 def __init__ (self ):
185240 # checked manually
186- self .data = [{'yr' : '2022-06-21T14:23:44' , 'mth' : '2020-08-21' , 'hr' : '16:23:44' }]
241+ self .data = [
242+ {"yr" : "2022-06-21T14:23:44" , "mth" : "2020-08-21" , "hr" : "16:23:44" }
243+ ]
187244 self .sql = """CREATE MATERIALIZED VIEW tsadd_legal AS SELECT
188245 TIMESTAMPADD(YEAR, 2, tmestmp) AS yr,
189246 TIMESTAMPADD(MONTH, 2, datee) AS mth,
@@ -207,22 +264,24 @@ def __init__(self):
207264class illarg_format_date_legal (TstView ):
208265 def __init__ (self ):
209266 # checked manually
210- self .data = [{' datee' : ' 2020-06' }]
267+ self .data = [{" datee" : " 2020-06" }]
211268 self .sql = """CREATE MATERIALIZED VIEW format_date_legal AS SELECT
212269 FORMAT_DATE('%Y-%m', datee) AS datee
213270 FROM illegal_tbl
214271 WHERE id = 0"""
215272
273+
216274class illarg_format_date_cast_legal (TstView ):
217275 def __init__ (self ):
218276 # checked manually
219- self .data = [{' tmestmp' : ' 2020-06' , ' arr' : ' 2021-01' }]
277+ self .data = [{" tmestmp" : " 2020-06" , " arr" : " 2021-01" }]
220278 self .sql = """CREATE MATERIALIZED VIEW format_date_cast_legal AS SELECT
221279 FORMAT_DATE('%Y-%m', tmestmp) AS tmestmp,
222280 FORMAT_DATE('%Y-%m', ARR[4]) AS arr
223281 FROM illegal_tbl
224282 WHERE id = 1"""
225283
284+
226285# Negative Test
227286class illarg_format_date_illegal (TstView ):
228287 def __init__ (self ):
@@ -238,7 +297,7 @@ def __init__(self):
238297class illarg_parse_date_legal (TstView ):
239298 def __init__ (self ):
240299 # checked manually
241- self .data = [{' datee' : ' 2021-01-20' }]
300+ self .data = [{" datee" : " 2021-01-20" }]
242301 self .sql = """CREATE MATERIALIZED VIEW parse_date_legal AS SELECT
243302 PARSE_DATE('%Y-%m-%d', ARR[4]) AS datee
244303 FROM illegal_tbl
@@ -249,7 +308,7 @@ def __init__(self):
249308class illarg_parse_date_illegal (TstView ):
250309 def __init__ (self ):
251310 # checked manually
252- self .data = [{' booll' : None }]
311+ self .data = [{" booll" : None }]
253312 self .sql = """CREATE MATERIALIZED VIEW parse_date_illegal AS SELECT
254313 PARSE_DATE('%Y-%m', booll) AS booll
255314 FROM illegal_tbl
@@ -260,11 +319,12 @@ def __init__(self):
260319# PARSE_TIMESTAMP
261320# PARSE_TIME
262321
322+
263323# TIMESTAMP_TRUNC
264324class illarg_trunc_ts_legal (TstView ):
265325 def __init__ (self ):
266326 # checked manually
267- self .data = [{' tmestmp' : ' 2020-06-01T00:00:00' }]
327+ self .data = [{" tmestmp" : " 2020-06-01T00:00:00" }]
268328 self .sql = """CREATE MATERIALIZED VIEW ts_trunc_legal AS SELECT
269329 TIMESTAMP_TRUNC(tmestmp, MONTH) AS tmestmp
270330 FROM illegal_tbl
@@ -274,7 +334,7 @@ def __init__(self):
274334class illarg_ts_trunc_cast_legal (TstView ):
275335 def __init__ (self ):
276336 # checked manually
277- self .data = [{' datee' : ' 2020-06-01T00:00:00' }]
337+ self .data = [{" datee" : " 2020-06-01T00:00:00" }]
278338 self .sql = """CREATE MATERIALIZED VIEW ts_trunc_cast_legal AS SELECT
279339 TIMESTAMP_TRUNC(datee, MONTH) AS datee
280340 FROM illegal_tbl
@@ -290,6 +350,3 @@ def __init__(self):
290350 FROM illegal_tbl
291351 WHERE id = 1"""
292352 self .expected_error = "Cannot apply 'TIMESTAMP_TRUNC' to arguments of type"
293-
294-
295-
0 commit comments