Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

Jefffrey
Copy link
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
Copy link
Contributor

@alamb alamb left a comment

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

@@ -754,6 +755,39 @@ async fn test_extract_epoch() -> Result<()> {
"946684800.0"
);
test_expression!("extract(epoch from NULL::timestamp)", "NULL");
// date
Copy link
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
# for free to join this conversation on GitHub. Already have an account? # 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