Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement extract_datetime_component in libcudf/pylibcudf #16776

Merged

Conversation

brandon-b-miller
Copy link
Contributor

Closes #16735

@brandon-b-miller brandon-b-miller requested review from a team as code owners September 9, 2024 19:57
@github-actions github-actions bot added libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API. CMake CMake build issue labels Sep 9, 2024
cpp/include/cudf/datetime.hpp Outdated Show resolved Hide resolved
cpp/include/cudf/datetime.hpp Outdated Show resolved Hide resolved
{
CUDF_FUNC_RANGE();
switch (component) {
case datetime_component::YEAR: return extract_year(column, mr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we plan to deprecate functions like extract_year, we should reverse the call stack here.

This function should dispatch to return detail::apply_datetime_op<detail::extract_component_operator<...>, cudf::type_id::INT16>(column, stream, mr); based on the enum, and we should make extract_year call extract_datetime_component(column, datetime_component::YEAR, mr);.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made these changes with the latest commits - let me know if this is along the lines of what you meant.

cpp/src/datetime/datetime_ops.cu Outdated Show resolved Hide resolved
python/pylibcudf/pylibcudf/datetime.pyx Show resolved Hide resolved
cpp/include/cudf/datetime.hpp Outdated Show resolved Hide resolved
cpp/src/datetime/datetime_ops.cu Outdated Show resolved Hide resolved
python/pylibcudf/pylibcudf/datetime.pyx Show resolved Hide resolved
from libcpp.memory cimport unique_ptr
from pylibcudf.libcudf.column.column cimport column
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.scalar.scalar cimport scalar


cdef extern from "cudf/datetime.hpp" namespace "cudf::datetime" nogil:
cpdef enum class datetime_component(int32_t):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @bdice suggests, make the underlying type explicit in the C++ and then match it here.

Comment on lines 13 to 16
pa.scalar(1694004645123456789, pa.timestamp("ns")),
pa.scalar(1544024645123456789, pa.timestamp("ns")),
pa.scalar(1682342345346235434, pa.timestamp("ns")),
pa.scalar(1445624625623452452, pa.timestamp("ns")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we can't use conversion from datetime? It's also not obvious to me that these are the same timepoints as before.

@github-actions github-actions bot added the pylibcudf Issues specific to the pylibcudf package label Sep 25, 2024
@brandon-b-miller brandon-b-miller added feature request New feature or request non-breaking Non-breaking change labels Sep 25, 2024
Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do a little tidy-up in the implementation on the C++ side, I think.

cpp/src/datetime/datetime_ops.cu Outdated Show resolved Hide resolved
cpp/src/datetime/datetime_ops.cu Outdated Show resolved Hide resolved
cpp/src/datetime/datetime_ops.cu Outdated Show resolved Hide resolved
@brandon-b-miller brandon-b-miller changed the base branch from branch-24.10 to branch-24.12 October 1, 2024 23:42
@github-actions github-actions bot added the cudf.polars Issues specific to cudf.polars label Oct 2, 2024
@brandon-b-miller
Copy link
Contributor Author

I'm having a little trouble figuring out why this warning/error is being generated during the docs build:

WARNING: cpp:func reference target not found: cudf::datetime::extract_datetime_component

Can anyone spot what I've got wrong? Maybe @bdice

@bdice
Copy link
Contributor

bdice commented Oct 2, 2024

I'm having a little trouble figuring out why this warning/error is being generated during the docs build:

WARNING: cpp:func reference target not found: cudf::datetime::extract_datetime_component

Can anyone spot what I've got wrong? Maybe @bdice

I'm not sure. Maybe try :cpp:func:`extract_datetime_component`.

@Matt711
Copy link
Contributor

Matt711 commented Oct 2, 2024

I'm having a little trouble figuring out why this warning/error is being generated during the docs build:

WARNING: cpp:func reference target not found: cudf::datetime::extract_datetime_component

Can anyone spot what I've got wrong? Maybe @bdice

I built the docs locally and extract_datetime_component does not show up in the libcudf API docs.

Edit: It should be in this part of the docs, but it isn't

@Matt711
Copy link
Contributor

Matt711 commented Oct 2, 2024

I noticed extract_datetime_component is not included in this header file. Is this file autogenerated? If not, we may need to add it there.

Copy link
Contributor

@Matt711 Matt711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the python changes. This begs the question, why did cudf::extract_datetime_component work, but not cudf::datetime::extract_datetime_component? It looks like extract_datetime_component is in the datetime namespace.

cpp/include/cudf/datetime.hpp Outdated Show resolved Hide resolved
@brandon-b-miller
Copy link
Contributor Author

/merge

Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few requests / questions.

cpp/include/cudf/datetime.hpp Outdated Show resolved Hide resolved
cpp/src/datetime/datetime_ops.cu Show resolved Hide resolved
python/pylibcudf/pylibcudf/datetime.pyx Show resolved Hide resolved
python/pylibcudf/pylibcudf/libcudf/datetime.pxd Outdated Show resolved Hide resolved
@brandon-b-miller brandon-b-miller requested a review from bdice October 4, 2024 17:14
@brandon-b-miller
Copy link
Contributor Author

@bdice any last thoughts here?

Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My last round of comments was addressed -- approving.

@rapids-bot rapids-bot bot merged commit 2d02bdc into rapidsai:branch-24.12 Oct 7, 2024
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMake CMake build issue cudf.polars Issues specific to cudf.polars feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change pylibcudf Issues specific to the pylibcudf package Python Affects Python cuDF API.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[FEA] Consider supporting extract_datetime_component in libcudf
4 participants