Ver Fonte

[impala] Hive metastore app links if no permission to access it

Fix space stripping in Impala colum types
Romain Rigaux há 11 anos atrás
pai
commit
5d971f8676

+ 1 - 1
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -594,7 +594,7 @@ class HiveServerTableCompatible(HiveServerTable):
   @property
   def cols(self):
     return [type('Col', (object,), {'name': col.get('col_name', '').strip(),
-                                    'type': col.get('data_type', ''),
+                                    'type': col.get('data_type', col.get('col_type', '')).strip(), # Impala is col_type
                                     'comment': col.get('comment', '').strip(), }) for col in HiveServerTable.cols.fget(self)]
 
 

+ 11 - 3
apps/beeswax/src/beeswax/templates/execute.mako

@@ -635,8 +635,11 @@ ${layout.menubar(section='query')}
 <div id="navigatorQuicklook" class="modal hide fade">
   <div class="modal-header">
     <a href="#" class="close" data-dismiss="modal">&times;</a>
-    <a class="tableLink pull-right" href="#" target="_blank" style="margin-right: 20px;margin-top:6px"><i
-        class="fa fa-external-link"></i> ${ _('View in Metastore Browser') }</a>
+    % if has_metastore:
+    <a class="tableLink pull-right" href="#" target="_blank" style="margin-right: 20px;margin-top:6px">
+      <iclass="fa fa-external-link"></i> ${ _('View in Metastore Browser') }
+    </a>
+    % endif
 
     <h3>${_('Data sample for')} <span class="tableName"></span></h3>
   </div>
@@ -1004,7 +1007,12 @@ $(document).ready(function () {
       $(data.split(" ")).each(function (cnt, table) {
         if ($.trim(table) != "") {
           var _table = $("<li>");
-          _table.html("<a href='javascript:void(0)' class='pull-right'><i class='fa fa-list' title='" + "${ _('Preview Sample data') }" + "' style='margin-left:5px'></i></a><a href='/${ app_name }/api/table/" + viewModel.database() + "/" + table + "' target='_blank' class='pull-right hide'><i class='fa fa-eye' title='" + "${ _('View in Metastore Browser') }" + "'></i></a><a href='javascript:void(0)' title='" + table + "'><i class='fa fa-table'></i> " + table + "</a><ul class='unstyled'></ul>");
+          var metastore_link = "";
+          % if has_metastore:
+            metastore_link = "<i class='fa fa-eye' title='" + "${ _('View in Metastore Browser') }" + "'></i></a>";
+          % endif
+          _table.html("<a href='javascript:void(0)' class='pull-right'><i class='fa fa-list' title='" + "${ _('Preview Sample data') }" + "' style='margin-left:5px'></i></a><a href='/metastore/table/" + viewModel.database() + "/" + table + "' target='_blank' class='pull-right hide'>" + metastore_link + "<a href='javascript:void(0)' title='" + table + "'><i class='fa fa-table'></i> " + table + "</a><ul class='unstyled'></ul>");
+
           _table.data("table", table).attr("id", "navigatorTables_" + table);
           _table.find("a:eq(2)").on("click", function () {
             _table.find(".fa-table").removeClass("fa-table").addClass("fa-spin").addClass("fa-spinner");

+ 4 - 3
apps/beeswax/src/beeswax/views.py

@@ -18,6 +18,7 @@
 import json
 import logging
 import re
+import time
 
 from django import forms
 from django.contrib import messages
@@ -29,6 +30,7 @@ from django.utils.html import escape
 from django.utils.translation import ugettext as _
 from django.core.urlresolvers import reverse
 
+from desktop.appmanager import get_apps_dict
 from desktop.context_processors import get_app_name
 from desktop.lib.paginator import Paginator
 from desktop.lib.django_util import copy_query_dict, format_preserving_redirect, render
@@ -47,8 +49,6 @@ from beeswax.models import SavedQuery, QueryHistory
 from beeswax.server import dbms
 from beeswax.server.dbms import expand_exception, get_query_server_config
 
-import time
-
 
 LOG = logging.getLogger(__name__)
 
@@ -391,7 +391,8 @@ def execute_query(request, design_id=None, query_history_id=None):
     'autocomplete_base_url': reverse(get_app_name(request) + ':api_autocomplete_databases', kwargs={}),
     'can_edit_name': design and design.id and not design.is_auto,
     'action': action,
-    'on_success_url': request.GET.get('on_success_url')
+    'on_success_url': request.GET.get('on_success_url'),
+    'has_metastore': 'metastore' in get_apps_dict(request.user)
   }
 
   return render('execute.mako', request, context)