Browse Source

[hive] Support fetching table list from various SQL servers

Some return more columns like isTemporary, so we just keep the
first column in the result set (it is always the table name)
Romain Rigaux 10 years ago
parent
commit
1aa9cae8a0
1 changed files with 2 additions and 2 deletions
  1. 2 2
      apps/beeswax/src/beeswax/server/dbms.py

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

@@ -175,7 +175,7 @@ class HiveServer2Dbms(object):
 
 
   def get_tables(self, database='default', table_names='*'):
   def get_tables(self, database='default', table_names='*'):
     identifier = self.to_matching_wildcard(table_names)
     identifier = self.to_matching_wildcard(table_names)
-    identifier = "'%s'" % identifier if identifier != '*' else '' # Filter not always supported
+    identifier = "'%s'" % identifier if identifier != '*' else '' # Filter not supported in SparkSql
 
 
     hql = "SHOW TABLES IN `%s` %s" % (database, identifier) # self.client.get_tables(database, table_names) is too slow
     hql = "SHOW TABLES IN `%s` %s" % (database, identifier) # self.client.get_tables(database, table_names) is too slow
     query = hql_query(hql)
     query = hql_query(hql)
@@ -186,7 +186,7 @@ class HiveServer2Dbms(object):
     if handle:
     if handle:
       result = self.fetch(handle, rows=5000)
       result = self.fetch(handle, rows=5000)
       self.close(handle)
       self.close(handle)
-      tables = [name for table in result.rows() for name in table]
+      tables = [table[0] for table in result.rows()] # We only keep the first column as the name, SparkSql returns multiple columns
       if len(tables) <= APPLY_NATURAL_SORT_MAX.get():
       if len(tables) <= APPLY_NATURAL_SORT_MAX.get():
         tables = apply_natural_sort(tables)
         tables = apply_natural_sort(tables)
       return tables
       return tables