vineetgarg02 commented on a change in pull request #783: HIVE-22232
URL: https://github.com/apache/hive/pull/783#discussion_r328282487
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java
##########
@@ -160,17 +160,27 @@ private ASTNode convert() throws
CalciteSemanticException {
}
HiveAggregate hiveAgg = (HiveAggregate) groupBy;
- for (int pos : hiveAgg.getAggregateColumnsOrder()) {
- RexInputRef iRef = new RexInputRef(groupBy.getGroupSet().nth(pos),
-
groupBy.getCluster().getTypeFactory().createSqlType(SqlTypeName.ANY));
- b.add(iRef.accept(new RexVisitor(schema, false,
root.getCluster().getRexBuilder())));
- }
- for (int pos = 0; pos < groupBy.getGroupCount(); pos++) {
- if (!hiveAgg.getAggregateColumnsOrder().contains(pos)) {
+ if (hiveAgg.getAggregateColumnsOrder() != null) {
+ // Aggregation columns may have been sorted in specific order
+ for (int pos : hiveAgg.getAggregateColumnsOrder()) {
RexInputRef iRef = new RexInputRef(groupBy.getGroupSet().nth(pos),
groupBy.getCluster().getTypeFactory().createSqlType(SqlTypeName.ANY));
b.add(iRef.accept(new RexVisitor(schema, false,
root.getCluster().getRexBuilder())));
}
+ for (int pos = 0; pos < groupBy.getGroupCount(); pos++) {
+ if (!hiveAgg.getAggregateColumnsOrder().contains(pos)) {
Review comment:
Can we change this to `hiveAgg.getAggregateColumnsOrder == null ||
!hiveAgg.getAggregateColumnsOrder().contains(pos`) ?. Take this for loop off if
condition and get rid of the repetitive else block
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]