Skip to content

Implement to_timestamp_millis etc #355

Closed

Description

@velvia

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
(This section helps Arrow developers understand the context and why for this feature, in addition to the what)

This is a follow up from the discussion in this PR:
apache/arrow#10005

Namely for first class casting to non nanosecond timestamp types and functions supporting those.

There was also a email thread on the list about this.

Describe the solution you'd like
A clear and concise description of what you want to happen.

The proposal is as follows:

  • A function to_timestamp_millis() which converts from the following types:
    • String - converts timestamp strings, just like to_timestamp() except to a TimestampArray with Milliseconds
    • Other TimestampArray's - casts them with truncation as necessary to Millisecond resolution
    • Int64 - assumes the values are already millisecond resolution and just does a cast to TimestampArray with Millis
  • Similar functions to_timestamp_micros() and to_timestamp_seconds()

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

We considered in the above threads to reuse datetime_trunc() for this purpose.

The issues with using datetime_trunc() are as follows:

  • Datetime trunc is primarily used for truncating an existing timestamp to say millis, seconds, hours, minutes, etc., and not for changing the type of the date time.
  • Without modifying the existing signature it would not be possible to disambiguate between, for example, using datetime_trunc to truncate to seconds but keeping nanosecond resolution, or actually casting to Timestamp type with Seconds resolution
  • Additional infrastructure is needed in the function evaluation code to support evaluating text/constant arguments in function type output determination, right now the output type is determined based on the input types alone

Additional context
Add any other context or screenshots about the feature request here.

Activity

  1. velvia commented on May 17, 2021

    @velvia
    ContributorAuthor

    /cc @alamb

  2. msathis commented on May 21, 2021

    @msathis
    Contributor

    I can pick this if no one else is working on 👍

  3. velvia commented on May 21, 2021

    @velvia
    ContributorAuthor
  4. msathis commented on May 22, 2021

    @msathis
    Contributor

    @velvia It makes sense for you to do it since you're already familiar with it. 👍 💯

  5. velvia commented on Jun 10, 2021

    @velvia
    ContributorAuthor

    Quick update: starting on the implementation, hopefully should be done in a few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions