Skip to content

Commit ce2a02a

Browse files
committed
Emit APPROX_COUNT_DISTINCT as the distinct_count_approx runtime name
PPLBuiltinOperators.DISTINCT_COUNT_APPROX created its SqlAggFunction with the runtime-resolution name "DISTINCT_COUNT_APPROX". The analytics-engine (DataFusion) backend resolves aggregates by the Calcite/Substrait-standard name APPROX_COUNT_DISTINCT, so distinct_count_approx() failed to bind on the analytics route. Emit APPROX_COUNT_DISTINCT instead. The Java field name stays DISTINCT_COUNT_APPROX (the PPL function name); only the resolution string changes. The OpenSearch V3 path is unaffected — it overrides this operator via the external HyperLogLog registration in OpenSearchExecutionEngine (whose name is unchanged), so explain output and execution on that path are identical (verified). The analytics-route binding is completed by opensearch-project/OpenSearch#22013 (APPROX_COUNT_DISTINCT -> approx_distinct). Per Sandesh Kumar. Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent c8bc773 commit ce2a02a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

core/src/main/java/org/opensearch/sql/expression/function/PPLBuiltinOperators.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,11 @@ public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
521521
public static final SqlAggFunction DISTINCT_COUNT_APPROX =
522522
createUserDefinedAggFunction(
523523
DistinctCountApproxLogicalAggFunction.class,
524-
"DISTINCT_COUNT_APPROX",
524+
// Emit the Calcite/Substrait-standard name so the analytics-engine (DataFusion) backend
525+
// resolves it; the OpenSearch V3 path overrides this via the external HLL registration in
526+
// OpenSearchExecutionEngine. The Java field name stays DISTINCT_COUNT_APPROX (the PPL
527+
// function name); only this runtime-resolution string changes.
528+
"APPROX_COUNT_DISTINCT",
525529
ReturnTypes.BIGINT_FORCE_NULLABLE,
526530
null);
527531

0 commit comments

Comments
 (0)