Browse Source

HUE-5129 [metastore] Properly browse Kudu tables from metastore

Romain Rigaux 9 years ago
parent
commit
e446cb95f1

+ 2 - 2
apps/beeswax/src/beeswax/server/dbms.py

@@ -278,7 +278,7 @@ class HiveServer2Dbms(object):
     return self.execute_and_watch(query, design=design)
     return self.execute_and_watch(query, design=design)
 
 
 
 
-  def select_star_from(self, database, table, limit=10000):
+  def select_star_from(self, database, table, limit=1000):
     if table.partition_keys:  # Filter on max number of partitions for partitioned tables
     if table.partition_keys:  # Filter on max number of partitions for partitioned tables
       hql = self._get_sample_partition_query(database, table, limit=limit) # Currently need a limit
       hql = self._get_sample_partition_query(database, table, limit=limit) # Currently need a limit
     else:
     else:
@@ -286,7 +286,7 @@ class HiveServer2Dbms(object):
     return self.execute_statement(hql)
     return self.execute_statement(hql)
 
 
 
 
-  def get_select_star_query(self, database, table, limit=10000):
+  def get_select_star_query(self, database, table, limit=1000):
     if table.partition_keys:  # Filter on max number of partitions for partitioned tables
     if table.partition_keys:  # Filter on max number of partitions for partitioned tables
       hql = self._get_sample_partition_query(database, table, limit=limit) # Currently need a limit
       hql = self._get_sample_partition_query(database, table, limit=limit) # Currently need a limit
     else:
     else:

+ 3 - 2
apps/metastore/src/metastore/templates/metastore.mako

@@ -252,8 +252,9 @@ ${ components.menubar() }
     <div title="${ _('Created') }"><i class="fa fa-fw fa-clock-o muted"></i> <span data-bind="text: localeFormat(details.properties.create_time)"></span></div>
     <div title="${ _('Created') }"><i class="fa fa-fw fa-clock-o muted"></i> <span data-bind="text: localeFormat(details.properties.create_time)"></span></div>
     <div title="${ _('Format') }">
     <div title="${ _('Format') }">
       <i class="fa fa-fw fa-file-o muted"></i> <span data-bind="text: details.properties.format"></span>
       <i class="fa fa-fw fa-file-o muted"></i> <span data-bind="text: details.properties.format"></span>
-      <i class="fa fa-fw fa-archive muted"></i> <span data-bind="visible: details.properties.compressed" style="display:none;">${_('Compressed')}</span>
-      <span data-bind="visible: !details.stats.compressed" style="display:none;">${_('Not compressed')}</span>
+      <i class="fa fa-fw fa-archive muted"></i>
+      <span data-bind="visible: details.properties.compressed" style="display:none;">${_('Compressed')}</span>
+      <span data-bind="visible: ! details.properties.compressed" style="display:none;">${_('Not compressed')}</span>
     </div>
     </div>
   </div>
   </div>
   <!-- /ko -->
   <!-- /ko -->

+ 2 - 2
desktop/libs/indexer/src/indexer/api3.py

@@ -259,7 +259,7 @@ def _create_table_from_a_file(request, source, destination):
   if table_format in ('parquet', 'kudu'):
   if table_format in ('parquet', 'kudu'):
     if load_data:
     if load_data:
       table_name, final_table_name = 'hue__tmp_%s' % table_name, table_name
       table_name, final_table_name = 'hue__tmp_%s' % table_name, table_name
