precision and scale not supported for DECIMAL type
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 545
- PR merge metrics
- No merged PRs in 30d
Description
The [current implementation of `DECIMAL` (/`NUMERIC`)](https://github.com/dropbox/PyHive/blob/master/pyhive/sqlalchemy_hive.py#L176-L178) does not support the precision and scale attribute which is supported [since hive 0.13](https://cwiki.apache.org/confluence/display/hive/languagemanual+types#LanguageManualTypes-NumericTypes).
possible implementation solution:
``` python
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}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.