diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 4ae3efbaf1c7e..19bd3bbc1bb04 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -230,6 +230,8 @@ def db_engine_spec(self) -> Type[BaseEngineSpec]: @property def type_generic(self) -> Optional[utils.GenericDataType]: + if self.is_dttm: + return GenericDataType.TEMPORAL column_spec = self.db_engine_spec.get_column_spec(self.type) return column_spec.generic_type if column_spec else None diff --git a/tests/sqla_models_tests.py b/tests/sqla_models_tests.py index 69dc4c737f1c3..a759270809c25 100644 --- a/tests/sqla_models_tests.py +++ b/tests/sqla_models_tests.py @@ -102,6 +102,10 @@ def test_db_column_types(self): self.assertEqual(col.is_numeric, db_col_type == GenericDataType.NUMERIC) self.assertEqual(col.is_string, db_col_type == GenericDataType.STRING) + for str_type, db_col_type in test_cases.items(): + col = TableColumn(column_name="foo", type=str_type, table=tbl, is_dttm=True) + self.assertTrue(col.is_temporal) + @patch("superset.jinja_context.g") def test_extra_cache_keys(self, flask_g): flask_g.user.username = "abc"