@@ -746,6 +746,45 @@ async def test_vector(conn_cnx, is_public_test):
746
746
assert len (data ) == 0
747
747
748
748
749
+ async def test_file (conn_cnx ):
750
+ """Variant including JSON object."""
751
+ name_file = random_string (5 , "test_file_" )
752
+ async with conn_cnx (
753
+ session_parameters = {
754
+ "ENABLE_FILE_DATA_TYPE" : True ,
755
+ },
756
+ ) as cnx :
757
+ async with cnx .cursor () as cur :
758
+ await cur .execute (
759
+ f"create temporary table { name_file } as select "
760
+ f"TO_FILE(OBJECT_CONSTRUCT('RELATIVE_PATH', 'some_new_file.jpeg', 'STAGE', '@myStage', "
761
+ f"'STAGE_FILE_URL', 'some_new_file.jpeg', 'SIZE', 123, 'ETAG', 'xxx', 'CONTENT_TYPE', 'image/jpeg', "
762
+ f"'LAST_MODIFIED', '2025-01-01')) as file_col"
763
+ )
764
+
765
+ expected_data = [
766
+ {
767
+ "RELATIVE_PATH" : "some_new_file.jpeg" ,
768
+ "STAGE" : "@myStage" ,
769
+ "STAGE_FILE_URL" : "some_new_file.jpeg" ,
770
+ "SIZE" : 123 ,
771
+ "ETAG" : "xxx" ,
772
+ "CONTENT_TYPE" : "image/jpeg" ,
773
+ "LAST_MODIFIED" : "2025-01-01" ,
774
+ }
775
+ ]
776
+
777
+ async with cnx .cursor () as cur :
778
+ # Test with FILE return type
779
+ result = await cur .execute (f"select * from { name_file } " )
780
+ for metadata in [cur .description , cur ._description_internal ]:
781
+ assert FIELD_ID_TO_NAME [metadata [0 ].type_code ] == "FILE"
782
+ data = await result .fetchall ()
783
+ for raw_data in data :
784
+ row = json .loads (raw_data [0 ])
785
+ assert row in expected_data
786
+
787
+
749
788
async def test_invalid_bind_data_type (conn_cnx ):
750
789
"""Invalid bind data type."""
751
790
async with conn_cnx () as cnx :
0 commit comments