mirror of
https://github.com/apache/superset.git
synced 2026-04-23 18:14:56 +00:00
[table editor] allow selecting physical table (#6046)
* [table editor] allow selecting physical table * Using classes for padding
This commit is contained in:
committed by
GitHub
parent
4667f0c288
commit
da813b7ee3
@@ -8,6 +8,7 @@ from flask_babel import gettext as __
|
||||
|
||||
from superset import appbuilder, db
|
||||
from superset.connectors.connector_registry import ConnectorRegistry
|
||||
from superset.models.core import Database
|
||||
from .base import BaseSupersetView, check_ownership, json_error_response
|
||||
|
||||
|
||||
@@ -42,9 +43,24 @@ class Datasource(BaseSupersetView):
|
||||
@has_access_api
|
||||
def external_metadata(self, datasource_type=None, datasource_id=None):
|
||||
"""Gets column info from the source system"""
|
||||
orm_datasource = ConnectorRegistry.get_datasource(
|
||||
datasource_type, datasource_id, db.session)
|
||||
return self.json_response(orm_datasource.external_metadata())
|
||||
if datasource_type == 'druid':
|
||||
datasource = ConnectorRegistry.get_datasource(
|
||||
datasource_type, datasource_id, db.session)
|
||||
elif datasource_type == 'table':
|
||||
database = (
|
||||
db.session
|
||||
.query(Database)
|
||||
.filter_by(id=request.args.get('db_id'))
|
||||
.one()
|
||||
)
|
||||
Table = ConnectorRegistry.sources['table']
|
||||
datasource = Table(
|
||||
database=database,
|
||||
table_name=request.args.get('table_name'),
|
||||
schema=request.args.get('schema') or None,
|
||||
)
|
||||
external_metadata = datasource.external_metadata()
|
||||
return self.json_response(external_metadata)
|
||||
|
||||
|
||||
appbuilder.add_view_no_menu(Datasource)
|
||||
|
||||
Reference in New Issue
Block a user