GH-33143: [C++] Kernel to convert timestamp with timezone to wall time#34208
GH-33143: [C++] Kernel to convert timestamp with timezone to wall time#34208westonpace merged 4 commits intoapache:mainfrom
Conversation
cdcb8c6 to
4a3bded
Compare
4a3bded to
a5185a2
Compare
westonpace
left a comment
There was a problem hiding this comment.
Thanks, as always, for your diligence here.
docs/source/cpp/compute.rst
Outdated
| +--------------------+------------+-------------------+---------------+----------------------------+-------+ | ||
| | is_leap_year | Unary | Timestamp, Date | Boolean | | | | ||
| +--------------------+------------+-------------------+---------------+----------------------------+-------+ | ||
| | local_time | Unary | Timestamp | Timestamp | | | |
There was a problem hiding this comment.
Can we add a note? I don't think it will be obvious what this function does.
There was a problem hiding this comment.
Good point. Added some text and moved under the Timezone handling chapter. I'll trigger a docs preview to make sure I've got the markup right.
| /// \return the resulting datum | ||
| /// | ||
| /// \since 12.0.0 | ||
| /// \note API not yet finalized |
There was a problem hiding this comment.
I was going to suggest removing this but now I see this is everywhere. Hmm.... :( I'm not sure how true this is these days.
There was a problem hiding this comment.
Well, you could see it as an opportunity to sync the API with substrait :D
|
@github-actions crossbow submit preview-docs |
|
Revision: 115347e Submitted crossbow builds: ursacomputing/crossbow @ actions-ffd22963ef
|
westonpace
left a comment
There was a problem hiding this comment.
Thanks, the description is clear to me. Two small grammar nits.
Co-authored-by: Weston Pace <[email protected]>
|
@github-actions crossbow submit preview-docs |
|
Thanks @westonpace, merged the grammar changes. |
|
Revision: cf2eb81 Submitted crossbow builds: ursacomputing/crossbow @ actions-760f71e893
|
|
The test failures seem unrelated (I've opened a new issue for one which appears to be an intermittent segfault). |
|
Benchmark runs are scheduled for baseline = ae1f98f and contender = daa5e26. daa5e26 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
|
Nice to see this functionality! One comment on the name of the function: given that "local_time" could also be interpreted as returning just the time (a For reference, in Joda they call this |
jorisvandenbossche
left a comment
There was a problem hiding this comment.
And a few doc comments/questions
| "cannot be found in the timezone database."), | ||
| "If timezone is not given then timezone naive timestamp in UTC are\n" | ||
| "returned. An error is returned if the values have a defined timezone\n" | ||
| "but it cannot be found in the timezone database."), |
There was a problem hiding this comment.
Was this change intentional? Or was it meant to be in local_time_doc?
(and if intentional, why only for round and not ceil/floor?)
|
|
||
| const FunctionDoc local_time_doc{ | ||
| "Convert timestamp to a timezone-naive local time timestamp", | ||
| ("LocalTime converts a timestamp to a local time of timestamps timezone\n" |
There was a problem hiding this comment.
Something is missing in this sentence?
| "and removes timezone metadata. If input is in UTC or doesn't have\n" | ||
| "timezone metadata, it is returned as is.\n" |
There was a problem hiding this comment.
Returned "as is" is not entirely correct for UTC, as I assume the "UTC" timezone is still removed?
|
Thanks for the review @jorisvandenbossche. I've opened a PR to address it: #34263. |
…rnel (#34263) ### Rationale for this change A better naming for local_time kernel was proposed in post merge review of #34208. ### What changes are included in this PR? Change `local_time` to `local_timestamp` and related docs/test changes. ### Are these changes tested? Yes. ### Are there any user-facing changes? Changing `local_time` to `local_timestamp` is a user facing change. But since it was not yet released we can probably treat it as non-breaking. * Closes: #33143 Authored-by: Rok Mihevc <[email protected]> Signed-off-by: Rok Mihevc <[email protected]>
Rationale for this change
We have
assume_timezoneto go from wall time timestamp to timestamp with a timezone. We might want a reverse operation to go from timestamp with a timezone to wall time.This is not needed for computation within Arrow, but would be needed if an application outsides of Arrow consumes wall time. E.g.: https://stackoverflow.com/questions/73275465/how-to-keep-original-datatime-in-pyarrow-table/73276431
What changes are included in this PR?
This adds a
local_timeC++ kernel.Are these changes tested?
Yes.
Are there any user-facing changes?
Yes,
local_timeC++ kernel is added.