Skip to content
Open
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 @@ -159,7 +159,11 @@ private boolean isSupportedFormat() {
}

private boolean isSupportedExplainFormat() {
return Stream.of("simple", "standard", "extended", "cost").anyMatch(format::equalsIgnoreCase);
// "json" is accepted for backward compatibility: the explain endpoint always returns JSON
// regardless of this parameter, so treating it as valid avoids the 400 regression
// introduced in OpenSearch 3.0. See https://github.com/opensearch-project/sql/issues/4373
return Stream.of("simple", "standard", "extended", "cost", "json")
.anyMatch(format::equalsIgnoreCase);
}

private String getFormat(Map<String, String> params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ public void should_support_explain_format() {
() -> assertTrue(explainRequest.isSupported()));
}

@Test
public void should_support_explain_with_json_format() {
// Regression test for https://github.com/opensearch-project/sql/issues/4373.
// ?format=json was accepted before OpenSearch 3.0 and should continue to be valid.
// The explain endpoint always returns JSON regardless of this parameter.
SQLQueryRequest explainRequest =
SQLQueryRequestBuilder.request("SELECT 1")
.path("_plugins/_sql/_explain")
.params(Map.of("format", "json"))
.build();

assertAll(
() -> assertTrue(explainRequest.isExplainRequest()),
() -> assertTrue(explainRequest.isSupported()));
}

@Test
public void should_not_support_explain_with_unsupported_explain_format() {
SQLQueryRequest explainRequest =
Expand Down
Loading