@@ -244,22 +244,47 @@ def test_record_pandas_dataframe(self, connection: turu.snowflake.Connection):
244244 import pandas as pd # type: ignore[import]
245245 from pandas .testing import assert_frame_equal # type: ignore[import]
246246
247+ with tempfile .NamedTemporaryFile () as file :
248+ with record_to_csv (
249+ file .name ,
250+ connection .execute_map (
251+ pd .DataFrame , "select 1 as ID union all select 2 AS ID"
252+ ),
253+ ) as cursor :
254+ expected = pd .DataFrame ({"ID" : [1 , 2 ]}, dtype = "int8" )
255+
256+ assert_frame_equal (cursor .fetch_pandas_all (), expected )
257+
258+ assert (
259+ Path (file .name ).read_text ()
260+ == dedent (
261+ """
262+ ID
263+ 1
264+ 2
265+ """
266+ ).lstrip ()
267+ )
268+
269+ @pytest .mark .skipif (not USE_PANDAS , reason = "pandas is not installed" )
270+ def test_record_pandas_dataframe_with_limit_option (
271+ self , connection : turu .snowflake .Connection
272+ ):
273+ import pandas as pd # type: ignore[import]
274+ from pandas .testing import assert_frame_equal # type: ignore[import]
275+
247276 with tempfile .NamedTemporaryFile () as file :
248277 with record_to_csv (
249278 file .name ,
250279 connection .execute_map (
251280 pd .DataFrame ,
252- "select 1 as ID union all select 2 AS ID " ,
281+ "select value::integer as ID from table(flatten(ARRAY_GENERATE_RANGE(1, 10))) " ,
253282 ),
283+ limit = 2 ,
254284 ) as cursor :
255- expected = pd .DataFrame (
256- {"ID" : [1 , 2 ]},
257- dtype = "int8" ,
258- )
285+ expected = pd .DataFrame ({"ID" : list (range (1 , 10 ))}, dtype = "object" )
259286
260287 assert_frame_equal (cursor .fetch_pandas_all (), expected )
261- for row in expected .values :
262- print (row )
263288
264289 assert (
265290 Path (file .name ).read_text ()
0 commit comments