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 extract second and minute in expr. #1901

Merged
merged 1 commit into from
Mar 3, 2022

Conversation

Ted-Jiang
Copy link
Member

Which issue does this PR close?

Closes #1900.

Rationale for this change

What changes are included in this PR?

DataFusion CLI v7.0.0
❯ select EXTRACT(minute FROM to_timestamp('2020-09-08T12:13:14+00:00'));
+-------------------------------------------------------------------------+
| datepart(Utf8("MINUTE"),totimestamp(Utf8("2020-09-08T12:13:14+00:00"))) |
+-------------------------------------------------------------------------+
| 13                                                                      |
+-------------------------------------------------------------------------+
1 row in set. Query took 0.005 seconds.
❯ select EXTRACT(second FROM to_timestamp('2020-09-08T12:13:14+00:00'));
+-------------------------------------------------------------------------+
| datepart(Utf8("SECOND"),totimestamp(Utf8("2020-09-08T12:13:14+00:00"))) |
+-------------------------------------------------------------------------+
| 14                                                                      |
+-------------------------------------------------------------------------+
1 row in set. Query took 0.002 seconds.
❯

Are there any user-facing changes?

Will add API week and month in arrow-rs then support in datafusion.

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Mar 2, 2022
@@ -351,6 +351,8 @@ pub fn date_part(args: &[ColumnarValue]) -> Result<ColumnarValue> {
let arr = match date_part.to_lowercase().as_str() {
"hour" => extract_date_part!(array, temporal::hour),
"year" => extract_date_part!(array, temporal::year),
"minute" => extract_date_part!(array, temporal::minute),
Copy link
Contributor

@liukun4515 liukun4515 Mar 2, 2022

Choose a reason for hiding this comment

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

Do we need to support month and other fields?
As described in the doc https://www.postgresql.org/docs/9.1/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT, There are many fields needed to support.
I think we can support the kernel following this https://github.com/apache/arrow-rs/pull/1376/files in the arrow-rs before next release of arrow-rs.
We can implement the fields which are most used first.

Copy link
Member Author

@Ted-Jiang Ted-Jiang Mar 3, 2022

Choose a reason for hiding this comment

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

Thanks, i will a 'mount 'API in arrow-rs arrow-pr

Copy link
Contributor

@alamb alamb Mar 3, 2022

Choose a reason for hiding this comment

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

PR is apache/arrow-rs#1388 for anyone who cares

@alamb
Copy link
Contributor

alamb commented Mar 3, 2022

Thanks @Ted-Jiang @xudong963 and @liukun4515 !

@alamb alamb merged commit bc42ead into apache:master Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support extract second and minute in expr.
4 participants