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