Skip to content

change extract return types to decimal to align with postgres #3996

Open

Description

@waitingkuo

extract currently returns i32 which might loss some information

❯ select extract(second from timestamp '2000-01-01T00:00:00.1');
+--------------------------------------------------------+
| datepart(Utf8("SECOND"),Utf8("2000-01-01T00:00:00.1")) |
+--------------------------------------------------------+
| 0                                                      |
+--------------------------------------------------------+
1 row in set. Query took 0.000 seconds.

while postgresql returns decimal

willy=# select extract(second from timestamp '2000-01-01T00:00:00.1');
 extract  
----------
 0.100000
(1 row)

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

change it to decimal

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

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

Activity

  1. tustvold commented on Oct 30, 2022

    @tustvold
    Contributor

    This likely will want to wait until decimal support is more consistent - see #4036

  2. comphead commented on Dec 6, 2022

    @comphead
    Contributor

    @waitingkuo looks like #4385 will address this ticket? Tests return seconds as floats

  3. waitingkuo commented on Dec 6, 2022

    @waitingkuo
    ContributorAuthor

    @comphead this is to align with postgresql to output decimal instead of decimal which could prevent something like this

    ❯ select date_part('millisecond', timestamp '2000-01-01T00:00:09.123456');
    +------------------------------------------------------------------+
    | datepart(Utf8("millisecond"),Utf8("2000-01-01T00:00:09.123456")) |
    +------------------------------------------------------------------+
    | 9123.455999999998                                                |
    +------------------------------------------------------------------+
    1 row in set. Query took 0.002 seconds.

    note that this datafusion-cli is from the date_part_f64 branch

  4. changed the title [-]change `extract` return types to decimal[/-] [+]change `extract` return types to decimal to align with postgres[/+] on Jan 17, 2023
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