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

Issues with floats #6

Open
djdevin opened this issue Oct 5, 2018 · 5 comments
Open

Issues with floats #6

djdevin opened this issue Oct 5, 2018 · 5 comments

Comments

@djdevin
Copy link

djdevin commented Oct 5, 2018

Having issues replicating a field that is a float:

Traceback (most recent call last):
  File "/usr/local/bin/target-postgres", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/target_postgres/__init__.py", line 138, in main
    state = persist_lines(config, input)
  File "/usr/local/lib/python3.6/site-packages/target_postgres/__init__.py", line 68, in persist_lines
    validators[stream].validate(o['record'])
  File "/usr/local/lib/python3.6/site-packages/jsonschema/validators.py", line 130, in validate
    raise error
jsonschema.exceptions.ValidationError: 0.57 is not a multiple of 0.01

Failed validating 'multipleOf' in schema['properties']['credits']:
    {'inclusion': 'available',
     'multipleOf': 0.01,
     'type': ['null', 'number']}

On instance['credits']:
    0.57

It looks like this is the issue here: python-jsonschema/jsonschema#247

Not sure if it's an issue that can be fixed here or somewhere else. Mathematically speaking I think it's accurate judging by that issue, but I'm not really sure what to do.

Here's a sample of the data from the tap:

{
  "type":"RECORD",
  "stream":"course_credit_awarded",
  "record":{
    "credits":0.57,
    "status":1,
    "created":"1970-01-01T00:00:00+00:00",
    "vid":1797,
    "expiration":null,
    "type":"case_manager",
    "date":"2012-07-11T19:48:55+00:00",
    "nid":200,
    "uid":1201,
    "ccaid":1895,
    "changed":"1970-01-01T00:00:00+00:00",
    "author_uid":null
  },
  "version":1538760868289,
  "time_extracted":"2018-10-05T17:34:28.297167Z"
}
@koszti
Copy link

koszti commented Oct 14, 2018

@djdevin give it a try with the PR above

@djdevin
Copy link
Author

djdevin commented Oct 22, 2018

Thanks, with the PR I get

ImportError: cannot import name 'FormatChecker'

@djdevin
Copy link
Author

djdevin commented Oct 23, 2018

May also be related (error also without patch)

jsonschema.exceptions.ValidationError: 39.948314 is not a multiple of 1e-06

@djdevin
Copy link
Author

djdevin commented Oct 23, 2018

I had to change the import to

from jsonschema import validators, Draft4Validator, FormatChecker
from decimal import Decimal

I have no experience with python (3 in this case) but it seems to work and it's importing data now.

djdevin added a commit to djdevin/target-postgres that referenced this issue Oct 23, 2018
@koszti
Copy link

koszti commented Oct 23, 2018

thanks @djdevin the imports were not correct as you detailed. I added this into the original PR #11 . Hopefully somebody will get it merged soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants