public static RelNode createSingleValueAggRel(
      RelOptCluster cluster,
      RelNode rel,
      RelFactories.AggregateFactory aggregateFactory) {
    // assert (rel.getRowType().getFieldCount() == 1);
    final int aggCallCnt = rel.getRowType().getFieldCount();
    final List<AggregateCall> aggCalls = new ArrayList<>();

    for (int i = 0; i < aggCallCnt; i++) {
      aggCalls.add(
          AggregateCall.create(
              SqlStdOperatorTable.SINGLE_VALUE, false, false,
              ImmutableList.of(i), -1, 0, rel, null, null));
    }

    return aggregateFactory.createAggregate(rel, Collections.emptyList(), ImmutableBitSet.of(), null, aggCalls);
  }
Creates a LogicalAggregate that removes all duplicates from the result of
an underlying relational expression.

@param rel underlying rel
@return rel implementing SingleValueAgg
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptUtil.java