Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public enum Key {
PPL_SYNTAX_LEGACY_PREFERRED("plugins.ppl.syntax.legacy.preferred"),
PPL_SUBSEARCH_MAXOUT("plugins.ppl.subsearch.maxout"),
PPL_JOIN_SUBSEARCH_MAXOUT("plugins.ppl.join.subsearch_maxout"),
PPL_REST_REDACTION_ENABLED("plugins.ppl.rest.redaction.enabled"),
PPL_REST_ALLOWED_ENDPOINTS("plugins.ppl.rest.allowed_endpoints"),

/** Enable Calcite as execution engine */
CALCITE_ENGINE_ENABLED("plugins.calcite.enabled"),
Expand Down

This file was deleted.

118 changes: 0 additions & 118 deletions core/src/main/java/org/opensearch/sql/utils/SystemIndexUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

package org.opensearch.sql.utils;

import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;
import java.util.Map;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.UtilityClass;
Expand Down Expand Up @@ -37,121 +34,6 @@ public static Boolean isSystemIndex(String indexName) {
return indexName.endsWith(SYS_TABLES_SUFFIX);
}

/**
* Reserved suffix marking a {@code rest} source table. Distinct from {@link #SYS_TABLES_SUFFIX}
* so {@link #isSystemIndex} and {@link #isRestSource} never overlap. The whole reserved name is a
* single Calcite identifier (REST + lowercase hex + this suffix), so it survives name resolution
* the same way the uppercase system-mapping names do.
*/
private static final String REST_SOURCE_SUFFIX = "__REST_SOURCE";

private static final String REST_SOURCE_PREFIX = "REST";

/** True if the resolved table name is a {@code rest} source token. */
public static boolean isRestSource(String indexName) {
return indexName.endsWith(REST_SOURCE_SUFFIX);
}

/**
* Encode a validated {@link RestSpec} into a single reserved table name. Mirrors {@link
* #mappingTable}: structured metadata travels inside a reserved name rather than a side channel.
* The endpoint/args have already been allow-list-validated before this is called.
*/
public static String restTable(RestSpec spec) {
StringBuilder sb = new StringBuilder();
sb.append("endpoint=").append(spec.getEndpoint());
if (spec.getCount() != null) {
sb.append('\n').append("count=").append(spec.getCount());
}
if (spec.getTimeout() != null) {
sb.append('\n').append("timeout=").append(spec.getTimeout());
}
if (spec.getArgs() != null) {
for (Map.Entry<String, String> e : spec.getArgs().entrySet()) {
sb.append('\n').append("arg.").append(e.getKey()).append('=').append(e.getValue());
}
}
return REST_SOURCE_PREFIX + toHex(sb.toString()) + REST_SOURCE_SUFFIX;
}

/** Decode a reserved {@code rest} table name back into its {@link RestSpec}. */
public static RestSpec decodeRestSpec(String indexName) {
// Validate the token shape before slicing it: callers gate on isRestSource today, but a
// public decoder must not assume its precondition, otherwise a malformed token would throw an
// opaque StringIndexOutOfBoundsException from substring rather than a clear input error.
if (!isRestSource(indexName)) {
throw new IllegalArgumentException("not a valid rest source token: " + indexName);
}
String body =
indexName.substring(
REST_SOURCE_PREFIX.length(), indexName.length() - REST_SOURCE_SUFFIX.length());
String decoded = fromHex(body);
String endpoint = null;
Integer count = null;
String timeout = null;
LinkedHashMap<String, String> args = new LinkedHashMap<>();
for (String line : decoded.split("\n")) {
if (line.isEmpty()) {
continue;
}
int eq = line.indexOf('=');
if (eq < 0) {
continue;
}
String k = line.substring(0, eq);
String v = line.substring(eq + 1);
if (k.equals("endpoint")) {
endpoint = v;
} else if (k.equals("count")) {
count = Integer.parseInt(v);
} else if (k.equals("timeout")) {
timeout = v;
} else if (k.startsWith("arg.")) {
args.put(k.substring("arg.".length()), v);
}
}
if (endpoint == null) {
throw new IllegalArgumentException("rest source token is missing the endpoint: " + indexName);
}
return new RestSpec(endpoint, args, count, timeout);
}

private static String toHex(String s) {
StringBuilder h = new StringBuilder();
for (byte b : s.getBytes(StandardCharsets.UTF_8)) {
h.append(Character.forDigit((b >> 4) & 0xF, 16)).append(Character.forDigit(b & 0xF, 16));
}
return h.toString();
}

private static String fromHex(String h) {
if (h.length() % 2 != 0) {
throw new IllegalArgumentException("not a valid rest source token: odd-length hex body");
}
byte[] bytes = new byte[h.length() / 2];
for (int i = 0; i < bytes.length; i++) {
bytes[i] =
(byte)
((Character.digit(h.charAt(2 * i), 16) << 4)
+ Character.digit(h.charAt(2 * i + 1), 16));
}
return new String(bytes, StandardCharsets.UTF_8);
}

/**
* The validated spec for a {@code rest} command: an allow-listed read-only endpoint plus optional
* count/timeout/query args. Lives in core so the parser (encode) and the storage engine (decode)
* share it without a cross-module dependency.
*/
@Getter
@RequiredArgsConstructor
public static class RestSpec {
private final String endpoint;
private final Map<String, String> args;
private final Integer count;
private final String timeout;
}

/**
* Compose system mapping table.
*
Expand Down
1 change: 0 additions & 1 deletion docs/category.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"user/ppl/cmd/rename.md",
"user/ppl/cmd/multisearch.md",
"user/ppl/cmd/replace.md",
"user/ppl/cmd/rest.md",
"user/ppl/cmd/rex.md",
"user/ppl/cmd/search.md",
"user/ppl/cmd/showdatasources.md",
Expand Down
94 changes: 0 additions & 94 deletions docs/user/ppl/cmd/rest.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/user/ppl/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ source=accounts
| [lookup command](cmd/lookup.md) | 3.0 | experimental (since 3.0) | Add or replace data from a lookup index. |
| [multisearch command](cmd/multisearch.md) | 3.4 | experimental (since 3.4) | Execute multiple search queries and combine their results. |
| [union command](cmd/union.md) | 3.7 | experimental (since 3.7) | Combine results from multiple datasets using UNION ALL semantics. |
| [rest command](cmd/rest.md) | 3.8 | experimental (since 3.8) | Read an allow-listed, read-only in-cluster management endpoint (cluster/cat/nodes) as rows. Calcite engine only. |
| [ml command](cmd/ml.md) | 2.5 | stable (since 2.5) | Apply machine learning algorithms to analyze data. |
| [kmeans command](cmd/kmeans.md) | 1.3 | stable (since 1.3) | Apply the kmeans algorithm on the search result returned by a PPL command. |
| [ad command](cmd/ad.md) | 1.3 | deprecated (since 2.5) | Apply Random Cut Forest algorithm on the search result returned by a PPL command. |
Expand Down
5 changes: 0 additions & 5 deletions doctest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ testClusters {
plugin(getJobSchedulerPlugin())
plugin ':opensearch-sql-plugin'
testDistribution = 'archive'
// The rest command is disabled by default (empty allow-list). Opt the doctest cluster into
// the registered endpoints so the rest.md examples run against an enabled command. A literal
// "*" cannot be used because a bare * is a YAML alias indicator in opensearch.yml.
setting 'plugins.ppl.rest.allowed_endpoints',
'/_cluster/health,/_cluster/state,/_cluster/settings,/_cat/indices,/_cat/nodes,/_cat/cluster_manager,/_cat/plugins,/_cat/shards,/_resolve/index'
}
}
tasks.register("runRestTestCluster", RunTask) {
Expand Down
10 changes: 0 additions & 10 deletions integ-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,6 @@ testClusters {
plugin(getGeoSpatialPlugin())
plugin ":opensearch-sql-plugin"
setting "plugins.query.datasources.encryption.masterkey", "1234567812345678"
// The rest command is disabled by default (empty allow-list). Opt this cluster into the
// registered endpoints so the rest integration tests exercise the enabled path. A literal
// "*" cannot be used because a bare * is a YAML alias indicator in opensearch.yml.
setting 'plugins.ppl.rest.allowed_endpoints',
'/_cluster/health,/_cluster/state,/_cluster/settings,/_cat/indices,/_cat/nodes,/_cat/cluster_manager,/_cat/plugins,/_cat/shards,/_resolve/index'
}
yamlRestTest {
testDistribution = 'archive'
Expand All @@ -410,9 +405,6 @@ testClusters {
testDistribution = 'archive'
plugin(getJobSchedulerPlugin())
plugin ":opensearch-sql-plugin"
// Opt into the rest endpoints (disabled by default) so RestCommandSecurityIT runs.
setting 'plugins.ppl.rest.allowed_endpoints',
'/_cluster/health,/_cluster/state,/_cluster/settings,/_cat/indices,/_cat/nodes,/_cat/cluster_manager,/_cat/plugins,/_cat/shards,/_resolve/index'
}
remoteIntegTestWithSecurity {
testDistribution = 'archive'
Expand All @@ -427,8 +419,6 @@ testClusters {
plugin(getArrowFlightRpcPlugin())
plugin(getAnalyticsEnginePlugin())
plugin ":opensearch-sql-plugin"
// Composite-default cluster: PPL queries route to the analytics engine unless excluded.
setting 'cluster.pluggable.dataformat', 'composite'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
CalciteObjectFieldOperateIT.class,
CalciteOperatorIT.class,
CalciteParseCommandIT.class,
CalcitePPLRestIT.class,
CalcitePPLAggregationIT.class,
CalcitePPLAppendcolIT.class,
CalcitePPLAppendCommandIT.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ public void init() throws Exception {
loadIndex(Index.GRAPH_EMPLOYEES);
}

// Only for Calcite: the rest row source explains as a CalciteScannableCatalogScan.
@Test
public void explainRestCommand() throws IOException {
String result = explainQueryToString("| rest '/_cluster/health' | fields status");
Assert.assertTrue(
"Expected a rest scan node in the explain output, got: " + result,
result.contains("CatalogScan"));
}

@Override
@Ignore("test only in v2")
public void testExplainModeUnsupportedInV2() throws IOException {}
Expand Down
Loading
Loading