1414
1515import snowflake .connector .cursor
1616from snowflake .connector import ProgrammingError , errors
17+ from snowflake .connector .cursor import DictCursor , SnowflakeCursor
1718
1819try : # pragma: no cover
1920 from snowflake .connector .constants import (
@@ -153,10 +154,11 @@ def test_binding_multi(conn_cnx, style: str, skip_to_last_set: bool):
153154 )
154155
155156
156- def test_async_exec_multi (conn_cnx , skip_to_last_set : bool ):
157+ @pytest .mark .parametrize ("cursor_class" , [SnowflakeCursor , DictCursor ])
158+ def test_async_exec_multi (conn_cnx , cursor_class , skip_to_last_set : bool ):
157159 """Tests whether async execution query works within a multi-statement"""
158160 with conn_cnx () as con :
159- with con .cursor () as cur :
161+ with con .cursor (cursor_class ) as cur :
160162 cur .execute_async (
161163 "select 1; select 2; select count(*) from table(generator(timeLimit => 1)); select 'b';" ,
162164 num_statements = 4 ,
@@ -165,14 +167,29 @@ def test_async_exec_multi(conn_cnx, skip_to_last_set: bool):
165167 assert con .is_still_running (con .get_query_status (q_id ))
166168 _wait_while_query_running (con , q_id , sleep_time = 1 )
167169 with conn_cnx () as con :
168- with con .cursor () as cur :
170+ with con .cursor (cursor_class ) as cur :
169171 _wait_until_query_success (con , q_id , num_checks = 3 , sleep_per_check = 1 )
170172 assert con .get_query_status_throw_if_error (q_id ) == QueryStatus .SUCCESS
171173
174+ if cursor_class == SnowflakeCursor :
175+ expected = [
176+ [(1 ,)],
177+ [(2 ,)],
178+ lambda x : len (x ) == 1 and len (x [0 ]) == 1 and x [0 ][0 ] > 0 ,
179+ [("b" ,)],
180+ ]
181+ elif cursor_class == DictCursor :
182+ expected = [
183+ [{"1" : 1 }],
184+ [{"2" : 2 }],
185+ lambda x : len (x ) == 1 and len (x [0 ]) == 1 and x [0 ]["COUNT(*)" ] > 0 ,
186+ [{"'B'" : "b" }],
187+ ]
188+
172189 cur .get_results_from_sfqid (q_id )
173190 _check_multi_statement_results (
174191 cur ,
175- checks = [[( 1 ,)], [( 2 ,)], lambda x : x > [( 0 ,)], [( "b" ,)]] ,
192+ checks = expected ,
176193 skip_to_last_set = skip_to_last_set ,
177194 )
178195
0 commit comments