-  
+
       sql += '\n\nDROP TABLE IF EXISTS `%(database)s`.`%(table_name)s`;\n' % {
       sql += '\n\nDROP TABLE IF EXISTS `%(database)s`.`%(table_name)s`;\n' % {
           'database': database,
           'database': database,
           'table_name': table_name
           'table_name': table_name
@@ -269,7 +269,7 @@ def _create_table_from_a_file(request, source, destination):
       file_format = table_format
       file_format = table_format
       skip_header = False
       skip_header = False
       if table_format == 'kudu':
       if table_format == 'kudu':
-        columns = [col for col in columns if col['name'] in primary_keys] + [col for col in columns if col['name'] not in primary_keys]      
+        columns = [col for col in columns if col['name'] in primary_keys] + [col for col in columns if col['name'] not in primary_keys]
 
 
   if external or (load_data and table_format in ('parquet', 'kudu')):
   if external or (load_data and table_format in ('parquet', 'kudu')):
     if not request.fs.isdir(external_path): # File selected
     if not request.fs.isdir(external_path): # File selected

+ 5 - 4
desktop/libs/indexer/src/indexer/templates/gen/create_table_statement.mako

@@ -57,10 +57,11 @@ COMMENT "${col["comment"]|n}" \
 </%def>
 </%def>
 
 
 <%def name="kudu_range_partition(partition)">
 <%def name="kudu_range_partition(partition)">
-% if partition['name'] == 'HASH':
-  HASH (${ ', '.join(partition['columns']) }) PARTITIONS ${ partition['int_val'] }
-% elif partition['name'] == 'RANGE BY':
-  RANGE BY (${ ', '.join(partition['columns']) }) (${ ', '.join(partition['range_partitions']) })
+PARTITION \
+% if partition['name'] == 'VALUES':
+  ${ partition['lower_val'] } <${ '=' if include_upper_val else '' } VALUES ${ '=' if include_upper_val else '' } ${ partition['upper_val'] }
+% elif partition['name'] == 'VALUE':
+  VALUE (${ ', '.join(partition['values']) })
 % endif
 % endif
 </%def>
 </%def>
 
 

+ 1 - 1
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -1226,7 +1226,7 @@ ${ assist.assistPanel() }
                 var snippet = self.editorVM.selectedNotebook().snippets()[0]; // Could be native to editor at some point
                 var snippet = self.editorVM.selectedNotebook().snippets()[0]; // Could be native to editor at some point
                 if (! snippet.result.handle().has_more_statements) {
                 if (! snippet.result.handle().has_more_statements) {
                   if (self.editorVM.selectedNotebook().onSuccessUrl()) {
                   if (self.editorVM.selectedNotebook().onSuccessUrl()) {
-                  //  window.location.href = self.editorVM.selectedNotebook().onSuccessUrl();
+                    window.location.href = self.editorVM.selectedNotebook().onSuccessUrl();
                   }
                   }
                 } else { // Perform last DROP statement execute
                 } else { // Perform last DROP statement execute
                   snippet.execute();
                   snippet.execute();

+ 5 - 1
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -666,7 +666,11 @@ class HS2Api(Api):
   def get_select_star_query(self, snippet, database, table):
   def get_select_star_query(self, snippet, database, table):
     db = self._get_db(snippet)
     db = self._get_db(snippet)
     table = db.get_table(database, table)
     table = db.get_table(database, table)
-    return db.get_select_star_query(database, table, limit=1000)
+    if table.is_impala_only:
+      snippet['type'] = 'impala'
+      db = self._get_db(snippet)
+
+    return db.get_select_star_query(database, table, limit=100)
 
 
 
 
   def _get_handle(self, snippet):
   def _get_handle(self, snippet):

+ 2 - 3
desktop/libs/notebook/src/notebook/views.py

@@ -137,11 +137,10 @@ def new(request):
 
 
 
 
 def browse(request, database, table):
 def browse(request, database, table):
-  editor_type = request.GET.get('type', 'hive')
-
-  snippet = {'type': editor_type}
+  snippet = {'type': 'hive'}
   sql_select = get_api(request, snippet).get_select_star_query(snippet, database, table)
   sql_select = get_api(request, snippet).get_select_star_query(snippet, database, table)
 
 
+  editor_type = snippet['type']
   editor = make_notebook(name='Browse', editor_type=editor_type, statement=sql_select, status='ready-execute')
   editor = make_notebook(name='Browse', editor_type=editor_type, statement=sql_select, status='ready-execute')
 
 
   return render('editor.mako', request, {
   return render('editor.mako', request, {