zhaoyongjie commented on a change in pull request #13294:
URL: https://github.com/apache/superset/pull/13294#discussion_r586061966
##########
File path: superset/db_engine_specs/base.py
##########
@@ -967,25 +973,27 @@ def make_label_compatible(cls, label: str) -> Union[str,
quoted_name]:
return label_mutated
@classmethod
- def get_sqla_column_type(cls, type_: Optional[str]) ->
Optional[TypeEngine]:
+ def get_sqla_column_type(
+ cls, column_type: Optional[str]
+ ) -> Tuple[Union[TypeEngine, utils.GenericDataType, None]]:
"""
Return a sqlalchemy native column type that corresponds to the column
type
defined in the data source (return None to use default type inferred by
SQLAlchemy). Override `column_type_mappings` for specific needs
(see MSSQL for example of NCHAR/NVARCHAR handling).
- :param type_: Column type returned by inspector
+ :param column_type: Column type returned by inspector
:return: SqlAlchemy column type
"""
- if not type_:
- return None
- for regex, sqla_type in cls.column_type_mappings:
- match = regex.match(type_)
+ if not column_type:
+ return None, None
+ for regex, sqla_type, generic_type in cls.column_type_mappings:
+ match = regex.match(column_type)
if match:
if callable(sqla_type):
- return sqla_type(match)
- return sqla_type
- return None
+ return sqla_type(match), generic_type
Review comment:
some SQLAlchemy `Type Visitor` no argument, so we can not use type call
the matched type. You can try postgresql `Date` datetype
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]