From aa604a4cd7f11445faaecdefe356c5360d6926ae Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Thu, 8 Apr 2021 09:17:36 +0300 Subject: [PATCH] fix(sqla): apply sqla type on calculated columns --- superset/connectors/sqla/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index cb506f6c4a522..432430cc891a5 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -224,12 +224,12 @@ def is_temporal(self) -> bool: def get_sqla_col(self, label: Optional[str] = None) -> Column: label = label or self.column_name + db_engine_spec = self.table.database.db_engine_spec + column_spec = db_engine_spec.get_column_spec(self.type) + type_ = column_spec.sqla_type if column_spec else None if self.expression: - col = literal_column(self.expression) + col = literal_column(self.expression, type_=type_) else: - db_engine_spec = self.table.database.db_engine_spec - column_spec = db_engine_spec.get_column_spec(self.type) - type_ = column_spec.sqla_type if column_spec else None col = column(self.column_name, type_=type_) col = self.table.make_sqla_column_compatible(col, label) return col