Skip to content

Implement EXTRACT expression with week, month, day, hour#1974

Merged
alamb merged 1 commit into
apache:masterfrom
Ted-Jiang:issue_1375_1
Mar 10, 2022
Merged

Implement EXTRACT expression with week, month, day, hour#1974
alamb merged 1 commit into
apache:masterfrom
Ted-Jiang:issue_1375_1

Conversation

@Ted-Jiang

@Ted-Jiang Ted-Jiang commented Mar 10, 2022

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #1896.

Rationale for this change

Already add compute method in arrow-rs PR.
But found

Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'
 SQL(ParserError("Expected date/time field, found: WEEK"))'

will fix EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00')) in sqlparser

What changes are included in this PR?

Are there any user-facing changes?

@Ted-Jiang

Copy link
Copy Markdown
Member Author

@alamb @liukun4515 PTAL

@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.

Thanks @Ted-Jiang and @jimexist

);
test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");

//TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

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.

Many keywords got added in apache/datafusion-sqlparser-rs#427 from @mobuchowski (👋 ) but sadly it seems to be missing week 😭

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can't believe I missed it... 😞

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 didn't meant to make you feel bad @mobuchowski -- mostly I was trying to give you props for adding stuff to sqlparser ;)

@mobuchowski mobuchowski Mar 10, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Don't worry, that's not how I received it 🙂

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.

@Ted-Jiang Maybe you can file a pr to fix this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@liukun4515 @liukun4515 @mobuchowski i would like to add this , it's a good chance to start familiar sqlparser
😊

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.

@alamb alamb merged commit a7598c5 into apache:master Mar 10, 2022
@liukun4515

Copy link
Copy Markdown
Contributor

Sorry for the later response.
@Ted-Jiang

@alamb

alamb commented Mar 12, 2022

Copy link
Copy Markdown
Contributor

Thanks @Ted-Jiang -- I hope to spend some non trivial amount of time this weekend reviewing and merging PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement EXTRACT expression with week, month, day, hour

5 participants