mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
feat: add generic type to column payload (#14547)
* feat: add generic type to column payload * feat: add generic type to column payload * xit flaky test
This commit is contained in:
@@ -533,6 +533,7 @@ class BaseColumn(AuditMixinNullable, ImportExportMixin):
|
||||
def __repr__(self) -> str:
|
||||
return str(self.column_name)
|
||||
|
||||
bool_types = ("BOOL",)
|
||||
num_types = (
|
||||
"DOUBLE",
|
||||
"FLOAT",
|
||||
@@ -560,6 +561,22 @@ class BaseColumn(AuditMixinNullable, ImportExportMixin):
|
||||
def is_string(self) -> bool:
|
||||
return self.type and any(map(lambda t: t in self.type.upper(), self.str_types))
|
||||
|
||||
@property
|
||||
def is_boolean(self) -> bool:
|
||||
return self.type and any(map(lambda t: t in self.type.upper(), self.bool_types))
|
||||
|
||||
@property
|
||||
def type_generic(self) -> Optional[utils.GenericDataType]:
|
||||
if self.is_string:
|
||||
return utils.GenericDataType.STRING
|
||||
if self.is_boolean:
|
||||
return utils.GenericDataType.BOOLEAN
|
||||
if self.is_numeric:
|
||||
return utils.GenericDataType.NUMERIC
|
||||
if self.is_temporal:
|
||||
return utils.GenericDataType.TEMPORAL
|
||||
return None
|
||||
|
||||
@property
|
||||
def expression(self) -> Column:
|
||||
raise NotImplementedError()
|
||||
|
||||
Reference in New Issue
Block a user