Pārlūkot izejas kodu

HUE-4908 [metastore] Add primiary key icons to the Kudu columns

Romain Rigaux 8 gadi atpakaļ
vecāks
revīzija
3376fcacc6

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

@@ -108,11 +108,24 @@ def _autocomplete(db, database=None, table=None, column=None, nested=None):
       tables_meta = db.get_tables_meta(database=database)
       response['tables_meta'] = tables_meta
     elif column is None:
-      t = db.get_table(database, table)
-      response['hdfs_link'] = t.hdfs_link
-      response['columns'] = [column.name for column in t.cols]
-      response['extended_columns'] = massage_columns_for_json(t.cols)
-      response['partition_keys'] = [{'name': part.name, 'type': part.type} for part in t.partition_keys]
+      table = db.get_table(database, table)
+      response['hdfs_link'] = table.hdfs_link
+
+      cols_extended = massage_columns_for_json(table.cols)
+
+      if table.is_impala_only: # Expand Kudu columns information
+        query_server = get_query_server_config('impala')
+        db = dbms.get(db.client.user, query_server)
+
+        col_options = db.get_table_describe(database, table.name)
+        extra_col_options = dict([(col[0], dict(zip(col_options.cols(), col))) for col in col_options.rows()])
+
+        for col_props in cols_extended:
+          col_props.update(extra_col_options.get(col_props['name'], {}))
+
+      response['columns'] = [column.name for column in table.cols]
+      response['extended_columns'] = cols_extended
+      response['partition_keys'] = [{'name': part.name, 'type': part.type} for part in table.partition_keys]
     else:
       col = db.get_column(database, table, column)
       if col:

+ 1 - 1
apps/metastore/src/metastore/templates/metastore.mako

@@ -124,7 +124,7 @@ ${ components.menubar() }
           <td title="${ _("Scroll to the column") }">
             <!-- ko if: $root.database().table().samples.loading() -->
             <span data-bind="text: name"></span>
-            <!-- ko if: typeof primary_key !== 'undefined' -->
+            <!-- ko if: typeof primary_key !== 'undefined' && primary_key() == 'true' -->
               <i class="fa fa-key"></i>
             <!-- /ko -->
             <!-- /ko -->

+ 1 - 17
apps/metastore/src/metastore/views.py

@@ -254,27 +254,11 @@ def describe_table(request, database, table):
       raise PopupException(_("Hive Error"), detail=e)
 
   if request.REQUEST.get("format", "html") == "json":
-    cols = []
-    extra_col_options = {}
-
-    if table.is_impala_only: # Expand columns information
-      query_server = get_query_server_config('impala')
-      db = dbms.get(request.user, query_server)
-
-      col_options = db.get_table_describe(database, table.name)
-      extra_col_options = dict([(col[0], dict(zip(col_options.cols(), col))) for col in col_options.rows()])
-
-    for col in table.cols:
-      col_props = {'name': col.name, 'type': col.type, 'comment': col.comment}
-      if extra_col_options:
-        col_props.update(extra_col_options.get(col.name, {}))
-      cols.append(col_props)
-
     return JsonResponse({
         'status': 0,
         'name': table.name,
         'partition_keys': [{'name': part.name, 'type': part.type} for part in table.partition_keys],
-        'cols': cols,
+        'cols': [{'name': col.name, 'type': col.type, 'comment': col.comment} for col in table.cols],
         'path_location': table.path_location,
         'hdfs_link': table.hdfs_link,
         'comment': table.comment,