kasakrisz commented on code in PR #6988:
URL: https://github.com/apache/hive/pull/6988#discussion_r4754113128
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateJoinTransposeRule.java:
##########
@@ -197,17 +201,41 @@ public void onMatch(RelOptRuleCall call) {
if (unique) {
++uniqueCount;
relBuilder.push(joinInput);
-
relBuilder.project(belowAggregateKey.asList().stream().map(relBuilder::field).collect(Collectors.toList()));
+ final List<RexNode> projects = new ArrayList<>();
+ for (Integer i : belowAggregateKey) {
+ projects.add(relBuilder.field(i));
+ }
+ for (Ord<AggregateCall> aggCall :
Ord.zip(aggregate.getAggCallList())) {
+ final SqlAggFunction aggregation = aggCall.e.getAggregation();
+ final SqlSplittableAggFunction splitter =
+ Preconditions.checkNotNull(
+ aggregation.unwrap(SqlSplittableAggFunction.class));
+ if (!aggCall.e.getArgList().isEmpty()
+ &&
fieldSet.contains(ImmutableBitSet.of(aggCall.e.getArgList()))) {
+ final RexNode singleton =
+ splitter.singleton(rexBuilder, joinInput.getRowType(),
+ aggCall.e.transform(mapping));
+
+ if (singleton instanceof RexInputRef) {
+ final int index = ((RexInputRef) singleton).getIndex();
+ if (!belowAggregateKey.get(index)) {
+ projects.add(singleton);
+ side.split.put(aggCall.i, projects.size() - 1);
+ } else {
+ side.split.put(aggCall.i, belowAggregateKey.indexOf(index));
+ }
+ } else {
+ projects.add(singleton);
Review Comment:
backported from Calcite
https://github.com/apache/calcite/blob/d6c81d757a8fcec3ea4ac4e0b51e437ee6ae1683/core/src/main/java/org/apache/calcite/rel/rules/AggregateJoinTransposeRule.java#L262-L273
--
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]