Skip to content

Commit

Permalink
support precision and scale for DECIMAL/NUMERIC dropbox#439
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-schick committed Dec 1, 2022
1 parent 3547bd6 commit ceb2572
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pyhive/sqlalchemy_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,15 @@ def visit_INTEGER(self, type_):
return 'INT'

def visit_NUMERIC(self, type_):
return 'DECIMAL'
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}

def visit_CHAR(self, type_):
return 'STRING'
Expand Down

0 comments on commit ceb2572

Please sign in to comment.