Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fetch error message in root cause for new default formatter #1001

Merged

Conversation

dai-chen
Copy link
Member

@dai-chen dai-chen commented Jan 22, 2021

Issue #, if available: #1002

Description of changes: Reuse existing ErrorMessage and ErrorMessageFactory to extract root cause info from Elasticsearch search. After changed, the error response is exactly same as that of old engine and PPL.

Testing: UT and manual verification as below

Without the fix:

PUT _settings
{
  "index.max_result_window": 100
}

POST _opendistro/_sql/
{
  "query": """
    SELECT * FROM accounts
  """
}
{
  "error": {
    "type": "SearchPhaseExecutionException",
    "reason": "all shards failed",
    "details": "all shards failed"
  },
  "status": 400
}

After the fix:

{
  "error": {
    "type": "SearchPhaseExecutionException",
    "reason": "Error occurred in Elasticsearch engine: all shards failed",
    "details": "Shard[0]: java.lang.IllegalArgumentException: Result window is too large, from + size must be less than or equal to: [100] but was [200]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting.\n\nFor more details, please send request for Json format to see the raw response from elasticsearch engine."
  },
  "status": 400
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dai-chen dai-chen added bug Something isn't working SQL labels Jan 22, 2021
@dai-chen dai-chen self-assigned this Jan 22, 2021
@codecov
Copy link

codecov bot commented Jan 22, 2021

Codecov Report

Merging #1001 (d8c3deb) into develop (c5ea315) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop    #1001   +/-   ##
==========================================
  Coverage      99.87%   99.87%           
  Complexity      2406     2406           
==========================================
  Files            234      234           
  Lines           5524     5526    +2     
  Branches         357      357           
==========================================
+ Hits            5517     5519    +2     
  Misses             5        5           
  Partials           2        2           
Impacted Files Coverage Δ Complexity Δ
...sticsearch/response/error/ErrorMessageFactory.java 100.00% <ø> (ø) 5.00 <0.00> (ø)
...sql/elasticsearch/response/error/ErrorMessage.java 100.00% <100.00%> (ø) 9.00 <1.00> (ø)
...rotocol/response/format/JdbcResponseFormatter.java 100.00% <100.00%> (ø) 11.00 <1.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5ea315...d8c3deb. Read the comment docs.

@dai-chen dai-chen marked this pull request as ready for review January 22, 2021 19:07
Copy link
Contributor

@penghuo penghuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dai-chen dai-chen merged commit 1101df0 into opendistro-for-elasticsearch:develop Jan 26, 2021
@dai-chen dai-chen deleted the sql-error-message branch January 26, 2021 17:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working SQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants