Fix SQL explain API rejecting ?format=json parameter#5607
Open
gingeekrishna wants to merge 1 commit into
Open
Conversation
isSupportedExplainFormat() only accepted "simple", "standard", "extended", and "cost" — excluding "json". Before OpenSearch 3.0, ?format=json was valid for the explain endpoint, so existing workflows that pass this parameter now receive: "Failed to create executor due to unknown response format: json" The explain endpoint already returns JSON unconditionally regardless of the format parameter, so accepting "json" is a pure backward- compatibility restoration with no behavioral change. Fixes opensearch-project#4373 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4373
Problem: Since OpenSearch 3.0, calling
POST /_plugins/_sql/_explain?format=jsonreturns:{ "error": { "reason": "Invalid SQL query", "details": "Failed to create executor due to unknown response format: json", "type": "IllegalArgumentException" }, "status": 400 }Root cause:
isSupportedExplainFormat()inSQLQueryRequest.javaonly accepted"simple","standard","extended", and"cost"—"json"was never in the list. The explain endpoint itself always returns JSON unconditionally (the format parameter has no effect on the response), so"json"was effectively accepted before this validation was tightened.Fix: Add
"json"toisSupportedExplainFormat(). The explain response path inSQLPlugin.javausesJsonResponseFormatter<ExplainResponse>regardless of the format parameter, so this is a pure backward-compatibility fix with no behavioral change.Changes
sql/src/main/java/.../SQLQueryRequest.java— add"json"toisSupportedExplainFormat()sql/src/test/java/.../SQLQueryRequestTest.java— regression test asserting?format=jsonis accepted on explain requestsTesting
29/29 tests pass in
SQLQueryRequestTest.