3333import org .opensearch .sql .ast .expression .WindowBound ;
3434import org .opensearch .sql .ast .expression .WindowFrame ;
3535import org .opensearch .sql .calcite .CalcitePlanContext ;
36+ import org .opensearch .sql .calcite .udf .udaf .DistinctCountApproxAggFunction ;
3637import org .opensearch .sql .calcite .udf .udaf .PercentileApproxFunction ;
3738import org .opensearch .sql .calcite .udf .udaf .TakeAggFunction ;
3839import org .opensearch .sql .expression .function .BuiltinFunctionName ;
@@ -218,6 +219,8 @@ static RelBuilder.AggCall makeAggCall(
218219 case AVG :
219220 return context .relBuilder .avg (distinct , null , field );
220221 case COUNT :
222+ // return context.relBuilder.aggregateCall(SqlStdOperatorTable.APPROX_COUNT_DISTINCT,
223+ // field);
221224 return context .relBuilder .count (
222225 distinct , null , field == null ? ImmutableList .of () : ImmutableList .of (field ));
223226 case SUM :
@@ -238,6 +241,14 @@ static RelBuilder.AggCall makeAggCall(
238241 // case PERCENTILE_APPROX:
239242 // return
240243 // context.relBuilder.aggregateCall(SqlStdOperatorTable.PERCENTILE_CONT, field);
244+ case DISTINCT_COUNT_APPROX :
245+ return TransferUserDefinedAggFunction (
246+ DistinctCountApproxAggFunction .class ,
247+ "APPROX_DISTINCT_COUNT" ,
248+ ReturnTypes .BIGINT_FORCE_NULLABLE ,
249+ List .of (field ),
250+ argList ,
251+ context .relBuilder );
241252 case TAKE :
242253 return TransferUserDefinedAggFunction (
243254 TakeAggFunction .class ,
0 commit comments