Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

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 Physical Expressions 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
22 checks passed
@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 Physical Expressions
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