Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sql-cli]wrap error response into exception #309

Merged
Merged
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
15 changes: 11 additions & 4 deletions sql-cli/src/opensearch_sql_cli/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from cli_helpers.tabular_output import TabularOutputFormatter
from cli_helpers.tabular_output.preprocessors import format_numbers
from opensearchpy.exceptions import OpenSearchException

click.disable_unicode_literals_warning = True

Expand Down Expand Up @@ -55,10 +56,16 @@ def format_output(self, data):
formatter = TabularOutputFormatter(format_name=self.table_format)

# parse response data
datarows = data["datarows"]
schema = data["schema"]
total_hits = data["total"]
cur_size = data["size"]
try:
datarows = data["datarows"]
schema = data["schema"]
total_hits = data["total"]
cur_size = data["size"]
except KeyError:
# tmp fix: in case some errors in query engine returns 200 in http response, leading to a parsing error
# TODO: remove this after #311 in sql repo is fixed
raise OpenSearchException(data)

# unused data for now,
fields = []
types = []
Expand Down