precision and scale not supported for DECIMAL type

Open
#439 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
databases

Research direction

Start in pyhive/sqlalchemy_hive.py at the HiveTypeCompiler implementation linked in the issue, then inspect how SQLAlchemy NUMERIC types expose precision and scale. Confirm that DECIMAL/NUMERIC output preserves the unspecified, precision-only, and precision-and-scale cases described in the issue.

Written by the indexing model from the issue text.

Description

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}

Dominant language
Python
Stars
1.7k
Forks
545
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dropbox/PyHive

All issues in dropbox/PyHive

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.