Skip to content

Support for extract(epoch from date) for Date32 and Date64 - #8695

Merged
comphead merged 1 commit into
apache:mainfrom
Jefffrey:extract_epoch_from_date
Jan 2, 2024
Merged

comphead merged 1 commit into
apache:mainfrom
Jefffrey:extract_epoch_from_date

Conversation

@Jefffrey

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #8694

Rationale for this change

What changes are included in this PR?

Support extracting seconds since epoch for Date32 and Date64 types

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates core Core DataFusion crate labels Dec 31, 2023

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👨‍🍳 👌 -- very nice @Jefffrey

Thank you for this contribution

"946684800.0"
);
test_expression!("extract(epoch from NULL::timestamp)", "NULL");
// date

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I double checked this is consistent with postgres:

postgres=# select extract(epoch from '1970-01-01'::date);
 extract
---------
       0
(1 row)

postgres=# select extract(epoch from '1970-01-02'::date);
 extract
---------
   86400
(1 row)

postgres=# select extract(epoch from '1969-12-31'::date);
 extract
---------
  -86400
(1 row)

@comphead
comphead merged commit 9a6cc88 into apache:main Jan 2, 2024
@Jefffrey
Jefffrey deleted the extract_epoch_from_date branch January 2, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extract(epoch from date) fails for Date32 and Date64 types

3 participants