This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 594cd70 A few fixes for Presto connection (#6720)
594cd70 is described below
commit 594cd7096070a742209851ff9112d5bf4d16a7be
Author: agrawaldevesh <[email protected]>
AuthorDate: Wed Jan 23 21:12:27 2019 -0800
A few fixes for Presto connection (#6720)
* Preserve existing configuration when modifying it in case of user
impersonation
* Add logging when a table cannot be added due to some schema issues
---
superset/connectors/sqla/views.py | 9 +++++++--
superset/models/core.py | 4 +++-
superset/views/core.py | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/superset/connectors/sqla/views.py
b/superset/connectors/sqla/views.py
index 6ba2f26..a7c77c2 100644
--- a/superset/connectors/sqla/views.py
+++ b/superset/connectors/sqla/views.py
@@ -16,6 +16,8 @@
# under the License.
# pylint: disable=C,R,W
"""Views used by the SqlAlchemy connector"""
+import logging
+
from flask import flash, Markup, redirect
from flask_appbuilder import CompactCRUDMixin, expose
from flask_appbuilder.actions import action
@@ -33,6 +35,8 @@ from superset.views.base import (
)
from . import models
+logger = logging.getLogger(__name__)
+
class TableColumnInlineView(CompactCRUDMixin, SupersetModelView): # noqa
datamodel = SQLAInterface(models.TableColumn)
@@ -269,12 +273,13 @@ class TableModelView(DatasourceModelView, DeleteMixin,
YamlExportMixin): # noqa
# Fail before adding if the table can't be found
try:
table.get_sqla_table_object()
- except Exception:
+ except Exception as e:
+ logger.exception(f'Got an error in pre_add for {table.name}')
raise Exception(_(
'Table [{}] could not be found, '
'please double check your '
'database connection, schema, and '
- 'table name').format(table.name))
+ 'table name, error: {}').format(table.name, str(e)))
def post_add(self, table, flash_message=True):
table.fetch_metadata()
diff --git a/superset/models/core.py b/superset/models/core.py
index 3f1b9a1..fc4b7e9 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -801,7 +801,9 @@ class Database(Model, AuditMixinNullable, ImportMixin):
self.impersonate_user,
effective_username))
if configuration:
- params['connect_args'] = {'configuration': configuration}
+ d = params.get('connect_args', {})
+ d['configuration'] = configuration
+ params['connect_args'] = d
DB_CONNECTION_MUTATOR = config.get('DB_CONNECTION_MUTATOR')
if DB_CONNECTION_MUTATOR:
diff --git a/superset/views/core.py b/superset/views/core.py
index 677b46f..fa70498 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -1768,7 +1768,7 @@ class Superset(BaseSupersetView):
.get('engine_params', {}))
connect_args = engine_params.get('connect_args')
- if configuration:
+ if configuration and connect_args is not None:
connect_args['configuration'] = configuration
engine = create_engine(uri, **engine_params)