Bladeren bron

added type = 'view' for views

ayush.goyal 4 jaren geleden
bovenliggende
commit
e3dd9c67a8

+ 4 - 1
desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

@@ -438,9 +438,12 @@ class SqlAlchemyApi(Api):
       response['databases'] = [db or '' for db in assist.get_databases()]
     elif table is None:
       tables_meta = []
-      for t in assist.get_tables(database):
+      for t in assist.get_table_names(database):
         t = self._fix_bigquery_db_prefixes(t)
         tables_meta.append({'name': t, 'type': 'Table', 'comment': ''})
+      for t in assist.get_view_names(database):
+        t = self._fix_bigquery_db_prefixes(t)
+        tables_meta.append({'name': t, 'type': 'View', 'comment': ''})
       response['tables_meta'] = tables_meta
     elif column is None:
       columns = assist.get_columns(database, table)

+ 2 - 0
desktop/libs/notebook/src/notebook/connectors/sql_alchemy_tests.py

@@ -287,6 +287,8 @@ class TestApi(object):
             response = SqlAlchemyApi(self.user, self.interpreter).autocomplete(snippet, database='database1')
             assert_equal(response['tables_meta'][0]['name'], 'table1')
             assert_equal(response['tables_meta'][1]['name'], 'view1')
+            assert_equal(response['tables_meta'][0]['type'], 'Table')
+            assert_equal(response['tables_meta'][1]['type'], 'View')
 
 
   def test_get_sample_data_table(self):