@@ -482,6 +482,47 @@ def test_write_pandas_use_logical_type(
482482 cnx .execute_string (drop_sql )
483483
484484
485+ @pytest .mark .parametrize (
486+ ("use_vectorized_scanner" , "expected_file_format" ),
487+ [
488+ (None , "FILE_FORMAT=(TYPE=PARQUET COMPRESSION=auto)" ),
489+ (True , "FILE_FORMAT=(TYPE=PARQUET COMPRESSION=auto USE_VECTORIZED_SCANNER=TRUE)" ),
490+ (False , "FILE_FORMAT=(TYPE=PARQUET COMPRESSION=auto USE_VECTORIZED_SCANNER=FALSE)" ),
491+ ],
492+ )
493+ def test_write_pandas_use_vectorized_scanner (
494+ conn_cnx : Callable [..., Generator [SnowflakeConnection , None , None ]],
495+ use_vectorized_scanner : bool | None ,
496+ expected_file_format : str ,
497+ ):
498+ """Test that use_vectorized_scanner is making correct arguments to the COPY INTO command in SQL."""
499+ from snowflake .connector .cursor import SnowflakeCursor
500+
501+ table_name = random_string (5 , "use_vectorized_scanner" )
502+
503+ with conn_cnx () as cnx :
504+ def mocked_execute (* args , ** kwargs ):
505+ if len (args ) >= 1 and args [0 ].startswith ("COPY INTO" ):
506+ assert expected_file_format in args [0 ]
507+ cur = SnowflakeCursor (cnx )
508+ cur ._result = iter ([])
509+ return cur
510+
511+ with mock .patch (
512+ "snowflake.connector.cursor.SnowflakeCursor.execute" ,
513+ side_effect = mocked_execute ,
514+ ) as m_execute :
515+ success , nchunks , nrows , _ = write_pandas (
516+ cnx ,
517+ sf_connector_version_df .get (),
518+ table_name = table_name ,
519+ use_vectorized_scanner = use_vectorized_scanner ,
520+ )
521+ assert m_execute .called and any (
522+ map (lambda e : "COPY INTO" in str (e [0 ]), m_execute .call_args_list )
523+ )
524+
525+
485526def test_invalid_table_type_write_pandas (
486527 conn_cnx : Callable [..., Generator [SnowflakeConnection , None , None ]],
487528):
@@ -534,6 +575,7 @@ def test_table_location_building(
534575
535576 def mocked_execute (* args , ** kwargs ):
536577 if len (args ) >= 1 and args [0 ].startswith ("COPY INTO" ):
578+ print (kwargs )
537579 assert kwargs ["params" ][0 ] == expected_location
538580 cur = SnowflakeCursor (cnx )
539581 cur ._result = iter ([])
0 commit comments