Преглед на файлове

HUE-8740 [sqlalchemy] Remove extra dataset prefixes on table listing

Romain преди 6 години
родител
ревизия
5c0641fccd
променени са 1 файла, в които са добавени 7 реда и са изтрити 0 реда
  1. 7 0
      desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

+ 7 - 0
desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

@@ -244,6 +244,7 @@ class SqlAlchemyApi(Api):
       tables_meta = []
       tables_meta = []
       database = self._fix_phoenix_empty_database(database)
       database = self._fix_phoenix_empty_database(database)
       for t in assist.get_tables(database):
       for t in assist.get_tables(database):
+        t = self._fix_bigquery_db_prefixes(t)
         tables_meta.append({'name': t, 'type': 'Table', 'comment': ''})
         tables_meta.append({'name': t, 'type': 'Table', 'comment': ''})
       response['tables_meta'] = tables_meta
       response['tables_meta'] = tables_meta
     elif column is None:
     elif column is None:
@@ -307,6 +308,12 @@ class SqlAlchemyApi(Api):
   def _fix_phoenix_empty_database(self, database):
   def _fix_phoenix_empty_database(self, database):
     return None if self.options['url'].startswith('phoenix://') and database == 'NULL' else database
     return None if self.options['url'].startswith('phoenix://') and database == 'NULL' else database
 
 
+  def _fix_bigquery_db_prefixes(self, table_or_column):
+    if self.options['url'].startswith('bigquery://'):
+      table_or_column = table_or_column.rsplit('.', 1)[1]
+    return table_or_column
+
+
 
 
 class Assist():
 class Assist():