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

[CALCITE-4491] Aggregations of nested window functions produce invalid SQL #2346

Closed
wants to merge 7 commits into from

Conversation

Dominick1993
Copy link

Dialects which do not support nested aggregations now also don't support
nested window functions.

The added test covers both cases:

  • a dialect which supports nested aggregations -> OracleSqlDialect
  • a dialect which does not support nested aggregations -> PostgreSqlDialect

@Dominick1993
Copy link
Author

Sorry, working on rebase on top of master now.

Dialects which do not support nested aggregations now also don't support
nested window functions.

The added test covers both cases:
- a dialect which supports nested aggregations -> OracleSqlDialect
- a dialect which does not support nested aggregations -> PostgreSqlDialect
@Dominick1993 Dominick1993 changed the title [CALCITE-4491] Fix aggregations of nested window functions [CALCITE-4491] Aggregations of nested window functions Feb 10, 2021
@@ -1803,9 +1805,14 @@ private boolean needNewSubQuery(

if (rel instanceof Aggregate) {
final Aggregate agg = (Aggregate) rel;
final boolean hasNestedAgg = hasNestedAggregations(agg);
final boolean hasNestedAgg = hasNested(agg, operand ->
operand instanceof SqlCall
Copy link
Author

Choose a reason for hiding this comment

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

@julianhyde I wasn't sure whether this check should be a part of hasNested method or a part of the predicate. I've chosen to go with the more generic predicate approach here, but please let me know your preference.

@Dominick1993 Dominick1993 changed the title [CALCITE-4491] Aggregations of nested window functions [CALCITE-4491] Aggregations of nested window functions produce invalid SQL Feb 10, 2021
julianhyde added a commit to julianhyde/calcite that referenced this pull request Feb 10, 2021
julianhyde pushed a commit to julianhyde/calcite that referenced this pull request Feb 10, 2021
…r PostgreSQL (Dominik Labuda)

Dialects that do not support nested aggregations now also don't support
nested window functions. (If there are dialects that support one but
not the other, we can revisit.)

The added test covers both cases:
- a dialect which supports nested aggregations -> OracleSqlDialect
- a dialect which does not support nested aggregations -> PostgreSqlDialect

Close apache#2346
MalteBellmann pushed a commit to caespes/calcite that referenced this pull request Feb 21, 2021
…r PostgreSQL (Dominik Labuda)

Dialects that do not support nested aggregations now also don't support
nested window functions. (If there are dialects that support one but
not the other, we can revisit.)

The added test covers both cases:
- a dialect which supports nested aggregations -> OracleSqlDialect
- a dialect which does not support nested aggregations -> PostgreSqlDialect

Close apache#2346
XuQianJin-Stars pushed a commit to XuQianJin-Stars/calcite that referenced this pull request Jul 14, 2021
…r PostgreSQL (Dominik Labuda)

Dialects that do not support nested aggregations now also don't support
nested window functions. (If there are dialects that support one but
not the other, we can revisit.)

The added test covers both cases:
- a dialect which supports nested aggregations -> OracleSqlDialect
- a dialect which does not support nested aggregations -> PostgreSqlDialect

Close apache#2346
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant