@@ -724,6 +724,46 @@ def test_geometry(conn_cnx):
724
724
assert row in expected_data
725
725
726
726
727
+ @pytest .mark .skipolddriver
728
+ def test_file (conn_cnx ):
729
+ """Variant including JSON object."""
730
+ name_file = random_string (5 , "test_file_" )
731
+ with conn_cnx (
732
+ session_parameters = {
733
+ "ENABLE_FILE_DATA_TYPE" : True ,
734
+ },
735
+ ) as cnx :
736
+ with cnx .cursor () as cur :
737
+ cur .execute (
738
+ f"create temporary table { name_file } as select "
739
+ f"TO_FILE(OBJECT_CONSTRUCT('RELATIVE_PATH', 'some_new_file.jpeg', 'STAGE', '@myStage', "
740
+ f"'STAGE_FILE_URL', 'some_new_file.jpeg', 'SIZE', 123, 'ETAG', 'xxx', 'CONTENT_TYPE', 'image/jpeg', "
741
+ f"'LAST_MODIFIED', '2025-01-01')) as file_col"
742
+ )
743
+
744
+ expected_data = [
745
+ {
746
+ "RELATIVE_PATH" : "some_new_file.jpeg" ,
747
+ "STAGE" : "@myStage" ,
748
+ "STAGE_FILE_URL" : "some_new_file.jpeg" ,
749
+ "SIZE" : 123 ,
750
+ "ETAG" : "xxx" ,
751
+ "CONTENT_TYPE" : "image/jpeg" ,
752
+ "LAST_MODIFIED" : "2025-01-01" ,
753
+ }
754
+ ]
755
+
756
+ with cnx .cursor () as cur :
757
+ # Test with FILE return type
758
+ result = cur .execute (f"select * from { name_file } " )
759
+ for metadata in [cur .description , cur ._description_internal ]:
760
+ assert FIELD_ID_TO_NAME [metadata [0 ].type_code ] == "FILE"
761
+ data = result .fetchall ()
762
+ for raw_data in data :
763
+ row = json .loads (raw_data [0 ])
764
+ assert row in expected_data
765
+
766
+
727
767
@pytest .mark .skipolddriver
728
768
def test_vector (conn_cnx , is_public_test ):
729
769
if is_public_test :
0 commit comments