Преглед изворни кода

HUE-7154 [hive] Replace NoSuchObjectException by QueryServerException

Avoid 500 error this way.
NoSuchObjectException does not have any argument for a message and is not used.
Romain Rigaux пре 8 година
родитељ
комит
73423e5

+ 1 - 4
apps/beeswax/src/beeswax/server/dbms.py

@@ -131,9 +131,6 @@ class QueryServerTimeoutException(Exception):
     self.message = message
 
 
-class NoSuchObjectException: pass
-
-
 class HiveServer2Dbms(object):
 
   def __init__(self, client, server_type):
@@ -839,7 +836,7 @@ class HiveServer2Dbms(object):
     partitions = self.get_partitions(db_name, table, partition_spec=partition_spec)
 
     if len(partitions) != 1:
-      raise NoSuchObjectException(_("Query did not return exactly one partition result"))
+      raise QueryServerException(_("Query did not return exactly one partition result: %s") % partitions)
 
     partition = partitions[0]
     partition_query = " AND ".join(partition.partition_spec.split(','))

+ 3 - 4
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -43,8 +43,7 @@ from beeswax import hive_site
 from beeswax.hive_site import hiveserver2_use_ssl
 from beeswax.conf import CONFIG_WHITELIST, LIST_PARTITIONS_LIMIT
 from beeswax.models import Session, HiveServerQueryHandle, HiveServerQueryHistory, QueryHistory
-from beeswax.server.dbms import Table, NoSuchObjectException, DataTable,\
-                                QueryServerException
+from beeswax.server.dbms import Table, DataTable, QueryServerException
 
 
 LOG = logging.getLogger(__name__)
@@ -61,11 +60,11 @@ class HiveServerTable(Table):
   def __init__(self, table_results, table_schema, desc_results, desc_schema):
     if beeswax_conf.THRIFT_VERSION.get() >= 7:
       if not table_results.columns:
-        raise NoSuchObjectException()
+        raise QueryServerException('No table columns')
       self.table = table_results.columns
     else: # Deprecated. To remove in Hue 4.
       if not table_results.rows:
-        raise NoSuchObjectException()
+        raise QueryServerException('No table rows')
       self.table = table_results.rows and table_results.rows[0] or ''
 
     self.table_schema = table_schema

+ 0 - 1
apps/metastore/src/metastore/forms.py

@@ -23,7 +23,6 @@ from desktop.lib.django_forms import ChoiceOrOtherField, MultiForm, SubmitButton
 from filebrowser.forms import PathField
 
 from beeswax import common
-from beeswax.server.dbms import NoSuchObjectException
 from beeswax.models import SavedQuery