Przeglądaj źródła

HUE-3450 [metadata] More error protection in topTables API

Romain Rigaux 9 lat temu
rodzic
commit
5e46b4fb65

+ 4 - 3
desktop/libs/metadata/src/metadata/optimizer_api.py

@@ -59,8 +59,6 @@ def top_tables(request):
   database = request.POST.get('database', 'default')
   len = request.POST.get('len', 1000)
 
-  api = OptimizerApi()
-
   if OPTIMIZER.MOCKING.get():
     from beeswax.server import dbms
     from beeswax.server.dbms import get_query_server_config
@@ -74,6 +72,9 @@ def top_tables(request):
     Get back:
     # u'details': [{u'columnCount': 28, u'name': u'date_dim', u'patternCount': 136, u'workloadPercent': 89, u'total': 92, u'type': u'Dimension', u'eid': u'19'},
     """
+    api = OptimizerApi()
+    data = api.top_tables()
+
     tables = [{
         'eid': table['eid'],
         'name': table['name'],
@@ -82,7 +83,7 @@ def top_tables(request):
         'patternCount': table['patternCount'],
         'total': table['total'],
         'is_fact': table['type'] != 'Dimension'
-        } for table in api.top_tables()['details']
+        } for table in data['details']
     ]
 
   response['top_tables'] = tables