[hive] Avoid error on empty EXPLAIN call
@@ -562,19 +562,24 @@ class HS2Api(Api):
response = self._get_current_statement(notebook, snippet)
session = self._get_session(notebook, snippet['type'])
- query = self._prepare_hql_query(snippet, response.pop('statement'), session)
+ statement = response.pop('statement')
+ explanation = ''
+
+ query = self._prepare_hql_query(snippet, statement, session)
+ if statement:
try:
db.use(query.database)
- explanation = db.explain(query)
+ explanation = db.explain(query).textual
+ statement = query.get_query_statement(0)
except QueryServerException as ex:
raise QueryError(ex.message)
return {
'status': 0,
- 'explanation': explanation.textual,
- 'statement': query.get_query_statement(0),
+ 'explanation': explanation,
+ 'statement': statement,
}
