2626 TimestampParameter ,
2727 TinyIntParameter ,
2828 VoidParameter ,
29+ ArrayParameter ,
30+ MapParameter ,
2931)
3032from tests .e2e .test_driver import PySQLPytestTestCase
3133
@@ -50,6 +52,8 @@ class Primitive(Enum):
5052 DOUBLE = 3.14
5153 FLOAT = 3.15
5254 SMALLINT = 51
55+ ARRAYS = ["a" , "b" , "c" ]
56+ MAPS = {"a" : 1 , "b" : 2 , "c" : 3 }
5357
5458
5559class PrimitiveExtra (Enum ):
@@ -103,6 +107,8 @@ class TestParameterizedQueries(PySQLPytestTestCase):
103107 Primitive .BOOL : "boolean_col" ,
104108 Primitive .DATE : "date_col" ,
105109 Primitive .TIMESTAMP : "timestamp_col" ,
110+ Primitive .ARRAYS : "array_col" ,
111+ Primitive .MAPS : "map_col" ,
106112 Primitive .NONE : "null_col" ,
107113 }
108114
@@ -134,7 +140,9 @@ def inline_table(self, connection_details):
134140 string_col STRING,
135141 boolean_col BOOLEAN,
136142 date_col DATE,
137- timestamp_col TIMESTAMP
143+ timestamp_col TIMESTAMP,
144+ array_col ARRAY<STRING>,
145+ map_col MAP<STRING, INT>
138146 ) USING DELTA
139147 """
140148
@@ -167,9 +175,9 @@ def _inline_roundtrip(self, params: dict, paramstyle: ParamStyle):
167175 This is a no-op but is included to make the test-code easier to read.
168176 """
169177 target_column = self ._get_inline_table_column (params .get ("p" ))
170- INSERT_QUERY = f"INSERT INTO pysql_e2e_inline_param_test_table (`{ target_column } `) VALUES (%(p)s)"
171- SELECT_QUERY = f"SELECT { target_column } `col` FROM pysql_e2e_inline_param_test_table LIMIT 1"
172- DELETE_QUERY = "DELETE FROM pysql_e2e_inline_param_test_table"
178+ INSERT_QUERY = f"INSERT INTO ___________________first.jprakash. pysql_e2e_inline_param_test_table (`{ target_column } `) VALUES (%(p)s)"
179+ SELECT_QUERY = f"SELECT { target_column } `col` FROM ___________________first.jprakash. pysql_e2e_inline_param_test_table LIMIT 1"
180+ DELETE_QUERY = "DELETE FROM ___________________first.jprakash. pysql_e2e_inline_param_test_table"
173181
174182 with self .connection (extra_params = {"use_inline_params" : True }) as conn :
175183 with conn .cursor () as cursor :
@@ -229,10 +237,18 @@ def _eq(self, actual, expected: Primitive):
229237 If primitive is Primitive.DOUBLE than an extra quantize step is performed before
230238 making the assertion.
231239 """
232- if expected in ( Primitive . DOUBLE , Primitive . FLOAT ):
233- return self . _quantize ( actual ) == self . _quantize ( expected .value )
240+ actual_parsed = actual
241+ expected_parsed = expected .value
234242
235- return actual == expected .value
243+ if expected in (Primitive .DOUBLE , Primitive .FLOAT ):
244+ actual_parsed = self ._quantize (actual )
245+ expected_parsed = self ._quantize (expected .value )
246+ elif expected == Primitive .ARRAYS :
247+ actual_parsed = actual .tolist ()
248+ elif expected == Primitive .MAPS :
249+ expected_parsed = list (expected .value .items ())
250+
251+ return actual_parsed == expected_parsed
236252
237253 @pytest .mark .parametrize ("primitive" , Primitive )
238254 @pytest .mark .parametrize (
@@ -278,6 +294,8 @@ def test_primitive_single(
278294 (Primitive .SMALLINT , SmallIntParameter ),
279295 (PrimitiveExtra .TIMESTAMP_NTZ , TimestampNTZParameter ),
280296 (PrimitiveExtra .TINYINT , TinyIntParameter ),
297+ (Primitive .ARRAYS , ArrayParameter ),
298+ (Primitive .MAPS , MapParameter ),
281299 ],
282300 )
283301 def test_dbsqlparameter_single (
0 commit comments