-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix Pinot aggregation pushdown for subqueries #12653
Conversation
Fixes #12655 |
if (aggregates.size() > 1) { | ||
return false; | ||
} | ||
AggregateFunction aggregate = getOnlyElement(aggregates); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can aggregates
be empty at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now aggregates would only contain 1 aggregate.
f12ceab
to
8fea740
Compare
Thanks for fixing this bug! |
8fea740
to
27b0bff
Compare
@elonazoulay when can this pull be merged? |
27b0bff
to
f79a4d9
Compare
Resolves #9134 |
f85aab4
to
cb49aa2
Compare
plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java
Outdated
Show resolved
Hide resolved
@@ -1864,6 +1864,52 @@ public void testAggregationPushdown() | |||
.isThrownBy(() -> query("SELECT bool_col, COUNT(long_col) FROM \"SELECT bool_col, long_col FROM " + ALL_TYPES_TABLE + " GROUP BY bool_col, long_col\"")) | |||
.withRootCauseInstanceOf(RuntimeException.class) | |||
.withMessage("Operation not supported for DISTINCT aggregation function"); | |||
|
|||
// Verify that count(<column name>) is pushed down only when it matches a COUNT(DISTINCT <column name>) query | |||
assertThat(query("SELECT COUNT(bool_col) FROM" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use """
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Noticed that using formatted(...)
disables the SQL formatting so the table names are hardcoded. Seems to be similar to other use cases, lmk if you prefer using formatted(tableName)
.
.../trino-pinot/src/test/java/io/trino/plugin/pinot/BasePinotIntegrationConnectorSmokeTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java
Outdated
Show resolved
Hide resolved
@@ -423,6 +424,44 @@ public static PinotColumnHandle toNonAggregateColumnHandle(PinotColumnHandle col | |||
return new PinotColumnHandle(columnHandle.getColumnName(), columnHandle.getDataType(), quoteIdentifier(columnHandle.getColumnName()), false, false, true, Optional.empty(), Optional.empty()); | |||
} | |||
|
|||
private boolean canPushDownAggregateIfGroupingColumnsPresent(ConnectorSession session, Optional<DynamicTable> dynamicTable, List<AggregateFunction> aggregates, Map<String, ColumnHandle> assignments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like this method does things that do not match what the name suggests (see pattern matching implementCountDistinct.getPattern().matches(
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmk if the new name is ok: isAggregationPushdownSupported
. Thanks for all the advice!
@elonazoulay @hashhar when can this pull be merged? |
cb49aa2
to
0317327
Compare
plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/PinotQueryRunner.java
Show resolved
Hide resolved
plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
% minor comments
plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java
Show resolved
Hide resolved
0317327
to
524d333
Compare
524d333
to
2defb1b
Compare
Thank you! |
Description
Related issues, pull requests, and links
Documentation
( ) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
( ) Release notes entries required with the following suggested text: