Skip to content

Commit

Permalink
distinct agg
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinyhZou committed Oct 8, 2024
1 parent 5e9b050 commit 349a25c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ case class CHHashAggregateExecTransformer(
CHExpressions.createAggregateFunction(args, aggregateFunc),
childrenNodeList,
modeToKeyWord(aggExpr.mode),
ConverterUtils.getTypeNode(aggregateFunc.dataType, aggregateFunc.nullable)
ConverterUtils.getTypeNode(aggregateFunc.dataType, aggregateFunc.nullable),
aggExpr.isDistinct
)
aggregateFunctionList.add(aggFunctionNode)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ public class AggregateFunctionNode implements Serializable {
private final List<ExpressionNode> expressionNodes = new ArrayList<>();
private final String phase;
private final TypeNode outputTypeNode;
private final boolean isDistinct;

AggregateFunctionNode(
Long functionId,
List<ExpressionNode> expressionNodes,
String phase,
TypeNode outputTypeNode) {
TypeNode outputTypeNode,
boolean isDistinct) {
this.functionId = functionId;
this.expressionNodes.addAll(expressionNodes);
this.phase = phase;
this.outputTypeNode = outputTypeNode;
this.isDistinct = isDistinct;
}

public AggregateFunction toProtobuf() {
Expand All @@ -53,9 +56,11 @@ public AggregateFunction toProtobuf() {
switch (phase) {
case "PARTIAL":
aggBuilder.setPhase(AggregationPhase.AGGREGATION_PHASE_INITIAL_TO_INTERMEDIATE);
aggBuilder.setIsDistinct(isDistinct);
break;
case "PARTIAL_MERGE":
aggBuilder.setPhase(AggregationPhase.AGGREGATION_PHASE_INTERMEDIATE_TO_INTERMEDIATE);
aggBuilder.setIsDistinct(isDistinct);
break;
case "COMPLETE":
aggBuilder.setPhase(AggregationPhase.AGGREGATION_PHASE_INITIAL_TO_RESULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,10 @@ public static AggregateFunctionNode makeAggregateFunction(
Long functionId,
List<ExpressionNode> expressionNodes,
String phase,
TypeNode outputTypeNode) {
return new AggregateFunctionNode(functionId, expressionNodes, phase, outputTypeNode);
TypeNode outputTypeNode,
boolean isDistinct) {
return new AggregateFunctionNode(
functionId, expressionNodes, phase, outputTypeNode, isDistinct);
}

public static CastNode makeCast(
Expand Down

0 comments on commit 349a25c

Please sign in to comment.