Skip to content

extract(second from dt) should return seconds without fraction #13482

Closed

Description

@findepi

In ANSI SQL, Trino, Snowflake, DuckDB, ... extract(second from a_date_time_value) returns just seconds (integer number 0-59 inclusive), which is consistent with other extraction of other fields like minute (meaning minute-of-hour), hour (meaning hour-of-day), etc. especially when sub-second fields are also supported.

in DataFusion extract(second from dt) returns second with fraction (as in PostgreSQL).
We should probably change it to return just second without fraction, especially given that the fraction part can be extracted with e.g. extract(millisecond ..) field

cc @jayzhan211 @comphead

Activity

  1. jayzhan211 commented on Nov 19, 2024

    @jayzhan211
    Contributor

    Given there are other systems return integer too, I'm fine if we return int for second and mili/micro/nano second

  2. jayzhan211 commented on Nov 20, 2024

    @jayzhan211
    Contributor

    I found that nanosecond is neither supported in postgres and duckdb. If it is true, I prefer to remove it.

  3. comphead commented on Nov 20, 2024

    @comphead
    Contributor

    I dont remember why we do support nanos although most of systems do not.
    not sure if we need to remove it if it works it can probably be helpful for someone if they store and do maths exacly on nanosecond level, not sure what the real world use case could be. Perhaps scientific thing

  4. jayzhan211 commented on Nov 21, 2024

    @jayzhan211
    Contributor

    I dont remember why we do support nanos although most of systems do not. not sure if we need to remove it if it works it can probably be helpful for someone if they store and do maths exacly on nanosecond level, not sure what the real world use case could be. Perhaps scientific thing

    If they really need nanosecond precision, they could customize the function for themselves

  5. findepi commented on Nov 22, 2024

    @findepi
    MemberAuthor

    i don't know why other systems don't support nanosecond field while supporting nanosecond precision timestamps. maybe that's a legacy thing?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions