diff --git a/src/main/cpp/src/datetime_parser.cu b/src/main/cpp/src/datetime_parser.cu index cd5b53e32..4b607f487 100644 --- a/src/main/cpp/src/datetime_parser.cu +++ b/src/main/cpp/src/datetime_parser.cu @@ -62,12 +62,15 @@ struct timestamp_components __device__ __host__ thrust::tuple to_utc_timestamp(timestamp_components components, cudf::string_view const &time_zone) { - // TODO replace the temp implementation - long v = 365L * 86400L * 1000000L * components.year + 30L * 86400L * 1000000L * components.month + - 86400L * 1000000L * components.day + 3600L * 1000000L * components.hour + - 60L * 1000000L * components.minute + 1000000L * components.second + - components.microseconds; - return thrust::make_tuple(cudf::timestamp_us{cudf::duration_us{v}}, true); + // TODO replace the fake implementation + long seconds = components.year * 365L * 86400L + + components.month * 30L * 86400L + + components.day * 86400L + + components.hour * 3600L + + components.minute * 60L + + components.second; + long us = seconds * 1000000L + components.microseconds; + return thrust::make_tuple(cudf::timestamp_us{cudf::duration_us{us}}, true); } __device__ __host__ inline bool is_whitespace(const char chr) @@ -492,11 +495,13 @@ parse_string_to_timestamp(cudf::strings_column_view const &input, } else { + // TODO update bitmask return std::make_pair(std::move(timestamp_column), true); } } else { + // TODO update bitmask return std::make_pair(std::move(timestamp_column), true); } } diff --git a/src/main/cpp/tests/datetime_parser.cpp b/src/main/cpp/tests/datetime_parser.cpp index ff6c7b79d..47a733a41 100644 --- a/src/main/cpp/tests/datetime_parser.cpp +++ b/src/main/cpp/tests/datetime_parser.cpp @@ -39,17 +39,17 @@ struct DateTimeParserTest : public cudf::test::BaseFixture TEST_F(DateTimeParserTest, ParseTimestamp) { - auto const ts_col = timestamp_col{ - -719162L, -354285L, -141714, -141438, -141437, -141432, -141427, -31463, -31453, -1, 0, 18335}; + auto v = (2023L * 365L * 86400L + 11L * 30L * 86400L + 5L * 86400L + 3L * 3600L + 4L * 60L + 55L) * 1000000L; + auto const ts_col = timestamp_col{v, v, v + 123456}; auto const ts_strings = cudf::test::strings_column_wrapper{"2023-11-05T03:04:55Z", - "2023-11-05T03:04:55 ", - "2023-11-05T03:04:55.123456 "}; + "2023-11-05T03:04:55 ", + "2023-11-05T03:04:55.123456 "}; auto const parsed_ts = - cudf::strings::string_to_timestamp(cudf::strings_column_view(ts_strings), - "Z", - true, - true); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(ts_col, *parsed_ts); + spark_rapids_jni::string_to_timestamp(cudf::strings_column_view(ts_strings), + "Z", + true, + true); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(ts_col, *(parsed_ts.first)); }