PyHive
PyHive copied to clipboard
precision and scale not supported for DECIMAL type
trafficstars
The current implementation of DECIMAL (/NUMERIC) does not support the precision and scale attribute which is supported since hive 0.13.
possible implementation solution:
class HiveTypeCompiler(compiler.GenericTypeCompiler):
# [..]
def visit_NUMERIC(self, type_):
precision = getattr(type_, "precision", None)
if precision is None:
return "DECIMAL"
else:
scale = getattr(type_, "scale", None)
if scale is None:
return "DECIMAL(%(precision)s)" % {"precision": precision}
else:
return "DECIMAL(%(precision)s, %(scale)s)" % {"precision": precision, "scale": scale}