@@ -15,16 +15,34 @@ def trino_connection(run_trino):
1515 )
1616
1717
18- def test_int_types (trino_connection ):
18+ def test_boolean_types (trino_connection ):
1919 SqlTest (trino_connection ) \
2020 .add_field (sql = "false" , python = False ) \
21+ .add_field (sql = "true" , python = True ) \
2122 .add_field (sql = "cast(null AS BOOLEAN)" , python = None ) \
23+ .execute ()
24+
25+
26+ def test_tinyint_types (trino_connection ):
27+ SqlTest (trino_connection ) \
2228 .add_field (sql = "cast(127 AS TINYINT)" , python = 127 ) \
2329 .add_field (sql = "cast(-128 AS TINYINT)" , python = - 128 ) \
30+ .add_field (sql = "cast(42 AS TINYINT)" , python = 42 ) \
31+ .add_field (sql = "cast(-42 AS TINYINT)" , python = - 42 ) \
2432 .add_field (sql = "cast(null AS TINYINT)" , python = None ) \
33+ .execute ()
34+
35+
36+ def test_smallint_types (trino_connection ):
37+ SqlTest (trino_connection ) \
2538 .add_field (sql = "cast(32767 AS SMALLINT)" , python = 32767 ) \
2639 .add_field (sql = "cast(-32768 AS SMALLINT)" , python = - 32768 ) \
2740 .add_field (sql = "cast(null AS SMALLINT)" , python = None ) \
41+ .execute ()
42+
43+
44+ def test_int_types (trino_connection ):
45+ SqlTest (trino_connection ) \
2846 .add_field (sql = "cast(2147483647 AS INTEGER)" , python = 2147483647 ) \
2947 .add_field (sql = "cast(-2147483648 AS INTEGER)" , python = - 2147483648 ) \
3048 .add_field (sql = "cast(null AS INTEGER)" , python = None ) \
@@ -34,25 +52,44 @@ def test_int_types(trino_connection):
3452 .execute ()
3553
3654
37- def test_float_types (trino_connection ):
55+ def test_bigint_types (trino_connection ):
56+ SqlTest (trino_connection ) \
57+ .add_field (sql = "cast(9223372036854775807 AS BIGINT)" , python = 9223372036854775807 ) \
58+ .add_field (sql = "cast(-9223372036854775808 AS BIGINT)" , python = - 9223372036854775808 ) \
59+ .add_field (sql = "cast(null AS BIGINT)" , python = None ) \
60+ .execute ()
61+
62+
63+ def test_real_types (trino_connection ):
3864 SqlTest (trino_connection ) \
3965 .add_field (sql = "cast(3.4028235E38 AS REAL)" , python = 3.4028235e+38 ) \
4066 .add_field (sql = "cast(1.4E-45 AS REAL)" , python = 1.4e-45 ) \
4167 .add_field (sql = "cast('Infinity' AS REAL)" , python = math .inf ) \
4268 .add_field (sql = "cast('-Infinity' AS REAL)" , python = - math .inf ) \
4369 .add_field (sql = "cast('NaN' AS REAL)" , python = math .nan ) \
4470 .add_field (sql = "cast(null AS REAL)" , python = None ) \
71+ .execute ()
72+
73+
74+ def test_double_types (trino_connection ):
75+ SqlTest (trino_connection ) \
4576 .add_field (sql = "cast(1.7976931348623157E308 AS DOUBLE)" , python = 1.7976931348623157e+308 ) \
4677 .add_field (sql = "cast(4.9E-324 AS DOUBLE)" , python = 5e-324 ) \
4778 .add_field (sql = "cast('Infinity' AS DOUBLE)" , python = math .inf ) \
4879 .add_field (sql = "cast('-Infinity' AS DOUBLE)" , python = - math .inf ) \
4980 .add_field (sql = "cast('NaN' AS DOUBLE)" , python = math .nan ) \
5081 .add_field (sql = "cast(null AS DOUBLE)" , python = None ) \
82+ .execute ()
83+
84+
85+ def test_decimal_types (trino_connection ):
86+ SqlTest (trino_connection ) \
5187 .add_field (sql = "DECIMAL '10.3'" , python = Decimal ('10.3' )) \
5288 .add_field (sql = "cast(null AS DECIMAL)" , python = None ) \
5389 .add_field (sql = "cast('0.123456789123456789' AS DECIMAL(18,18))" , python = Decimal ('0.123456789123456789' )) \
5490 .add_field (sql = "cast(null AS DECIMAL(18,18))" , python = None ) \
55- .add_field (sql = "cast('10.3' AS DECIMAL(38,0))" , python = 10.0 ) \
91+ .add_field (sql = "cast('10.3' AS DECIMAL(38,1))" , python = Decimal ('10.3' )) \
92+ .add_field (sql = "cast('0.123456789123456789' AS DECIMAL(18,2))" , python = Decimal ('0.12' )) \
5693 .add_field (sql = "cast(null AS DECIMAL(38,0))" , python = None ) \
5794 .execute ()
5895
@@ -67,6 +104,7 @@ def test_string_types(trino_connection):
67104 .add_field (sql = "cast('ccc' AS CHAR)" , python = 'c' ) \
68105 .add_field (sql = "cast(null AS CHAR)" , python = None ) \
69106 .add_field (sql = "cast('ddd' AS CHAR(1))" , python = 'd' ) \
107+ .add_field (sql = "cast('😂' AS CHAR(1))" , python = '😂' ) \
70108 .add_field (sql = "cast(null AS CHAR(1))" , python = None ) \
71109 .add_field (sql = "X'65683F'" , python = 'ZWg/' ) \
72110 .add_field (sql = "cast(null AS VARBINARY)" , python = None ) \
@@ -81,6 +119,7 @@ def test_datetime_types(trino_connection):
81119
82120 SqlTest (trino_connection ) \
83121 .add_field (sql = "DATE '2001-08-22'" , python = datetime .date (2001 , 8 , 22 )) \
122+ .add_field (sql = "DATE '02001-08-22'" , python = datetime .date (2001 , 8 , 22 )) \
84123 .add_field (sql = "cast(null AS DATE)" , python = None ) \
85124 .add_field (sql = "TIME '01:23:45.123'" , python = datetime .time (1 , 23 , 45 , 123000 )) \
86125 .add_field (sql = "cast(null AS TIME)" , python = None ) \
@@ -149,22 +188,53 @@ def test_datetime_types(trino_connection):
149188 .execute ()
150189
151190
152- def test_misc_types (trino_connection ):
191+ def test_interval_types (trino_connection ):
153192 SqlTest (trino_connection ) \
154193 .add_field (sql = "INTERVAL '3' MONTH" , python = '0-3' ) \
155194 .add_field (sql = "cast(null AS INTERVAL YEAR TO MONTH)" , python = None ) \
156195 .add_field (sql = "INTERVAL '2' DAY" , python = '2 00:00:00.000' ) \
196+ .add_field (sql = "INTERVAL '-2' DAY" , python = '-2 00:00:00.000' ) \
157197 .add_field (sql = "cast(null AS INTERVAL DAY TO SECOND)" , python = None ) \
198+ .execute ()
199+
200+
201+ def test_array_types (trino_connection ):
202+ SqlTest (trino_connection ) \
158203 .add_field (sql = "ARRAY['a', 'b', null]" , python = ['a' , 'b' , None ]) \
159204 .add_field (sql = "cast(null AS ARRAY(VARCHAR))" , python = None ) \
205+ .execute ()
206+
207+
208+ def test_map_types (trino_connection ):
209+ SqlTest (trino_connection ) \
160210 .add_field (sql = "MAP(ARRAY['a', 'b'], ARRAY[1, null])" , python = {'a' : 1 , 'b' : None }) \
161211 .add_field (sql = "cast(null AS MAP(VARCHAR, INTEGER))" , python = None ) \
212+ .execute ()
213+
214+
215+ def test_row_types (trino_connection ):
216+ SqlTest (trino_connection ) \
162217 .add_field (sql = "cast(ROW(1, 2e0) AS ROW(x BIGINT, y DOUBLE))" , python = (1 , 2.0 )) \
163218 .add_field (sql = "cast(null AS ROW(x BIGINT, y DOUBLE))" , python = None ) \
219+ .execute ()
220+
221+
222+ def test_ipaddress_types (trino_connection ):
223+ SqlTest (trino_connection ) \
164224 .add_field (sql = "IPADDRESS '2001:db8::1'" , python = '2001:db8::1' ) \
165225 .add_field (sql = "cast(null AS IPADDRESS)" , python = None ) \
226+ .execute ()
227+
228+
229+ def test_uuid_types (trino_connection ):
230+ SqlTest (trino_connection ) \
166231 .add_field (sql = "UUID '12151fd2-7586-11e9-8f9e-2a86e4085a59'" , python = '12151fd2-7586-11e9-8f9e-2a86e4085a59' ) \
167232 .add_field (sql = "cast(null AS UUID)" , python = None ) \
233+ .execute ()
234+
235+
236+ def test_digest_types (trino_connection ):
237+ SqlTest (trino_connection ) \
168238 .add_field (sql = "approx_set(1)" , python = 'AgwBAIADRAA=' ) \
169239 .add_field (sql = "cast(null AS HyperLogLog)" , python = None ) \
170240 .add_field (sql = "cast(approx_set(1) AS P4HyperLogLog)" , python = 'AwwAAAAg' + 'A' * 2730 + '==' ) \
0 commit comments