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

feat(parser): Adds support for parsing order by in functions #3566

Merged
merged 11 commits into from
Jun 30, 2022

Conversation

Graphcalibur
Copy link
Contributor

I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • Summarize your change (mandatory)
    • See PR title.

Checklist

  • I have written necessary docs and comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Refer to a related PR or issue link (optional)

Fixes #3434

Graphcalibur and others added 4 commits June 30, 2022 12:16
Co-authored-by: Yuhao Su <31772373+yuhao-su@users.noreply.github.com>
Co-authored-by: Yuhao Su <31772373+yuhao-su@users.noreply.github.com>
@@ -561,7 +561,7 @@ impl Parser {
pub fn parse_function(&mut self, name: ObjectName) -> Result<Expr, ParserError> {
self.expect_token(&Token::LParen)?;
let distinct = self.parse_all_or_distinct()?;
let args = self.parse_optional_args()?;
let (args, order_by) = self.parse_optional_args()?;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check the function name before deciding whether ORDER BY is acceptable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is ok to accept ORDER BY without checking the function name since Postgresql seems to do the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

The check can be done in binder.

@codecov
Copy link

codecov bot commented Jun 30, 2022

Codecov Report

Merging #3566 (448c12e) into main (70cc2f1) will increase coverage by 0.00%.
The diff coverage is 95.45%.

@@           Coverage Diff           @@
##             main    #3566   +/-   ##
=======================================
  Coverage   74.38%   74.38%           
=======================================
  Files         771      771           
  Lines      108701   108714   +13     
=======================================
+ Hits        80861    80872   +11     
- Misses      27840    27842    +2     
Flag Coverage Δ
rust 74.38% <95.45%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/tests/sqlsmith/src/expr.rs 89.47% <ø> (ø)
src/sqlparser/src/parser.rs 92.17% <94.11%> (-0.02%) ⬇️
src/sqlparser/src/ast/mod.rs 89.36% <100.00%> (+0.04%) ⬆️
src/meta/src/manager/id.rs 94.94% <0.00%> (-0.57%) ⬇️
src/common/src/types/ordered_float.rs 24.70% <0.00%> (-0.20%) ⬇️
src/frontend/src/expr/utils.rs 98.99% <0.00%> (+0.25%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

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

rest lgtm

@@ -561,7 +561,7 @@ impl Parser {
pub fn parse_function(&mut self, name: ObjectName) -> Result<Expr, ParserError> {
self.expect_token(&Token::LParen)?;
let distinct = self.parse_all_or_distinct()?;
let args = self.parse_optional_args()?;
let (args, order_by) = self.parse_optional_args()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

The check can be done in binder.

src/sqlparser/src/parser.rs Outdated Show resolved Hide resolved
@Graphcalibur Graphcalibur merged commit edab3f5 into main Jun 30, 2022
@Graphcalibur Graphcalibur deleted the steven/parsing-agg-order branch June 30, 2022 10:29
huangjw806 pushed a commit that referenced this pull request Jul 5, 2022
* feat(parser): Add support for parsing ORDER BY in agg functions

* feat(expr): Fix typo

Co-authored-by: Yuhao Su <31772373+yuhao-su@users.noreply.github.com>

* feat(parser): Fix typo

Co-authored-by: Yuhao Su <31772373+yuhao-su@users.noreply.github.com>

* feat(parser): Fix test

* feat(parser): Fix additional test

* feat(parser): Throw error when using order by for table functions

Co-authored-by: Yuhao Su <31772373+yuhao-su@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

frontend: support parsing agg order
4 participants