PyHive icon indicating copy to clipboard operation
PyHive copied to clipboard

precision and scale not supported for DECIMAL type

Open leo-schick opened this issue 2 years ago • 0 comments
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}

leo-schick avatar Dec 01 '22 09:12 leo-schick