Skip to content

Commit ae0e253

Browse files
Working Timedelta conversion
1 parent 5cb9b24 commit ae0e253

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,10 @@ void CArrowTableIterator::convertIntervalDayTimeColumn_nanoarrow(
569569
"array, error code: %d",
570570
returnCode);
571571
} else {
572-
auto originalVal = ArrowArrayViewGetIntUnsafe(columnArray, rowIdx);
572+
ArrowDecimal arrowDecimal;
573+
ArrowDecimalInit(&arrowDecimal, 128, 38, 0);
574+
ArrowArrayViewGetDecimalUnsafe(columnArray, rowIdx, &arrowDecimal);
575+
auto originalVal = ArrowDecimalGetIntUnsafe(&arrowDecimal);
573576
returnCode = ArrowArrayAppendInt(newArray, originalVal);
574577
SF_CHECK_ARROW_RC(returnCode,
575578
"[Snowflake Exception] error appending int to arrow "

test/integ/pandas_it/test_arrow_pandas.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,7 @@ def test_interval_year_month(conn_cnx):
8585
reason="arrow_iterator extension is not built, or pandas is missing.",
8686
)
8787
def test_interval_day_time(conn_cnx):
88-
cases = [
89-
"0 00:00:51",
90-
# "0 0:0:0.0",
91-
# "12 3:4:5.678",
92-
# "-1 2:3:4.567",
93-
# "999999999 23:59:59.999999",
94-
# "-99999 23:59:59.999999"
95-
]
88+
cases = ["106751 23:47:16.854775807", "0 0:0:0.0", "-5 0:0:0.0"]
9689
table = "test_arrow_day_time_interval"
9790
values = "(" + "),(".join([f"'{c}'" for c in cases]) + ")"
9891
with conn_cnx() as conn:
@@ -789,7 +782,11 @@ def validate_pandas(
789782
int(year_month_list[1]) * 12 + int(year_month_list[2])
790783
)
791784
elif data_type == "interval_day_time":
792-
c_case = pandas.Timedelta(cases[i])
785+
timedelta_split_days = cases[i].split(" ")
786+
pandas_timedelta_str = (
787+
timedelta_split_days[0] + " days " + timedelta_split_days[1]
788+
)
789+
c_case = pandas.to_timedelta(pandas_timedelta_str)
793790
elif data_type == "time":
794791
time_str_len = 8 if scale == 0 else 9 + scale
795792
c_case = cases[i].strip()[:time_str_len]

0 commit comments

Comments
 (0)