@@ -1090,6 +1090,71 @@ async def test_fetch_as_numpy_val(conn_cnx):
1090
1090
assert val [3 ] == numpy .datetime64 ("2019-01-02 12:34:56.12345678" )
1091
1091
1092
1092
1093
+ @pytest .mark .parametrize ("use_numpy" , [True , False ])
1094
+ async def test_select_year_month_interval_arrow (conn_cnx , use_numpy ):
1095
+ cases = ["0-0" , "1-2" , "-1-3" , "999999999-11" , "-999999999-11" ]
1096
+ expected = [0 , 14 , - 15 , 11_999_999_999 , - 11_999_999_999 ]
1097
+ if use_numpy :
1098
+ expected = [numpy .timedelta64 (e , "M" ) for e in expected ]
1099
+
1100
+ table = "test_arrow_day_time_interval"
1101
+ values = "(" + "),(" .join ([f"'{ c } '" for c in cases ]) + ")"
1102
+ async with conn_cnx (numpy = use_numpy ) as conn :
1103
+ cursor = conn .cursor ()
1104
+ await cursor .execute (
1105
+ "alter session set python_connector_query_result_format='arrow'"
1106
+ )
1107
+
1108
+ await cursor .execute ("alter session set feature_interval_types=enabled" )
1109
+ await cursor .execute (
1110
+ f"create or replace table { table } (c1 interval year to month)"
1111
+ )
1112
+ await cursor .execute (f"insert into { table } values { values } " )
1113
+ result = await conn .cursor ().execute (f"select * from { table } " ).fetchall ()
1114
+ result = [r [0 ] for r in result ]
1115
+ assert result == expected
1116
+
1117
+
1118
+ @pytest .mark .skip (
1119
+ reason = "SNOW-1878635: Add support for day-time interval in ArrowStreamWriter"
1120
+ )
1121
+ @pytest .mark .parametrize ("use_numpy" , [True , False ])
1122
+ async def test_select_day_time_interval_arrow (conn_cnx , use_numpy ):
1123
+ cases = [
1124
+ "0 0:0:0.0" ,
1125
+ "12 3:4:5.678" ,
1126
+ "-1 2:3:4.567" ,
1127
+ "99999 23:59:59.999999" ,
1128
+ "-99999 23:59:59.999999" ,
1129
+ ]
1130
+ expected = [
1131
+ timedelta (days = 0 ),
1132
+ timedelta (days = 12 , hours = 3 , minutes = 4 , seconds = 5.678 ),
1133
+ - timedelta (days = 1 , hours = 2 , minutes = 3 , seconds = 4.567 ),
1134
+ timedelta (days = 99999 , hours = 23 , minutes = 59 , seconds = 59.999999 ),
1135
+ - timedelta (days = 99999 , hours = 23 , minutes = 59 , seconds = 59.999999 ),
1136
+ ]
1137
+ if use_numpy :
1138
+ expected = [numpy .timedelta64 (e ) for e in expected ]
1139
+
1140
+ table = "test_arrow_day_time_interval"
1141
+ values = "(" + "),(" .join ([f"'{ c } '" for c in cases ]) + ")"
1142
+ async with conn_cnx (numpy = use_numpy ) as conn :
1143
+ cursor = conn .cursor ()
1144
+ await cursor .execute (
1145
+ "alter session set python_connector_query_result_format='arrow'"
1146
+ )
1147
+
1148
+ await cursor .execute ("alter session set feature_interval_types=enabled" )
1149
+ await cursor .execute (
1150
+ f"create or replace table { table } (c1 interval day(5) to second)"
1151
+ )
1152
+ await cursor .execute (f"insert into { table } values { values } " )
1153
+ result = await conn .cursor ().execute (f"select * from { table } " ).fetchall ()
1154
+ result = [r [0 ] for r in result ]
1155
+ assert result == expected
1156
+
1157
+
1093
1158
async def iterate_over_test_chunk (
1094
1159
test_name , conn_cnx , sql_text , row_count , col_count , eps = None , expected = None
1095
1160
):
0 commit comments