nrc opened a new pull request, #6246:
URL: https://github.com/apache/arrow-rs/pull/6246
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax. For example `Closes #123`
indicates that this PR will close issue #123.
-->
Closes #6245.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
AFAICT, the only interesting part of this change is choosing which
conversions between durations and date parts to allow. All durations represent
time in seconds or smaller, which is much simpler than intervals. Because
different months have different lengths, I think it is invalid to convert a
duration to a month or longer. However, I have chosen to allow conversions to
days and weeks, even though the conversion from *seconds to days is not
supported with intervals. I believe the intention of date_part is not primarily
to convert times but to extract an element from some kind of time
representation. Intervals separate time within a day from number of days (or
longer) and so conversion is forbidden. Durations do not make that distinction,
so conversion should be allowed.
There's a lot of similar code in this PR and it is tempting to reduce that
with macro magic. I opted for simpler but longer code, but I'd be happy to
throw in some macros if you prefer a more concise style.
# Are there any user-facing changes?
Some uses of `date_part` which previously errored, now give reasonable
results.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]