Browse Source

HUE-3228 [search] Support listing tables

Romain Rigaux 8 years ago
parent
commit
5c4eb5d

+ 5 - 2
apps/impala/src/impala/dashboard_api.py

@@ -36,10 +36,13 @@ class SQLApi():
   def __init__(self, user):
     self.user = user
 
-  def query(self, dashboard, query, facet):
+  def query(self, dashboard, query, facet=None):
     database, table = self._get_database_table_names(dashboard['name'])
     filters = []
 
+    if query and query['qs'] == [{'q': '_root_:*'}]:
+      return {'response': {'numFound': 0}}
+
     if facet:
       hql = "SELECT %(field)s, COUNT(*) AS top FROM %(database)s.%(table)s WHERE %(field)s IS NOT NULL %(filters)s GROUP BY %(field)s ORDER BY top DESC LIMIT %(limit)s" % {
           'database': database,
@@ -86,7 +89,7 @@ class SQLApi():
     else:
       return self._convert_impala_results(result, dashboard, query)
 
-  def datasets(self):
+  def datasets(self,  show_all=False):
     return ['sample_07', 'web_logs']
 
   def fields(self, dashboard):

+ 3 - 1
apps/search/src/search/api.py

@@ -486,8 +486,10 @@ def get_collections(request):
   result = {'status': -1, 'message': ''}
 
   try:
+    collection = json.loads(request.POST.get('collection'))
     show_all = json.loads(request.POST.get('show_all'))
-    result['collection'] = SearchController(request.user).get_all_indexes(show_all=show_all)
+
+    result['collection'] = get_engine(request.user, collection).datasets(show_all=show_all)
     result['status'] = 0
 
   except Exception, e:

+ 4 - 4
apps/search/src/search/api_engines.py

@@ -43,9 +43,9 @@ class DashboardApi(object):
   def __init__(self, user):
     self.user = user
 
-  def datasets(self): pass
+  def datasets(self, show_all=False): pass
 
-  def query(self, collection, query, facet): pass
+  def query(self, collection, query, facet=None): pass
 
   def suggest(self, collection, query): pass
 
@@ -74,8 +74,8 @@ class SearchApi(DashboardApi):
     response = self.api.query(collection, query)
     return augment_solr_response(response, collection, query)
   
-  def datasets(self):
-    return SearchController(self.user).get_all_indexes()
+  def datasets(self, show_all=False):
+    return SearchController(self.user).get_all_indexes(show_all=show_all)
 
   def fields(self, collection):
     return self.api.fields(collection)