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

Parse ARRAY_AGG for Bigquery and Snowflake #662

Merged
merged 1 commit into from Nov 11, 2022

Conversation

SuperBo
Copy link
Contributor

@SuperBo SuperBo commented Oct 8, 2022

@alamb
Copy link
Collaborator

alamb commented Oct 31, 2022

@AugustoFKL do you have time to review this PR?

@coveralls
Copy link

coveralls commented Oct 31, 2022

Pull Request Test Coverage Report for Build 3435201483

  • 58 of 69 (84.06%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 86.164%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dialect/mod.rs 1 2 50.0%
src/dialect/snowflake.rs 1 2 50.0%
src/ast/mod.rs 14 17 82.35%
src/parser.rs 28 34 82.35%
Totals Coverage Status
Change from base Build 3413823174: -0.01%
Covered Lines: 11627
Relevant Lines: 13494

💛 - Coveralls

@AugustoFKL
Copy link
Contributor

@SuperBo please fix the linter warnings

pub distinct: bool,
pub expr: Box<Expr>,
pub order_by: Option<Box<OrderByExpr>>,
pub limit: Option<Box<Expr>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

@SuperBo any reason why you did the implementation for all dialects the same time?

You didn't complete none, but added parts of different ones. Got me a little confused

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 changed this. You can review again

src/ast/mod.rs Outdated Show resolved Hide resolved
src/ast/mod.rs Outdated Show resolved Hide resolved
@@ -71,6 +71,10 @@ pub trait Dialect: Debug + Any {
fn supports_filter_during_aggregation(&self) -> bool {
false
}
/// Does the dialect supports ARRAY_AGG() [WITHIN GROUP (ORDER BY)] or ARRAY_AGG([ORDER BY])
fn supports_within_after_array_aggregation(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment is confusing.

The comment make it sounds like if any of both is valid, it will return true.

Could be something like

/// Returns true if the dialect supports ARRAY_AGG() [WITHIN GROUP (ORDER BY)] expressions.
///
/// Otherwise, the dialect should expect an `ORDER BY` without the `WITHIN GROUP` clause, e.g. `ANSI` [(1)].
/// [(1)]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#array-aggregate-function

Having the function here is not my usual approach, as it will require maintenance over other dialects individually, but I don't think it's wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, @SuperBo, one thing:

  • Generic dialect should be the most permissive one so, if you actually can have both structures in a query, generic dialect should allow both. But considering my previous comment, I'd allow the most common one, maybe?

@alamb what do you think? This is a divergence from dialects. I'd go for the one with more dialects, so the generic is as generic as possible.

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 you are right, the ANSI one should be default option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AugustoFKL, are we good to go with this or should we change to more generics behavior?

tests/sqlparser_snowflake.rs Outdated Show resolved Hide resolved
tests/sqlparser_common.rs Outdated Show resolved Hide resolved
src/parser.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@AugustoFKL AugustoFKL left a comment

Choose a reason for hiding this comment

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

LGTM, sorry the delay

@alamb ready for your eyes 👀

Copy link
Collaborator

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

Looks good to me -- thank you @SuperBo and @AugustoFKL

@alamb alamb merged commit 87b4a16 into sqlparser-rs:main Nov 11, 2022
MazterQyou pushed a commit to cube-js/sqlparser-rs that referenced this pull request May 19, 2023
MazterQyou pushed a commit to cube-js/sqlparser-rs that referenced this pull request May 19, 2023
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.

None yet

4 participants