songwdfu commented on code in PR #16308:
URL: https://github.com/apache/pinot/pull/16308#discussion_r2275212415
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/query/FilteredGroupByOperator.java:
##########
@@ -187,28 +187,48 @@ protected GroupByResultsBlock getNextBlock() {
// - There are more groups than the trim size
// TODO: Currently the groups are not trimmed if there is no ordering
specified. Consider ordering on group-by
// columns if no ordering is specified.
+ // TODO: extract common logic with GroupByOperator
int trimSize = _queryContext.getEffectiveSegmentGroupTrimSize();
- if (trimSize > 0) {
- if (groupKeyGenerator.getNumKeys() > trimSize) {
- TableResizer tableResizer = new TableResizer(_dataSchema,
_queryContext);
- Collection<IntermediateRecord> intermediateRecords =
- tableResizer.trimInSegmentResults(groupKeyGenerator,
groupByResultHolders, trimSize);
- // Release the resources used by the group key generator
- groupKeyGenerator.close();
+ boolean unsafeTrim = _queryContext.isUnsafeTrim();
-
ServerMetrics.get().addMeteredGlobalValue(ServerMeter.AGGREGATE_TIMES_GROUPS_TRIMMED,
1);
- boolean unsafeTrim = _queryContext.isUnsafeTrim(); // set trim flag
only if it's not safe
- GroupByResultsBlock resultsBlock = new
GroupByResultsBlock(_dataSchema, intermediateRecords, _queryContext);
- resultsBlock.setGroupsTrimmed(unsafeTrim);
- resultsBlock.setNumGroupsLimitReached(numGroupsLimitReached);
-
resultsBlock.setNumGroupsWarningLimitReached(numGroupsWarningLimitReached);
- return resultsBlock;
- }
+ if (trimSize == 0) {
Review Comment:
Confirmed this is reacheable for queries like this
```SELECT COUNT(*) from baseballStats GROUP BY AtBatting ORDER BY AtBatting
LIMIT 0```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]