Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix precision and scale truncation warnings #100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tap_postgres/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,14 @@ def compute_tap_stream_id(database_name, schema_name, table_name):

#NB> numeric/decimal columns in postgres without a specified scale && precision
#default to 'up to 131072 digits before the decimal point; up to 16383
#digits after the decimal point'. For practical reasons, we are capping this at 74/38
#digits after the decimal point'. For practical reasons, we are capping this at 100/38
# https://www.postgresql.org/docs/10/static/datatype-numeric.html#DATATYPE-NUMERIC-TABLE
MAX_SCALE = 38
MAX_PRECISION = 100

def numeric_precision(c):
if c.numeric_precision is None:
LOGGER.warning('capping decimal precision to 100. THIS MAY CAUSE TRUNCATION')
return MAX_PRECISION

if c.numeric_precision > MAX_PRECISION:
Expand All @@ -182,7 +183,9 @@ def numeric_precision(c):

def numeric_scale(c):
if c.numeric_scale is None:
LOGGER.warning('capping decimal scale to 38. THIS MAY CAUSE TRUNCATION')
return MAX_SCALE

if c.numeric_scale > MAX_SCALE:
LOGGER.warning('capping decimal scale to 38. THIS MAY CAUSE TRUNCATION')
return MAX_SCALE
Expand Down