Skip to content

Commit ee5798d

Browse files
committed
Pass minimal {"properties":{}} mapping in testSearchCommandWithSpecialIndexName
`OpenSearchSchemaBuilder.buildSchema` skips any index whose mapping has no `properties` block — the analytics catalog then doesn't surface the index, and the PPL parser fails with `Table 'logs-2021.01.11' not found` before reaching the row type. Routing the special-index create through `TestUtils.createIndexByRestClient` with `null` mapping produces an empty `{}` body, so the index is created with no mapping at all and the catalog still skips it. Pass a minimal `{"mappings":{"properties":{}}}` body. OpenSearch strips the empty `properties` to `{}` server-side but the schema builder sees a non-null mapping and registers the (zero-column) table. The query then parses cleanly and the test's `verifyDataRows()` (no expected rows) succeeds against the empty index. Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent b283dcc commit ee5798d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/ppl/SearchCommandIT.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ public void testSearchCommandWithoutSearchKeyword() throws IOException {
5454

5555
@Test
5656
public void testSearchCommandWithSpecialIndexName() throws IOException {
57-
// Route through TestUtils so the analytics-engine parquet-indices toggle
58-
// (tests.analytics.parquet_indices=true) applies the composite/parquet
59-
// settings; without them the analytics-engine planner can't find a backend
60-
// for the scan and the query 500s.
61-
org.opensearch.sql.legacy.TestUtils.createIndexByRestClient(client(), "logs-2021.01.11", null);
57+
// A minimal `{"properties":{}}` mapping is required so the analytics-engine
58+
// catalog (OpenSearchSchemaBuilder.buildSchema) actually surfaces the index —
59+
// mapping-less indices are skipped and the parser then fails with
60+
// "Table 'logs-2021.01.11' not found". Routing through TestUtils also
61+
// honors the tests.analytics.parquet_indices toggle.
62+
String minimalMapping = "{\"mappings\":{\"properties\":{}}}";
63+
org.opensearch.sql.legacy.TestUtils.createIndexByRestClient(
64+
client(), "logs-2021.01.11", minimalMapping);
6265
verifyDataRows(executeQuery("search source=logs-2021.01.11"));
6366

6467
org.opensearch.sql.legacy.TestUtils.createIndexByRestClient(
65-
client(), "logs-7.10.0-2021.01.11", null);
68+
client(), "logs-7.10.0-2021.01.11", minimalMapping);
6669
verifyDataRows(executeQuery("search source=logs-7.10.0-2021.01.11"));
6770
}
6871

0 commit comments

Comments
 (0)