-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 filtered aggregation when it is mixed with regular aggregation #8172
Fix filtered aggregation when it is mixed with regular aggregation #8172
Conversation
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.
Thanks for the fix.
IMO, the fix is pretty contained and can be done in 50ish LOC. The majority of the changes in the PR are around whitespace and renaming, which are a separate discussion and should be done in a separate PR.
pinot-core/src/main/java/org/apache/pinot/core/query/reduce/PostAggregationHandler.java
Outdated
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java
Show resolved
Hide resolved
} else if (function.getType() == FunctionContext.Type.TRANSFORM | ||
&& function.getFunctionName().equalsIgnoreCase("filter")) { | ||
return new ColumnValueExtractor( | ||
_filteredAggregationsIndexMap.get(Pair.of(function, null)) + _numGroupByExpressions); |
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.
The main change here is that regular aggregations also refer to the filtered aggregation functions index map, instead of the standard index map. The remaining changes seem whitespace/naming changes?
pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java
Outdated
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java
Outdated
Show resolved
Hide resolved
pinot-core/src/test/java/org/apache/pinot/queries/FilteredAggregationsTest.java
Outdated
Show resolved
Hide resolved
Assert.assertEquals(firstSetRow[j], secondSetRow[j]); | ||
} | ||
private void testQuery(String filterQuery, String nonFilterQuery) { | ||
List<Object[]> filterQueryResults = getBrokerResponseForSqlQuery(filterQuery).getResultTable().getRows(); |
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.
I am not sure if this method has the same intent as the original method -- the original method had extra checks around row lengths and number of rows, and the result schemas. Can we please revert this? This anyways does not seem related to the problem the PR is solving.
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.
Added the data schema check in #8184
The rows check remains the same, where assertEquals(Object[] a, Object[] b)
will verify the array size and array content
pinot-core/src/test/java/org/apache/pinot/queries/FilteredAggregationsTest.java
Outdated
Show resolved
Hide resolved
pinot-core/src/test/java/org/apache/pinot/queries/FilteredAggregationsTest.java
Outdated
Show resolved
Hide resolved
pinot-core/src/test/java/org/apache/pinot/queries/FilteredAggregationsTest.java
Outdated
Show resolved
Hide resolved
@atris Most of the whitespace changes are actually done by the IDE auto-formatting. Let me separate them into a separate PR so that the change for the bug fix is more clear. The main fix is in 2 parts:
|
6244553
to
f7e5b0e
Compare
@atris Rebased the re-factor PR, and addressed the comments. Can you please take another look? |
Codecov Report
@@ Coverage Diff @@
## master #8172 +/- ##
=============================================
- Coverage 71.33% 27.60% -43.74%
=============================================
Files 1623 1612 -11
Lines 84314 83952 -362
Branches 12640 12600 -40
=============================================
- Hits 60146 23174 -36972
- Misses 20047 58620 +38573
+ Partials 4121 2158 -1963
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
LGTM. Please address the one comment remaining
} | ||
|
||
@Test | ||
public void testMixedAggregations() { |
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.
Lets rename this to testMixedAggregationsOfSameType, since other tests in this class contain tests with mixed aggregations, just of different types
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
f7e5b0e
to
abb28f1
Compare
…pache#8172) When a query has the same mixed regular aggregation and filtered aggregation, the index of the aggregation function is not maintained correctly. This PR contains the following changes: - Fix `QueryContext` to maintain the correct index - Fix `PostAggregationHandler` to always use the filtered aggregation index map - Add tests for `QueryContext` and queries
When a query has the same mixed regular aggregation and filtered aggregation, the index of the aggregation function is not maintained correctly.
This PR contains the following changes:
QueryContext
to maintain the correct indexPostAggregationHandler
to always use the filtered aggregation index mapQueryContext
and queries