Skip to content

Commit 74cdf9e

Browse files
authored
Fix CalcitePPLAggregationIT on the analytics-engine route (parquet testSimpleCount0 + APPROX_COUNT_DISTINCT name) (#5525)
* Use a parquet-backed index in CalcitePPLAggregationIT.testSimpleCount0 A bare auto-created index isn't composite/parquet-backed, so on the analytics-engine route it doesn't route to the analytics engine. Switch to TEST_INDEX_BANK (loaded via loadIndex, which injects parquet settings when the flag is set, 7 docs) so the test is meaningful on both routes. Diagnosis by Sandesh Kumar. Signed-off-by: Kai Huang <ahkcs@amazon.com> * Emit APPROX_COUNT_DISTINCT as the distinct_count_approx runtime name distinct_count_approx() failed to bind on the analytics-engine (DataFusion) route because the SqlAggFunction was named DISTINCT_COUNT_APPROX; the backend resolves aggregates by the Calcite/Substrait-standard name APPROX_COUNT_DISTINCT. The Java field name and PPL function name are unchanged. The OpenSearch V3 path is unaffected (it overrides this via the external HLL registration). Analytics-route binding is completed by opensearch-project/OpenSearch#22013. Per Sandesh Kumar. Signed-off-by: Kai Huang <ahkcs@amazon.com> --------- Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent 9a32644 commit 74cdf9e

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
521521
public static final SqlAggFunction DISTINCT_COUNT_APPROX =
522522
createUserDefinedAggFunction(
523523
DistinctCountApproxLogicalAggFunction.class,
524-
"DISTINCT_COUNT_APPROX",
524+
// Substrait-standard name the analytics-engine backend resolves by (V3 overrides it).
525+
"APPROX_COUNT_DISTINCT",
525526
ReturnTypes.BIGINT_FORCE_NULLABLE,
526527
null);
527528

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLAggregationIT.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.List;
2626
import org.json.JSONObject;
2727
import org.junit.jupiter.api.Test;
28-
import org.opensearch.client.Request;
2928
import org.opensearch.sql.common.utils.StringUtils;
3029
import org.opensearch.sql.exception.SemanticCheckException;
3130
import org.opensearch.sql.ppl.PPLIntegTestCase;
@@ -52,16 +51,11 @@ public void init() throws Exception {
5251

5352
@Test
5453
public void testSimpleCount0() throws IOException {
55-
Request request1 = new Request("PUT", "/test/_doc/1?refresh=true");
56-
request1.setJsonEntity("{\"name\": \"hello\", \"age\": 20}");
57-
client().performRequest(request1);
58-
Request request2 = new Request("PUT", "/test/_doc/2?refresh=true");
59-
request2.setJsonEntity("{\"name\": \"world\", \"age\": 30}");
60-
client().performRequest(request2);
61-
62-
JSONObject actual = executeQuery("source=test | stats count() as c");
54+
// A bare auto-created index isn't parquet-backed; use the parquet-aware bank index (7 docs).
55+
JSONObject actual =
56+
executeQuery(String.format("source=%s | stats count() as c", TEST_INDEX_BANK));
6357
verifySchema(actual, schema("c", "bigint"));
64-
verifyDataRows(actual, rows(2));
58+
verifyDataRows(actual, rows(7));
6559
}
6660

6761
@Test

0 commit comments

Comments
 (0)