@@ -295,6 +295,7 @@ def test_iceberg_partition_by(session, local_testing_mode):
295295 ),
296296 )
297297
298+ # Test 1: Single string value
298299 table_name_1 = Utils .random_table_name ()
299300 df .write .save_as_table (
300301 table_name_1 ,
@@ -316,6 +317,7 @@ def test_iceberg_partition_by(session, local_testing_mode):
316317 finally :
317318 session .table (table_name_1 ).drop_table ()
318319
320+ # Test 2: Empty list
319321 table_name_2 = Utils .random_table_name ()
320322 df .write .save_as_table (
321323 table_name_2 ,
@@ -331,6 +333,53 @@ def test_iceberg_partition_by(session, local_testing_mode):
331333 finally :
332334 session .table (table_name_2 ).drop_table ()
333335
336+ # Test 3: Single Column object
337+ table_name_3 = Utils .random_table_name ()
338+ df .write .save_as_table (
339+ table_name_3 ,
340+ iceberg_config = {
341+ "external_volume" : "PYTHON_CONNECTOR_ICEBERG_EXVOL" ,
342+ "catalog" : "SNOWFLAKE" ,
343+ "partition_by" : col ("b" ),
344+ },
345+ )
346+ try :
347+ ddl = session ._run_query (f"select get_ddl('table', '{ table_name_3 } ')" )
348+ assert "PARTITION BY (B)" in ddl [0 ][0 ]
349+ finally :
350+ session .table (table_name_3 ).drop_table ()
351+
352+ # Test 4: Mix of strings and Column objects with empty strings
353+ table_name_4 = Utils .random_table_name ()
354+ df .write .save_as_table (
355+ table_name_4 ,
356+ iceberg_config = {
357+ "external_volume" : "PYTHON_CONNECTOR_ICEBERG_EXVOL" ,
358+ "catalog" : "SNOWFLAKE" ,
359+ "partition_by" : ["a" , "" , col ("b" )],
360+ },
361+ )
362+ try :
363+ ddl = session ._run_query (f"select get_ddl('table', '{ table_name_4 } ')" )
364+ assert "PARTITION BY (A, B)" in ddl [0 ][0 ]
365+ finally :
366+ session .table (table_name_4 ).drop_table ()
367+
368+ # Test 5: No partition_by
369+ table_name_5 = Utils .random_table_name ()
370+ df .write .save_as_table (
371+ table_name_5 ,
372+ iceberg_config = {
373+ "external_volume" : "PYTHON_CONNECTOR_ICEBERG_EXVOL" ,
374+ "catalog" : "SNOWFLAKE" ,
375+ },
376+ )
377+ try :
378+ ddl = session ._run_query (f"select get_ddl('table', '{ table_name_5 } ')" )
379+ assert "PARTITION BY" not in ddl [0 ][0 ]
380+ finally :
381+ session .table (table_name_5 ).drop_table ()
382+
334383
335384@pytest .mark .skipif (
336385 "config.getoption('local_testing_mode', default=False)" ,
0 commit comments