فهرست منبع

HUE-7877 [hive] Move subquery table to the core HiveServer2 API

Romain Rigaux 7 سال پیش
والد
کامیت
ce8cfa456e
2فایلهای تغییر یافته به همراه24 افزوده شده و 18 حذف شده
  1. 2 18
      apps/beeswax/src/beeswax/api.py
  2. 22 0
      apps/beeswax/src/beeswax/server/dbms.py

+ 2 - 18
apps/beeswax/src/beeswax/api.py

@@ -34,7 +34,6 @@ from desktop.lib.i18n import force_unicode
 from desktop.lib.parameterization import substitute_variables
 from metastore import parser
 from notebook.models import escape_rows
-from indexer.file_format import HiveFormat
 
 import beeswax.models
 
@@ -44,7 +43,8 @@ from beeswax.conf import USE_GET_LOG_API
 from beeswax.forms import QueryForm
 from beeswax.models import Session, QueryHistory
 from beeswax.server import dbms
-from beeswax.server.dbms import expand_exception, get_query_server_config, QueryServerException, QueryServerTimeoutException
+from beeswax.server.dbms import expand_exception, get_query_server_config, QueryServerException, QueryServerTimeoutException,\
+  SubQueryTable
 from beeswax.views import authorized_get_design, authorized_get_query_history, make_parameterization_form,\
                           safe_get_design, save_design, massage_columns_for_json, _get_query_handle_and_state, \
                           parse_out_jobs
@@ -110,22 +110,6 @@ def _autocomplete(db, database=None, table=None, column=None, nested=None, query
       response['tables_meta'] = tables_meta
     elif column is None:
       if query is not None:
-        class SubQueryTable():
-          def __init__(self, db, query):
-            self.query = query
-            # Table Properties            
-            self.name = 'Test'
-            cols = db.get_query_metadata(query).data_table.cols()
-            for col in cols:
-              col.name = re.sub('^t\.', '', col.name)
-              col.type = HiveFormat.FIELD_TYPE_TRANSLATE.get(col.type, 'string')
-            self.cols =  cols
-            self.hdfs_link = None
-            self.comment = None
-            self.is_impala_only = False
-            self.is_view = False
-            self.partition_keys = []
-            self.properties = {}
         table = SubQueryTable(db, query)
       else:
         table = db.get_table(database, table)

+ 22 - 0
apps/beeswax/src/beeswax/server/dbms.py

@@ -16,6 +16,7 @@
 # limitations under the License.
 
 import logging
+import re
 import threading
 import time
 
@@ -28,6 +29,7 @@ from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.parameterization import substitute_variables
 from desktop.models import Cluster, ANALYTIC_DB
 from filebrowser.views import location_to_url
+from indexer.file_format import HiveFormat
 
 from beeswax import hive_site
 from beeswax.conf import HIVE_SERVER_HOST, HIVE_SERVER_PORT, LIST_PARTITIONS_LIMIT, SERVER_CONN_TIMEOUT, \
@@ -37,6 +39,7 @@ from beeswax.design import hql_query
 from beeswax.hive_site import hiveserver2_use_ssl
 from beeswax.models import QueryHistory, QUERY_TYPES
 
+
 LOG = logging.getLogger(__name__)
 
 
@@ -947,6 +950,25 @@ class DataTable:
   pass
 
 
+class SubQueryTable:
+
+  def __init__(self, db, query):
+    self.query = query
+    # Table Properties            
+    self.name = 'Test'
+    cols = db.get_query_metadata(query).data_table.cols()
+    for col in cols:
+      col.name = re.sub('^t\.', '', col.name)
+      col.type = HiveFormat.FIELD_TYPE_TRANSLATE.get(col.type, 'string')
+    self.cols =  cols
+    self.hdfs_link = None
+    self.comment = None
+    self.is_impala_only = False
+    self.is_view = False
+    self.partition_keys = []
+    self.properties = {}
+
+
 # TODO decorator?
 def expand_exception(exc, db, handle=None):
   try: