@@ -699,6 +699,46 @@ def test_geometry(conn_cnx):
699699 assert row in expected_data
700700
701701
702+ @pytest .mark .skipolddriver
703+ def test_file (conn_cnx ):
704+ """Variant including JSON object."""
705+ name_file = random_string (5 , "test_file_" )
706+ with conn_cnx (
707+ session_parameters = {
708+ "ENABLE_FILE_DATA_TYPE" : True ,
709+ },
710+ ) as cnx :
711+ with cnx .cursor () as cur :
712+ cur .execute (
713+ f"create temporary table { name_file } as select "
714+ f"TO_FILE(OBJECT_CONSTRUCT('RELATIVE_PATH', 'some_new_file.jpeg', 'STAGE', '@myStage', "
715+ f"'STAGE_FILE_URL', 'some_new_file.jpeg', 'SIZE', 123, 'ETAG', 'xxx', 'CONTENT_TYPE', 'image/jpeg', "
716+ f"'LAST_MODIFIED', '2025-01-01')) as file_col"
717+ )
718+
719+ expected_data = [
720+ {
721+ "RELATIVE_PATH" : "some_new_file.jpeg" ,
722+ "STAGE" : "@myStage" ,
723+ "STAGE_FILE_URL" : "some_new_file.jpeg" ,
724+ "SIZE" : 123 ,
725+ "ETAG" : "xxx" ,
726+ "CONTENT_TYPE" : "image/jpeg" ,
727+ "LAST_MODIFIED" : "2025-01-01" ,
728+ }
729+ ]
730+
731+ with cnx .cursor () as cur :
732+ # Test with FILE return type
733+ result = cur .execute (f"select * from { name_file } " )
734+ for metadata in [cur .description , cur ._description_internal ]:
735+ assert FIELD_ID_TO_NAME [metadata [0 ].type_code ] == "FILE"
736+ data = result .fetchall ()
737+ for raw_data in data :
738+ row = json .loads (raw_data [0 ])
739+ assert row in expected_data
740+
741+
702742@pytest .mark .skipolddriver
703743def test_vector (conn_cnx , is_public_test ):
704744 if is_public_test :
0 commit comments