You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "praveenc7 (via GitHub)" <gi...@apache.org> on 2024/09/15 05:19:10 UTC
[PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
praveenc7 opened a new pull request, #14001:
URL: https://github.com/apache/pinot/pull/14001
## Summary
For GroupBy queries, the default size of the GroupByResultHolder is set to 10K, which can lead to inefficient resource usage in cases where fewer group-by keys are expected, such as in queries with highly selective filters.
`select column1, sum(column2) from testTable where column1 in ("123") group by column1 limit 20000
`
## Description
This update dynamically adjusts the initial capacity of the GroupByResultHolder based on the filter predicates for such queries. By aligning the result holder size with the filter, we aim to optimize resource allocation and improve performance for filtered group-by queries.
## Testing
TODO: Functional tests
Performance evaluation is also required to assess the trade-offs of the introduced overhead vs. resource optimization.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] [WIP]Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "vvivekiyer (via GitHub)" <gi...@apache.org>.
vvivekiyer commented on code in PR #14001:
URL: https://github.com/apache/pinot/pull/14001#discussion_r1761509972
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -183,4 +194,26 @@ public GroupKeyGenerator getGroupKeyGenerator() {
public GroupByResultHolder[] getGroupByResultHolders() {
return _groupByResultHolders;
}
+
+ private Integer getGroupByResultHolderCapacityBasedOnFilterPredicate(QueryContext queryContext) {
+ if (queryContext.getFilter() == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ List<FilterContext> filterContexts = queryContext.getFilter().getChildren() != null
+ ? queryContext.getFilter().getChildren()
+ : List.of(queryContext.getFilter());
+
+ Map<ExpressionContext, InPredicate> predicateMap = filterContexts.stream()
+ .map(FilterContext::getPredicate)
+ .filter(predicate -> predicate.getType() == Predicate.Type.IN)
+ .collect(Collectors.toMap(Predicate::getLhs, predicate -> (InPredicate) predicate));
+
+ OptionalInt result = queryContext.getGroupByExpressions().stream()
Review Comment:
If there is a single groupBy expression with a filter on the groupBy, this is correct.
However, consider the case where there are 2 groupByExpressions but only a filter on 1 column. In this case this optimization will not work.
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -183,4 +194,26 @@ public GroupKeyGenerator getGroupKeyGenerator() {
public GroupByResultHolder[] getGroupByResultHolders() {
return _groupByResultHolders;
}
+
+ private Integer getGroupByResultHolderCapacityBasedOnFilterPredicate(QueryContext queryContext) {
+ if (queryContext.getFilter() == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ List<FilterContext> filterContexts = queryContext.getFilter().getChildren() != null
+ ? queryContext.getFilter().getChildren()
+ : List.of(queryContext.getFilter());
+
+ Map<ExpressionContext, InPredicate> predicateMap = filterContexts.stream()
+ .map(FilterContext::getPredicate)
+ .filter(predicate -> predicate.getType() == Predicate.Type.IN)
Review Comment:
We should also do this for EQ predicate?
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -183,4 +194,26 @@ public GroupKeyGenerator getGroupKeyGenerator() {
public GroupByResultHolder[] getGroupByResultHolders() {
return _groupByResultHolders;
}
+
+ private Integer getGroupByResultHolderCapacityBasedOnFilterPredicate(QueryContext queryContext) {
+ if (queryContext.getFilter() == null || queryContext.getGroupByExpressions() == null) {
Review Comment:
Unless there are groupByExpressions, we wouldn't come in to this class. It's better for this to be an assert if at all you want to ensure this case.
I think a better check here is to see if the groupByExpression contains only a single column (assuming that is the case you are optimizing)
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -110,7 +117,11 @@ public DefaultGroupByExecutor(QueryContext queryContext, AggregationFunction[] a
// Initialize result holders
int maxNumResults = _groupKeyGenerator.getGlobalGroupKeyUpperBound();
+ Integer optimalGroupByResultHolderCapacity = getGroupByResultHolderCapacityBasedOnFilterPredicate(queryContext);
Review Comment:
Can we wire the logic of determining the filter-based result holder limit into `maxInitialResultHolderCapacity()`?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "jasperjiaguo (via GitHub)" <gi...@apache.org>.
jasperjiaguo commented on code in PR #14001:
URL: https://github.com/apache/pinot/pull/14001#discussion_r1819454034
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -127,6 +139,48 @@ public DefaultGroupByExecutor(QueryContext queryContext, AggregationFunction[] a
}
}
+ private Map<ExpressionContext, Integer> getGroupByExpressionSizesFromPredicates(QueryContext queryContext) {
+ FilterContext filterContext = queryContext.getFilter();
+ if (filterContext == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ Set<Predicate> predicateColumns = new HashSet<>();
+ if (filterContext.getType() == FilterContext.Type.AND) {
+ for (FilterContext child : filterContext.getChildren()) {
+ FilterContext.Type type = child.getType();
+ if (type != FilterContext.Type.PREDICATE && type != FilterContext.Type.AND) {
+ return null;
+ } else if (child.getPredicate() != null) {
+ predicateColumns.add(child.getPredicate());
+ }
+ }
+ } else if (filterContext.getPredicate() != null) {
+ predicateColumns.add(filterContext.getPredicate());
+ } else {
+ return null;
+ }
+
+ // Collect IN and EQ predicates and store their sizes
+ Map<ExpressionContext, Integer> predicateSizeMap = predicateColumns.stream()
+ .filter(predicate -> predicate.getType() == Predicate.Type.IN || predicate.getType() == Predicate.Type.EQ)
+ .collect(Collectors.toMap(
+ Predicate::getLhs,
+ predicate -> (predicate.getType() == Predicate.Type.IN)
+ ? ((InPredicate) predicate).getValues().size()
+ : 1,
+ Integer::sum
Review Comment:
If we are only considering and-connected predicates here then I think Integer::min should probably be more accurate here? Although realistically `where A in (x,y,z) and A in (a,b) should be rare`
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -127,6 +139,48 @@ public DefaultGroupByExecutor(QueryContext queryContext, AggregationFunction[] a
}
}
+ private Map<ExpressionContext, Integer> getGroupByExpressionSizesFromPredicates(QueryContext queryContext) {
+ FilterContext filterContext = queryContext.getFilter();
+ if (filterContext == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ Set<Predicate> predicateColumns = new HashSet<>();
+ if (filterContext.getType() == FilterContext.Type.AND) {
Review Comment:
Can you add some comments to this part of the code to explain the logic to handle AND/PREDICATE/OR? Similarly those parts where cardinalities are processed?
##########
pinot-core/src/test/java/org/apache/pinot/core/query/aggregation/groupby/DictionaryBasedGroupKeyGeneratorTest.java:
##########
@@ -431,6 +430,51 @@ public void testMapDefaultValue() {
GroupKeyGenerator.INVALID_ID);
}
+ @Test(dataProvider = "groupByResultHolderCapacityDataProvider")
+ public void testGetGroupByResultHolderCapacity(String query, Integer expectedCapacity) {
+ query = query + "SET optimizeMaxInitialResultHolderCapacity=true";
+ QueryContext queryContext = QueryContextConverterUtils.getQueryContext(query);
+ List<ExpressionContext> expressionContextList = queryContext.getGroupByExpressions();
+ ExpressionContext[] expressions =
+ expressionContextList.toArray(new ExpressionContext[expressionContextList.size()]);
+ DefaultGroupByExecutor defaultGroupByExecutor =
+ new DefaultGroupByExecutor(queryContext, expressions, _projectOperator);
+ assertEquals(defaultGroupByExecutor.getGroupKeyGenerator().getGlobalGroupKeyUpperBound(), expectedCapacity,
+ _errorMessage);
+ }
+
+ @DataProvider(name = "groupByResultHolderCapacityDataProvider")
+ public Object[][] groupByResultHolderCapacityDataProvider() {
+ return new Object[][]{
+ // Single IN predicate
+ {"SELECT COUNT(s9), s1 FROM testTable WHERE s1 IN (1, 2, 3, 4, 5) GROUP BY s1 LIMIT 10;", 5},
+ // Multiple IN predicates but only one used in group-by
+ {"SELECT COUNT(s9), s1 FROM testTable WHERE s1 IN (1, 2, 3) AND s2 IN (4, 5) GROUP BY s1 LIMIT 10;", 3},
+ // Multiple IN predicates used in group-by
+ {"SELECT COUNT(s9), s1, s3 FROM testTable WHERE s1 IN (1, 2, 3) AND s3 IN (4, 5) GROUP BY s1, s3 LIMIT 10;", 6},
+ // Single EQ predicate
+ {"SELECT COUNT(s9), s1 FROM testTable WHERE s1 = 1 GROUP BY s1 LIMIT 10;", 1},
+ // Multiple EQ predicates but only one used in group-by
+ {"SELECT COUNT(s9), s1 FROM testTable WHERE s1 = 1 AND s2 = 4 GROUP BY s1 LIMIT 10;", 1},
+ // Mixed predicates
+ {"SELECT COUNT(s9), s1, s3 FROM testTable WHERE s1 IN (1, 2, 3) AND s3 = 4 GROUP BY s1, s3 LIMIT 10;", 3},
+ {"SELECT COUNT(*), s1, s3 FROM testTable WHERE s1 = 1 AND s3 IN (4, 5) GROUP BY s1, s3 LIMIT 10;", 2},
+ // Multiple IN Predicate columns with same column name and different values
+ {"SELECT COUNT(s9), s1, s2 FROM testTable WHERE s1 IN (1, 2, 3) AND s1 IN (4, 5) AND s2 IN (6, 7)"
Review Comment:
in reality this will result in 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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "praveenc7 (via GitHub)" <gi...@apache.org>.
praveenc7 commented on PR #14001:
URL: https://github.com/apache/pinot/pull/14001#issuecomment-2401310382
> @praveenc7 I see, thanks for checking! I think the only (small) gap here is that when we have
>
> ```
> select ... where A in (a1, a2, a3) group by A,B
> ```
>
> Do we currently handle this mixture of bounded + unbounded? ideally the effective card estimation could be calculated with cardinality_product/card(A) * filterlen(A)
@jasperjiaguo Agree this might create a more tighter bound, currently the cardinality is available for [DictionaryBasedGroupKey](https://github.com/apache/pinot/blob/8334add327fc497689d0cc2c9d4371ecef4c17e5/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DictionaryBasedGroupKeyGenerator.java#L161) so the unbounded case would be mostly applicable to this, might need some more change to support this. Was thinking of doing in a follow up PR
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "jasperjiaguo (via GitHub)" <gi...@apache.org>.
jasperjiaguo merged PR #14001:
URL: https://github.com/apache/pinot/pull/14001
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "praveenc7 (via GitHub)" <gi...@apache.org>.
praveenc7 commented on code in PR #14001:
URL: https://github.com/apache/pinot/pull/14001#discussion_r1819929596
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -127,6 +139,48 @@ public DefaultGroupByExecutor(QueryContext queryContext, AggregationFunction[] a
}
}
+ private Map<ExpressionContext, Integer> getGroupByExpressionSizesFromPredicates(QueryContext queryContext) {
+ FilterContext filterContext = queryContext.getFilter();
+ if (filterContext == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ Set<Predicate> predicateColumns = new HashSet<>();
+ if (filterContext.getType() == FilterContext.Type.AND) {
Review Comment:
Added comment
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -127,6 +139,48 @@ public DefaultGroupByExecutor(QueryContext queryContext, AggregationFunction[] a
}
}
+ private Map<ExpressionContext, Integer> getGroupByExpressionSizesFromPredicates(QueryContext queryContext) {
+ FilterContext filterContext = queryContext.getFilter();
+ if (filterContext == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ Set<Predicate> predicateColumns = new HashSet<>();
+ if (filterContext.getType() == FilterContext.Type.AND) {
+ for (FilterContext child : filterContext.getChildren()) {
+ FilterContext.Type type = child.getType();
+ if (type != FilterContext.Type.PREDICATE && type != FilterContext.Type.AND) {
+ return null;
+ } else if (child.getPredicate() != null) {
+ predicateColumns.add(child.getPredicate());
+ }
+ }
+ } else if (filterContext.getPredicate() != null) {
+ predicateColumns.add(filterContext.getPredicate());
+ } else {
+ return null;
+ }
+
+ // Collect IN and EQ predicates and store their sizes
+ Map<ExpressionContext, Integer> predicateSizeMap = predicateColumns.stream()
+ .filter(predicate -> predicate.getType() == Predicate.Type.IN || predicate.getType() == Predicate.Type.EQ)
+ .collect(Collectors.toMap(
+ Predicate::getLhs,
+ predicate -> (predicate.getType() == Predicate.Type.IN)
+ ? ((InPredicate) predicate).getValues().size()
+ : 1,
+ Integer::sum
Review Comment:
We are right, let me fix this
##########
pinot-core/src/test/java/org/apache/pinot/core/query/aggregation/groupby/DictionaryBasedGroupKeyGeneratorTest.java:
##########
@@ -431,6 +430,51 @@ public void testMapDefaultValue() {
GroupKeyGenerator.INVALID_ID);
}
+ @Test(dataProvider = "groupByResultHolderCapacityDataProvider")
+ public void testGetGroupByResultHolderCapacity(String query, Integer expectedCapacity) {
+ query = query + "SET optimizeMaxInitialResultHolderCapacity=true";
+ QueryContext queryContext = QueryContextConverterUtils.getQueryContext(query);
+ List<ExpressionContext> expressionContextList = queryContext.getGroupByExpressions();
+ ExpressionContext[] expressions =
+ expressionContextList.toArray(new ExpressionContext[expressionContextList.size()]);
+ DefaultGroupByExecutor defaultGroupByExecutor =
+ new DefaultGroupByExecutor(queryContext, expressions, _projectOperator);
+ assertEquals(defaultGroupByExecutor.getGroupKeyGenerator().getGlobalGroupKeyUpperBound(), expectedCapacity,
+ _errorMessage);
+ }
+
+ @DataProvider(name = "groupByResultHolderCapacityDataProvider")
+ public Object[][] groupByResultHolderCapacityDataProvider() {
+ return new Object[][]{
+ // Single IN predicate
+ {"SELECT COUNT(s9), s1 FROM testTable WHERE s1 IN (1, 2, 3, 4, 5) GROUP BY s1 LIMIT 10;", 5},
+ // Multiple IN predicates but only one used in group-by
+ {"SELECT COUNT(s9), s1 FROM testTable WHERE s1 IN (1, 2, 3) AND s2 IN (4, 5) GROUP BY s1 LIMIT 10;", 3},
+ // Multiple IN predicates used in group-by
+ {"SELECT COUNT(s9), s1, s3 FROM testTable WHERE s1 IN (1, 2, 3) AND s3 IN (4, 5) GROUP BY s1, s3 LIMIT 10;", 6},
+ // Single EQ predicate
+ {"SELECT COUNT(s9), s1 FROM testTable WHERE s1 = 1 GROUP BY s1 LIMIT 10;", 1},
+ // Multiple EQ predicates but only one used in group-by
+ {"SELECT COUNT(s9), s1 FROM testTable WHERE s1 = 1 AND s2 = 4 GROUP BY s1 LIMIT 10;", 1},
+ // Mixed predicates
+ {"SELECT COUNT(s9), s1, s3 FROM testTable WHERE s1 IN (1, 2, 3) AND s3 = 4 GROUP BY s1, s3 LIMIT 10;", 3},
+ {"SELECT COUNT(*), s1, s3 FROM testTable WHERE s1 = 1 AND s3 IN (4, 5) GROUP BY s1, s3 LIMIT 10;", 2},
+ // Multiple IN Predicate columns with same column name and different values
+ {"SELECT COUNT(s9), s1, s2 FROM testTable WHERE s1 IN (1, 2, 3) AND s1 IN (4, 5) AND s2 IN (6, 7)"
Review Comment:
Let me remove this
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "praveenc7 (via GitHub)" <gi...@apache.org>.
praveenc7 commented on code in PR #14001:
URL: https://github.com/apache/pinot/pull/14001#discussion_r1772579144
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -183,4 +194,26 @@ public GroupKeyGenerator getGroupKeyGenerator() {
public GroupByResultHolder[] getGroupByResultHolders() {
return _groupByResultHolders;
}
+
+ private Integer getGroupByResultHolderCapacityBasedOnFilterPredicate(QueryContext queryContext) {
+ if (queryContext.getFilter() == null || queryContext.getGroupByExpressions() == null) {
Review Comment:
Refactor the logic to handle both single and multi groupby
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -183,4 +194,26 @@ public GroupKeyGenerator getGroupKeyGenerator() {
public GroupByResultHolder[] getGroupByResultHolders() {
return _groupByResultHolders;
}
+
+ private Integer getGroupByResultHolderCapacityBasedOnFilterPredicate(QueryContext queryContext) {
+ if (queryContext.getFilter() == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ List<FilterContext> filterContexts = queryContext.getFilter().getChildren() != null
+ ? queryContext.getFilter().getChildren()
+ : List.of(queryContext.getFilter());
+
+ Map<ExpressionContext, InPredicate> predicateMap = filterContexts.stream()
+ .map(FilterContext::getPredicate)
+ .filter(predicate -> predicate.getType() == Predicate.Type.IN)
Review Comment:
Added it
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "praveenc7 (via GitHub)" <gi...@apache.org>.
praveenc7 commented on PR #14001:
URL: https://github.com/apache/pinot/pull/14001#issuecomment-2409137708
> Let's think about the edge case of
>
> ```
> select ... where (A in (a1, a2, a3) or C > c) group by A
> ```
@jasperjiaguo Added condition that checks for top-level AND and also added mixed support for both bounded & unbounded
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #14001:
URL: https://github.com/apache/pinot/pull/14001#issuecomment-2351397230
## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/14001?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `0%` with `18 lines` in your changes missing coverage. Please review.
> Project coverage is 27.93%. Comparing base [(`59551e4`)](https://app.codecov.io/gh/apache/pinot/commit/59551e45224f1535c4863fd577622b37366ccc97?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`d6e0cae`)](https://app.codecov.io/gh/apache/pinot/commit/d6e0cae2665853d9e7c3bb4ea96c3fd42b562306?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 1036 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/14001?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...ry/aggregation/groupby/DefaultGroupByExecutor.java](https://app.codecov.io/gh/apache/pinot/pull/14001?src=pr&el=tree&filepath=pinot-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fcore%2Fquery%2Faggregation%2Fgroupby%2FDefaultGroupByExecutor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9ncm91cGJ5L0RlZmF1bHRHcm91cEJ5RXhlY3V0b3IuamF2YQ==) | 0.00% | [18 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/14001?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (59551e4) and HEAD (d6e0cae). Click for more details.
>
> <details><summary>HEAD has 53 uploads less than BASE</summary>
>
>| Flag | BASE (59551e4) | HEAD (d6e0cae) |
>|------|------|------|
>|integration|7|0|
>|integration2|3|0|
>|temurin|12|1|
>|java-21|7|1|
>|skip-bytebuffers-true|3|1|
>|skip-bytebuffers-false|7|0|
>|unittests|5|1|
>|unittests1|2|0|
>|java-11|5|0|
>|unittests2|3|1|
>|integration1|2|0|
>|custom-integration1|2|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #14001 +/- ##
=============================================
- Coverage 61.75% 27.93% -33.82%
- Complexity 207 213 +6
=============================================
Files 2436 2613 +177
Lines 133233 143286 +10053
Branches 20636 21998 +1362
=============================================
- Hits 82274 40026 -42248
- Misses 44911 100179 +55268
+ Partials 6048 3081 -2967
```
| [Flag](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration1](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration2](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-11](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-21](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `27.93% <0.00%> (-33.70%)` | :arrow_down: |
| [skip-bytebuffers-false](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [skip-bytebuffers-true](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `27.93% <0.00%> (+0.20%)` | :arrow_up: |
| [temurin](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `27.93% <0.00%> (-33.82%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `27.93% <0.00%> (-33.82%)` | :arrow_down: |
| [unittests1](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unittests2](https://app.codecov.io/gh/apache/pinot/pull/14001/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `27.93% <0.00%> (+0.20%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/14001?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on PR #14001:
URL: https://github.com/apache/pinot/pull/14001#issuecomment-2378040079
These queries are very uncommon, and I don't know if it is worth taking the overhead for all group-by queries. Alternatively, we might just add a query option to override the initial capacity if desired
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "praveenc7 (via GitHub)" <gi...@apache.org>.
praveenc7 commented on code in PR #14001:
URL: https://github.com/apache/pinot/pull/14001#discussion_r1819929776
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -127,6 +139,48 @@ public DefaultGroupByExecutor(QueryContext queryContext, AggregationFunction[] a
}
}
+ private Map<ExpressionContext, Integer> getGroupByExpressionSizesFromPredicates(QueryContext queryContext) {
+ FilterContext filterContext = queryContext.getFilter();
+ if (filterContext == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ Set<Predicate> predicateColumns = new HashSet<>();
+ if (filterContext.getType() == FilterContext.Type.AND) {
+ for (FilterContext child : filterContext.getChildren()) {
+ FilterContext.Type type = child.getType();
+ if (type != FilterContext.Type.PREDICATE && type != FilterContext.Type.AND) {
+ return null;
+ } else if (child.getPredicate() != null) {
+ predicateColumns.add(child.getPredicate());
+ }
+ }
+ } else if (filterContext.getPredicate() != null) {
+ predicateColumns.add(filterContext.getPredicate());
+ } else {
+ return null;
+ }
+
+ // Collect IN and EQ predicates and store their sizes
+ Map<ExpressionContext, Integer> predicateSizeMap = predicateColumns.stream()
+ .filter(predicate -> predicate.getType() == Predicate.Type.IN || predicate.getType() == Predicate.Type.EQ)
+ .collect(Collectors.toMap(
+ Predicate::getLhs,
+ predicate -> (predicate.getType() == Predicate.Type.IN)
+ ? ((InPredicate) predicate).getValues().size()
+ : 1,
+ Integer::sum
Review Comment:
right, let me fix this
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "jasperjiaguo (via GitHub)" <gi...@apache.org>.
jasperjiaguo commented on PR #14001:
URL: https://github.com/apache/pinot/pull/14001#issuecomment-2403465785
Let's think about the edge case of
```
select ... where (A in (a1, a2, a3) or C > c) group by A
```
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "praveenc7 (via GitHub)" <gi...@apache.org>.
praveenc7 commented on code in PR #14001:
URL: https://github.com/apache/pinot/pull/14001#discussion_r1772579379
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -183,4 +194,26 @@ public GroupKeyGenerator getGroupKeyGenerator() {
public GroupByResultHolder[] getGroupByResultHolders() {
return _groupByResultHolders;
}
+
+ private Integer getGroupByResultHolderCapacityBasedOnFilterPredicate(QueryContext queryContext) {
+ if (queryContext.getFilter() == null || queryContext.getGroupByExpressions() == null) {
+ return null;
+ }
+
+ List<FilterContext> filterContexts = queryContext.getFilter().getChildren() != null
+ ? queryContext.getFilter().getChildren()
+ : List.of(queryContext.getFilter());
+
+ Map<ExpressionContext, InPredicate> predicateMap = filterContexts.stream()
+ .map(FilterContext::getPredicate)
+ .filter(predicate -> predicate.getType() == Predicate.Type.IN)
+ .collect(Collectors.toMap(Predicate::getLhs, predicate -> (InPredicate) predicate));
+
+ OptionalInt result = queryContext.getGroupByExpressions().stream()
Review Comment:
handled this case
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Dynamic evaluation of GroupBy Initial Capacity [pinot]
Posted by "praveenc7 (via GitHub)" <gi...@apache.org>.
praveenc7 commented on code in PR #14001:
URL: https://github.com/apache/pinot/pull/14001#discussion_r1772578809
##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/groupby/DefaultGroupByExecutor.java:
##########
@@ -110,7 +117,11 @@ public DefaultGroupByExecutor(QueryContext queryContext, AggregationFunction[] a
// Initialize result holders
int maxNumResults = _groupKeyGenerator.getGlobalGroupKeyUpperBound();
+ Integer optimalGroupByResultHolderCapacity = getGroupByResultHolderCapacityBasedOnFilterPredicate(queryContext);
Review Comment:
Done
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org