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

Support as_datetime::<DataType::Interval~> #4969

Closed
NiwakaDev opened this issue Oct 21, 2023 · 2 comments
Closed

Support as_datetime::<DataType::Interval~> #4969

NiwakaDev opened this issue Oct 21, 2023 · 2 comments
Labels
development-process Related to development process of arrow-rs enhancement Any new improvement worthy of a entry in the changelog

Comments

@NiwakaDev
Copy link

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

I'd like to call as_datetime::<DataType::Interval~> to address apache/datafusion#7097.

Is it possible to return Some(~), not None?:

DataType::Interval(_) => None,

Also, is it possible to uncomment the following lines?:

// impl ArrowTemporalType for IntervalYearMonthType {}
// impl ArrowTemporalType for IntervalDayTimeType {}
// impl ArrowTemporalType for IntervalMonthDayNanoType {}

Describe the solution you'd like

Describe alternatives you've considered

Additional context

@NiwakaDev NiwakaDev added the enhancement Any new improvement worthy of a entry in the changelog label Oct 21, 2023
@tustvold
Copy link
Contributor

A DateTime is a point in time, whereas an interval is not, I'm not entirely sure how this would work?

@Jefffrey
Copy link
Contributor

I don't think this is the correct way to go about implementing the extract(x from interval) functionality, since as mentioned there isn't a well defined way to convert an interval into a datetime.

Would probably need to modify the existing temporal kernels:

/// Extracts the years of a given temporal primitive array as an array of integers
pub fn year<T>(array: &PrimitiveArray<T>) -> Result<Int32Array, ArrowError>
where
T: ArrowTemporalType + ArrowNumericType,
i64: From<T::Native>,
{
time_fraction_internal(array, "year", |t| t.year())
}

To be able to extract from intervals directly, instead of attempting to convert intervals to datetime to then leverage existing functionality of these kernels (which only currently work for datetimes).

That or implement the logic entirely on Datafusion's side.

Note there is an issue on Datafusion repo that relates to this functionality: apache/datafusion#6327

@tustvold tustvold closed this as not planned Won't fix, can't repro, duplicate, stale Jan 1, 2024
@tustvold tustvold added the development-process Related to development process of arrow-rs label Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development-process Related to development process of arrow-rs enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

No branches or pull requests

3 participants