datetime.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cudf/types.hpp>
21 #include <cudf/utilities/export.hpp>
23 
24 #include <rmm/cuda_stream_view.hpp>
25 
26 #include <memory>
27 
33 namespace CUDF_EXPORT cudf {
34 namespace datetime {
44 enum class datetime_component : uint8_t {
45  YEAR,
46  MONTH,
47  DAY,
48  WEEKDAY,
49  HOUR,
50  MINUTE,
51  SECOND,
52  MILLISECOND,
53  MICROSECOND,
54  NANOSECOND
55 };
56 
70 [[deprecated]] std::unique_ptr<cudf::column> extract_year(
74 
88 [[deprecated]] std::unique_ptr<cudf::column> extract_month(
92 
106 [[deprecated]] std::unique_ptr<cudf::column> extract_day(
107  cudf::column_view const& column,
110 
124 [[deprecated]] std::unique_ptr<cudf::column> extract_weekday(
125  cudf::column_view const& column,
128 
142 [[deprecated]] std::unique_ptr<cudf::column> extract_hour(
143  cudf::column_view const& column,
146 
160 [[deprecated]] std::unique_ptr<cudf::column> extract_minute(
161  cudf::column_view const& column,
164 
178 [[deprecated]] std::unique_ptr<cudf::column> extract_second(
179  cudf::column_view const& column,
182 
199 [[deprecated]] std::unique_ptr<cudf::column> extract_millisecond_fraction(
200  cudf::column_view const& column,
203 
220 [[deprecated]] std::unique_ptr<cudf::column> extract_microsecond_fraction(
221  cudf::column_view const& column,
224 
241 [[deprecated]] std::unique_ptr<cudf::column> extract_nanosecond_fraction(
242  cudf::column_view const& column,
245 
258 std::unique_ptr<cudf::column> extract_datetime_component(
259  cudf::column_view const& column,
260  datetime_component component,
263  // end of group
282 std::unique_ptr<cudf::column> last_day_of_month(
283  cudf::column_view const& column,
286 
298 std::unique_ptr<cudf::column> day_of_year(
299  cudf::column_view const& column,
302 
334 std::unique_ptr<cudf::column> add_calendrical_months(
335  cudf::column_view const& timestamps,
336  cudf::column_view const& months,
339 
371 std::unique_ptr<cudf::column> add_calendrical_months(
372  cudf::column_view const& timestamps,
373  cudf::scalar const& months,
376 
391 std::unique_ptr<cudf::column> is_leap_year(
392  cudf::column_view const& column,
395 
409 std::unique_ptr<cudf::column> days_in_month(
410  cudf::column_view const& column,
413 
427 std::unique_ptr<cudf::column> extract_quarter(
428  cudf::column_view const& column,
431 
436 enum class rounding_frequency : int32_t {
437  DAY,
438  HOUR,
439  MINUTE,
440  SECOND,
441  MILLISECOND,
442  MICROSECOND,
443  NANOSECOND
444 };
445 
457 std::unique_ptr<cudf::column> ceil_datetimes(
458  cudf::column_view const& column,
459  rounding_frequency freq,
462 
474 std::unique_ptr<cudf::column> floor_datetimes(
475  cudf::column_view const& column,
476  rounding_frequency freq,
479 
491 std::unique_ptr<cudf::column> round_datetimes(
492  cudf::column_view const& column,
493  rounding_frequency freq,
496  // end of group
498 
499 } // namespace datetime
500 } // namespace CUDF_EXPORT cudf
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
A container of nullable device data as a column of elements.
Definition: column.hpp:47
An owning class to represent a singular value.
Definition: scalar.hpp:49
std::unique_ptr< cudf::column > add_calendrical_months(cudf::column_view const &timestamps, cudf::scalar const &months, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Adds or subtracts a number of months from the datetime type and returns a timestamp column that is of...
std::unique_ptr< cudf::column > floor_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Round datetimes down to the nearest multiple of the given frequency.
std::unique_ptr< cudf::column > last_day_of_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())
Computes the last day of the month in datetime type and returns a TIMESTAMP_DAYS cudf::column.
std::unique_ptr< cudf::column > days_in_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())
Extract the number of days in the month.
std::unique_ptr< cudf::column > round_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Round datetimes to the nearest multiple of the given frequency.
std::unique_ptr< cudf::column > is_leap_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())
Check if the year of the given date is a leap year.
std::unique_ptr< cudf::column > day_of_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())
Computes the day number since the start of the year from the datetime and returns an int16_t cudf::co...
std::unique_ptr< cudf::column > extract_quarter(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())
Returns the quarter of the date.
rounding_frequency
Fixed frequencies supported by datetime rounding functions ceil, floor, round.
Definition: datetime.hpp:436
std::unique_ptr< cudf::column > ceil_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Round datetimes up to the nearest multiple of the given frequency.
std::unique_ptr< cudf::column > 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())
Extracts year from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > 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())
Extracts nanosecond fraction from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > 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())
Extracts day from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > 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())
Extracts millisecond fraction from any datetime type and returns an int16_t cudf::column.
datetime_component
Types of datetime components that may be extracted.
Definition: datetime.hpp:44
std::unique_ptr< cudf::column > 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())
Extracts hour from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_datetime_component(cudf::column_view const &column, datetime_component component, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Extracts the specified datetime component from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > 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())
Extracts a weekday from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > 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())
Extracts minute from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > 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())
Extracts second from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > 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())
Extracts month from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > 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())
Extracts microsecond fraction from any datetime type and returns an int16_t cudf::column.
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
cuDF interfaces
Definition: aggregation.hpp:35
Type declarations for libcudf.