def get_column_spec( cls, native_type: Optional[str], source: utils.ColumnTypeSource = utils.ColumnTypeSource.GET_TABLE, column_type_mappings: Tuple[ Tuple[ Pattern[str], Union[TypeEngine, Callable[[Match[str]], TypeEngine]], GenericDataType, ], ..., ] = column_type_mappings, ) -> Union[ColumnSpec, None]: """ Converts native database type to sqlalchemy column type. :param native_type: Native database typee :param source: Type coming from the database table or cursor description :return: ColumnSpec object """ col_types = cls.get_sqla_column_type( native_type, column_type_mappings=column_type_mappings ) if col_types: column_type, generic_type = col_types # wrap temporal types in custom type that supports literal binding # using datetimes if generic_type == GenericDataType.TEMPORAL: column_type = literal_dttm_type_factory( type(column_type), cls, native_type or "" ) is_dttm = generic_type == GenericDataType.TEMPORAL return ColumnSpec( sqla_type=column_type, generic_type=generic_type, is_dttm=is_dttm ) return None
def get_column_spec( cls, native_type: Optional[str], source: utils.ColumnTypeSource = utils.ColumnTypeSource.GET_TABLE, column_type_mappings: Tuple[Tuple[Pattern[str], Union[TypeEngine, Callable[[Match[str]], TypeEngine]], GenericDataType, ], ..., ] = column_type_mappings, ) -> Union[ColumnSpec, None]: """ Converts native database type to sqlalchemy column type. :param native_type: Native database typee :param source: Type coming from the database table or cursor description :return: ColumnSpec object """ column_type = None if (cls.get_sqla_column_type(native_type, column_type_mappings=column_type_mappings) is not None): column_type, generic_type = cls.get_sqla_column_type( # type: ignore native_type, column_type_mappings=column_type_mappings) is_dttm = generic_type == GenericDataType.TEMPORAL if column_type: return ColumnSpec(sqla_type=column_type, generic_type=generic_type, is_dttm=is_dttm) return None