Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"Decimal32": DecimalType,
"Decimal64": DecimalType,
"Decimal128": DecimalType,
}
PY_TYPES_MAPPING = {
int: IntType.unconvert,
float: FloatType.unconvert,
str: StrType.unconvert,
dt.date: DateType.unconvert,
dt.datetime: DateTimeType.unconvert,
tuple: TupleType.unconvert,
list: ArrayType.unconvert,
type(None): NullableType.unconvert,
UUID: UUIDType.unconvert,
Decimal: DecimalType.unconvert,
}
def what_py_type(name: str, container: bool = False) -> BaseType:
""" Returns needed type class from clickhouse type name """
name = name.strip()
try:
return CH_TYPES_MAPPING[name.split("(")[0]](name, container=container)
except KeyError:
raise ChClientError(f"Unrecognized type name: '{name}'")
def what_py_converter(name: str, container: bool = False) -> Callable:
""" Returns needed type class from clickhouse type name """
return what_py_type(name, container).convert
"Int64": IntType,
"Float32": FloatType,
"Float64": FloatType,
"String": StrType,
"FixedString": StrType,
"Enum8": StrType,
"Enum16": StrType,
"Date": DateType,
"DateTime": DateTimeType,
"Tuple": TupleType,
"Array": ArrayType,
"Nullable": NullableType,
"Nothing": NothingType,
"UUID": UUIDType,
"LowCardinality": LowCardinalityType,
"Decimal": DecimalType,
"Decimal32": DecimalType,
"Decimal64": DecimalType,
"Decimal128": DecimalType,
}
PY_TYPES_MAPPING = {
int: IntType.unconvert,
float: FloatType.unconvert,
str: StrType.unconvert,
dt.date: DateType.unconvert,
dt.datetime: DateTimeType.unconvert,
tuple: TupleType.unconvert,
list: ArrayType.unconvert,
type(None): NullableType.unconvert,
UUID: UUIDType.unconvert,
Decimal: DecimalType.unconvert,