diff --git a/cpp/include/cudf/datetime.hpp b/cpp/include/cudf/datetime.hpp index 1eaea5b6374..1f6e86d0389 100644 --- a/cpp/include/cudf/datetime.hpp +++ b/cpp/include/cudf/datetime.hpp @@ -58,6 +58,8 @@ enum class datetime_component : uint8_t { * @brief Extracts year from any datetime type and returns an int16_t * cudf::column. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -65,7 +67,7 @@ enum class datetime_component : uint8_t { * @returns cudf::column of the extracted int16_t years * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_year( +[[deprecated]] std::unique_ptr extract_year( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -74,6 +76,8 @@ std::unique_ptr extract_year( * @brief Extracts month from any datetime type and returns an int16_t * cudf::column. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -81,7 +85,7 @@ std::unique_ptr extract_year( * @returns cudf::column of the extracted int16_t months * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_month( +[[deprecated]] std::unique_ptr extract_month( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -90,6 +94,8 @@ std::unique_ptr extract_month( * @brief Extracts day from any datetime type and returns an int16_t * cudf::column. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -97,7 +103,7 @@ std::unique_ptr extract_month( * @returns cudf::column of the extracted int16_t days * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_day( +[[deprecated]] std::unique_ptr extract_day( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -106,6 +112,8 @@ std::unique_ptr extract_day( * @brief Extracts a weekday from any datetime type and returns an int16_t * cudf::column. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -113,7 +121,7 @@ std::unique_ptr extract_day( * @returns cudf::column of the extracted int16_t days * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_weekday( +[[deprecated]] std::unique_ptr extract_weekday( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -122,6 +130,8 @@ std::unique_ptr extract_weekday( * @brief Extracts hour from any datetime type and returns an int16_t * cudf::column. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -129,7 +139,7 @@ std::unique_ptr extract_weekday( * @returns cudf::column of the extracted int16_t hours * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_hour( +[[deprecated]] std::unique_ptr extract_hour( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -138,6 +148,8 @@ std::unique_ptr extract_hour( * @brief Extracts minute from any datetime type and returns an int16_t * cudf::column. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -145,7 +157,7 @@ std::unique_ptr extract_hour( * @returns cudf::column of the extracted int16_t minutes * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_minute( +[[deprecated]] std::unique_ptr extract_minute( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -154,6 +166,8 @@ std::unique_ptr extract_minute( * @brief Extracts second from any datetime type and returns an int16_t * cudf::column. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -161,7 +175,7 @@ std::unique_ptr extract_minute( * @returns cudf::column of the extracted int16_t seconds * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_second( +[[deprecated]] std::unique_ptr extract_second( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -173,6 +187,8 @@ std::unique_ptr extract_second( * A millisecond fraction is only the 3 digits that make up the millisecond portion of a duration. * For example, the millisecond fraction of 1.234567890 seconds is 234. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -180,7 +196,7 @@ std::unique_ptr extract_second( * @returns cudf::column of the extracted int16_t milliseconds * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_millisecond_fraction( +[[deprecated]] std::unique_ptr extract_millisecond_fraction( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -192,6 +208,8 @@ std::unique_ptr extract_millisecond_fraction( * A microsecond fraction is only the 3 digits that make up the microsecond portion of a duration. * For example, the microsecond fraction of 1.234567890 seconds is 567. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -199,7 +217,7 @@ std::unique_ptr extract_millisecond_fraction( * @returns cudf::column of the extracted int16_t microseconds * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_microsecond_fraction( +[[deprecated]] std::unique_ptr extract_microsecond_fraction( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); @@ -211,6 +229,8 @@ std::unique_ptr extract_microsecond_fraction( * A nanosecond fraction is only the 3 digits that make up the nanosecond portion of a duration. * For example, the nanosecond fraction of 1.234567890 seconds is 890. * + * @deprecated Deprecated in 24.12, to be removed in 25.02 + * * @param column cudf::column_view of the input datetime values * @param stream CUDA stream used for device memory operations and kernel launches * @param mr Device memory resource used to allocate device memory of the returned column @@ -218,7 +238,7 @@ std::unique_ptr extract_microsecond_fraction( * @returns cudf::column of the extracted int16_t nanoseconds * @throw cudf::logic_error if input column datatype is not TIMESTAMP */ -std::unique_ptr extract_nanosecond_fraction( +[[deprecated]] std::unique_ptr extract_nanosecond_fraction( cudf::column_view const& column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); diff --git a/cpp/tests/datetime/datetime_ops_test.cpp b/cpp/tests/datetime/datetime_ops_test.cpp index 44f99adc0e9..1d1deb42a51 100644 --- a/cpp/tests/datetime/datetime_ops_test.cpp +++ b/cpp/tests/datetime/datetime_ops_test.cpp @@ -52,16 +52,26 @@ TYPED_TEST(NonTimestampTest, TestThrowsOnNonTimestamp) cudf::data_type dtype{cudf::type_to_id()}; cudf::column col{dtype, 0, rmm::device_buffer{}, rmm::device_buffer{}, 0}; - EXPECT_THROW(extract_year(col), cudf::logic_error); - EXPECT_THROW(extract_month(col), cudf::logic_error); - EXPECT_THROW(extract_day(col), cudf::logic_error); - EXPECT_THROW(extract_weekday(col), cudf::logic_error); - EXPECT_THROW(extract_hour(col), cudf::logic_error); - EXPECT_THROW(extract_minute(col), cudf::logic_error); - EXPECT_THROW(extract_second(col), cudf::logic_error); - EXPECT_THROW(extract_millisecond_fraction(col), cudf::logic_error); - EXPECT_THROW(extract_microsecond_fraction(col), cudf::logic_error); - EXPECT_THROW(extract_nanosecond_fraction(col), cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::YEAR), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::MONTH), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::DAY), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::WEEKDAY), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::HOUR), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::MINUTE), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::SECOND), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::MILLISECOND), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::MICROSECOND), + cudf::logic_error); + EXPECT_THROW(extract_datetime_component(col, cudf::datetime::datetime_component::NANOSECOND), + cudf::logic_error); EXPECT_THROW(last_day_of_month(col), cudf::logic_error); EXPECT_THROW(day_of_year(col), cudf::logic_error); EXPECT_THROW(add_calendrical_months(col, *cudf::make_empty_column(cudf::type_id::INT16)), @@ -104,96 +114,6 @@ TEST_F(BasicDatetimeOpsTest, TestExtractingDatetimeComponents) 987234623 // 1970-01-01 00:00:00.987234623 GMT }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_year(timestamps_D), - fixed_width_column_wrapper{1965, 2018, 2023}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_year(timestamps_s), - fixed_width_column_wrapper{1965, 2018, 2023}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_year(timestamps_ms), - fixed_width_column_wrapper{1965, 2018, 2023}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_year(timestamps_ns), - fixed_width_column_wrapper{1969, 1970, 1970}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_month(timestamps_D), - fixed_width_column_wrapper{10, 7, 1}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_month(timestamps_s), - fixed_width_column_wrapper{10, 7, 1}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_month(timestamps_ms), - fixed_width_column_wrapper{10, 7, 1}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_month(timestamps_ns), - fixed_width_column_wrapper{12, 1, 1}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_day(timestamps_D), - fixed_width_column_wrapper{26, 4, 25}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_day(timestamps_s), - fixed_width_column_wrapper{26, 4, 25}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_day(timestamps_ms), - fixed_width_column_wrapper{26, 4, 25}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_day(timestamps_ns), - fixed_width_column_wrapper{31, 1, 1}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_weekday(timestamps_D), - fixed_width_column_wrapper{2, 3, 3}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_weekday(timestamps_s), - fixed_width_column_wrapper{2, 3, 3}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_weekday(timestamps_ms), - fixed_width_column_wrapper{2, 3, 3}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_weekday(timestamps_ms), - fixed_width_column_wrapper{2, 3, 3}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_hour(timestamps_D), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_hour(timestamps_s), - fixed_width_column_wrapper{14, 12, 7}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_hour(timestamps_ms), - fixed_width_column_wrapper{14, 12, 7}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_hour(timestamps_ns), - fixed_width_column_wrapper{23, 0, 0}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_minute(timestamps_D), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_minute(timestamps_s), - fixed_width_column_wrapper{1, 0, 32}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_minute(timestamps_ms), - fixed_width_column_wrapper{1, 0, 32}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_minute(timestamps_ns), - fixed_width_column_wrapper{59, 0, 0}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_second(timestamps_D), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_second(timestamps_s), - fixed_width_column_wrapper{12, 0, 12}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_second(timestamps_ms), - fixed_width_column_wrapper{12, 0, 12}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_minute(timestamps_ns), - fixed_width_column_wrapper{59, 0, 0}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_millisecond_fraction(timestamps_D), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_millisecond_fraction(timestamps_s), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_millisecond_fraction(timestamps_ms), - fixed_width_column_wrapper{762, 0, 929}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_millisecond_fraction(timestamps_ns), - fixed_width_column_wrapper{976, 23, 987}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_microsecond_fraction(timestamps_D), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_microsecond_fraction(timestamps_s), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_microsecond_fraction(timestamps_ms), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_microsecond_fraction(timestamps_ns), - fixed_width_column_wrapper{675, 432, 234}); - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_nanosecond_fraction(timestamps_D), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_nanosecond_fraction(timestamps_s), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_nanosecond_fraction(timestamps_ms), - fixed_width_column_wrapper{0, 0, 0}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_nanosecond_fraction(timestamps_ns), - fixed_width_column_wrapper{766, 424, 623}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL( *extract_datetime_component(timestamps_D, cudf::datetime::datetime_component::YEAR), fixed_width_column_wrapper{1965, 2018, 2023}); @@ -346,16 +266,29 @@ TYPED_TEST(TypedDatetimeOpsTest, TestEmptyColumns) cudf::column int16s{int16s_dtype, 0, rmm::device_buffer{}, rmm::device_buffer{}, 0}; cudf::column timestamps{timestamps_dtype, 0, rmm::device_buffer{}, rmm::device_buffer{}, 0}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_year(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_month(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_day(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_weekday(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_hour(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_minute(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_second(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_millisecond_fraction(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_microsecond_fraction(timestamps), int16s); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_nanosecond_fraction(timestamps), int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::YEAR), int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::MONTH), int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::DAY), int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::WEEKDAY), int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::HOUR), int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::MINUTE), int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::SECOND), int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::MILLISECOND), + int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::MICROSECOND), + int16s); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::NANOSECOND), + int16s); } TYPED_TEST(TypedDatetimeOpsTest, TestExtractingGeneratedDatetimeComponents) @@ -385,13 +318,27 @@ TYPED_TEST(TypedDatetimeOpsTest, TestExtractingGeneratedDatetimeComponents) expected_seconds = fixed_width_column_wrapper{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; } - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_year(timestamps), expected_years); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_month(timestamps), expected_months); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_day(timestamps), expected_days); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_weekday(timestamps), expected_weekdays); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_hour(timestamps), expected_hours); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_minute(timestamps), expected_minutes); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_second(timestamps), expected_seconds); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::YEAR), + expected_years); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::MONTH), + expected_months); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::DAY), + expected_days); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::WEEKDAY), + expected_weekdays); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::HOUR), + expected_hours); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::MINUTE), + expected_minutes); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::SECOND), + expected_seconds); } TYPED_TEST(TypedDatetimeOpsTest, TestExtractingGeneratedNullableDatetimeComponents) @@ -441,13 +388,27 @@ TYPED_TEST(TypedDatetimeOpsTest, TestExtractingGeneratedNullableDatetimeComponen {true, false, true, false, true, false, true, false, true, false}}; } - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_year(timestamps), expected_years); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_month(timestamps), expected_months); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_day(timestamps), expected_days); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_weekday(timestamps), expected_weekdays); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_hour(timestamps), expected_hours); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_minute(timestamps), expected_minutes); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_second(timestamps), expected_seconds); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::YEAR), + expected_years); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::MONTH), + expected_months); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::DAY), + expected_days); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::WEEKDAY), + expected_weekdays); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::HOUR), + expected_hours); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::MINUTE), + expected_minutes); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *extract_datetime_component(timestamps, cudf::datetime::datetime_component::SECOND), + expected_seconds); } TEST_F(BasicDatetimeOpsTest, TestLastDayOfMonthWithSeconds) diff --git a/cpp/tests/streams/datetime_test.cpp b/cpp/tests/streams/datetime_test.cpp index 82629156fa6..29b302c3637 100644 --- a/cpp/tests/streams/datetime_test.cpp +++ b/cpp/tests/streams/datetime_test.cpp @@ -35,52 +35,62 @@ class DatetimeTest : public cudf::test::BaseFixture { TEST_F(DatetimeTest, ExtractYear) { - cudf::datetime::extract_year(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::YEAR, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractMonth) { - cudf::datetime::extract_month(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::MONTH, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractDay) { - cudf::datetime::extract_day(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::DAY, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractWeekday) { - cudf::datetime::extract_weekday(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::WEEKDAY, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractHour) { - cudf::datetime::extract_hour(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::HOUR, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractMinute) { - cudf::datetime::extract_minute(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::MINUTE, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractSecond) { - cudf::datetime::extract_second(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::SECOND, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractMillisecondFraction) { - cudf::datetime::extract_millisecond_fraction(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::MILLISECOND, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractMicrosecondFraction) { - cudf::datetime::extract_microsecond_fraction(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::MICROSECOND, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, ExtractNanosecondFraction) { - cudf::datetime::extract_nanosecond_fraction(timestamps, cudf::test::get_default_stream()); + cudf::datetime::extract_datetime_component( + timestamps, cudf::datetime::datetime_component::NANOSECOND, cudf::test::get_default_stream()); } TEST_F(DatetimeTest, LastDayOfMonth)