Просмотр исходного кода

[metastore] Improve UX of list of partition values on table page

Romain Rigaux 10 лет назад
Родитель
Сommit
fce33b3

+ 4 - 4
apps/beeswax/src/beeswax/tests.py

@@ -1662,7 +1662,7 @@ for x in sys.stdin:
 
   def test_get_sample_partitioned(self):
     # Test limit of one partition
-    finish = conf.LIST_PARTITIONS_LIMIT.set_for_testing(1)
+    finish = conf.QUERY_PARTITIONS_LIMIT.set_for_testing(1)
     try:
       table_name = 'test_partitions'
       partition_spec = "(baz='baz_one' AND boom='boom_two')"
@@ -1673,7 +1673,7 @@ for x in sys.stdin:
       finish()
 
     # Test limit of more than one partition
-    finish = conf.LIST_PARTITIONS_LIMIT.set_for_testing(2)
+    finish = conf.QUERY_PARTITIONS_LIMIT.set_for_testing(2)
     try:
       table_name = 'test_partitions'
       partition_spec = "(baz='baz_one' AND boom='boom_two') OR (baz='baz_foo' AND boom='boom_bar')"
@@ -1696,7 +1696,7 @@ for x in sys.stdin:
     """
     resp = _make_query(self.client, hql, wait=True, local=False, max=180.0, database=self.db_name)
 
-    finish = conf.LIST_PARTITIONS_LIMIT.set_for_testing(2)
+    finish = conf.QUERY_PARTITIONS_LIMIT.set_for_testing(2)
     try:
       table_name = 'test_partitions_int'
       table = self.db.get_table(database=self.db_name, table_name=table_name)
@@ -1712,7 +1712,7 @@ for x in sys.stdin:
     """
     resp = _make_query(self.client, hql, wait=True, local=False, max=60.0, database=self.db_name)
 
-    finish = conf.LIST_PARTITIONS_LIMIT.set_for_testing(2)
+    finish = conf.QUERY_PARTITIONS_LIMIT.set_for_testing(2)
     try:
       table_name = 'test_partitions_empty'
       table = self.db.get_table(database=self.db_name, table_name=table_name)

+ 7 - 4
apps/metastore/src/metastore/templates/describe_table.mako

@@ -171,7 +171,7 @@ ${ assist.assistPanel() }
         %endif
         <th>${_('Values')}</th>
         <th>${_('Spec')}</th>
-        <th>${_('Sd')}</th>
+        <th>${_('Browse')}</th>
       </tr>
     </thead>
     <tbody>
@@ -185,9 +185,12 @@ ${ assist.assistPanel() }
               </a>
             </td>
           %endif
-          <td>${ column.values }</td>
-          <td>${ column.partition_spec }</td>
-          <td>${ column.sd }</td>
+          <td><a href="${ column['readUrl'] }">${ column['columns'] }</a></td>
+          <td>${ column['partitionSpec'] }</td>
+          <td>
+            <a href="${ column['readUrl'] }"><i class="fa fa-th"></i> ${_('Data')}</a>
+            <a href="${ column['browseUrl'] }"><i class="fa fa-file-o"></i> ${_('Files')}</a>
+        </td>
         </tr>
       % endfor
     </tbody>

+ 19 - 11
apps/metastore/src/metastore/views.py

@@ -244,7 +244,7 @@ def describe_table(request, database, table):
 
     partitions = None
     if app_name != 'impala' and table.partition_keys:
-      partitions = db.get_partitions(database, table)
+      partitions = [_massage_partition(database, table, partition) for partition in db.get_partitions(database, table)]
 
     return render(renderable, request, {
       'breadcrumbs': [{
@@ -418,16 +418,7 @@ def describe_partitions(request, database, table):
 
   partitions = db.get_partitions(database, table_obj, partition_spec, reverse_sort=reverse_sort)
 
-  massaged_partitions = []
-  for partition in partitions:
-    massaged_partitions.append({
-      'columns': partition.values,
-      'partitionSpec': partition.partition_spec,
-      'readUrl': reverse('metastore:read_partition', kwargs={'database': database, 'table': table_obj.name,
-                                                             'partition_spec': urllib.quote(partition.partition_spec)}),
-      'browseUrl': reverse('metastore:browse_partition', kwargs={'database': database, 'table': table_obj.name,
-                                                                 'partition_spec': urllib.quote(partition.partition_spec)})
-    })
+  massaged_partitions = [_massage_partition(database, table_obj, partition) for partition in partitions]
 
   if request.method == "POST" or request.GET.get('format', 'html') == 'json':
     return JsonResponse({
@@ -457,6 +448,23 @@ def describe_partitions(request, database, table):
     })
 
 
+def _massage_partition(database, table, partition):
+  return {
+    'columns': partition.values,
+    'partitionSpec': partition.partition_spec,
+    'readUrl': reverse('metastore:read_partition', kwargs={
+        'database': database,
+        'table': table.name,
+        'partition_spec': urllib.quote(partition.partition_spec)
+    }),
+    'browseUrl': reverse('metastore:browse_partition', kwargs={
+        'database': database,
+        'table': table.name,
+        'partition_spec': urllib.quote(partition.partition_spec)
+    })
+  }
+
+
 def browse_partition(request, database, table, partition_spec):
   db = dbms.get(request.user)
   try: