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

psycopg2.IntegrityError: null value in column "uid" violates not-null constraint #7

Open
djdevin opened this issue Oct 9, 2018 · 6 comments · May be fixed by #15
Open

psycopg2.IntegrityError: null value in column "uid" violates not-null constraint #7

djdevin opened this issue Oct 9, 2018 · 6 comments · May be fixed by #15

Comments

@djdevin
Copy link

djdevin commented Oct 9, 2018

Strange issue where an integer 0 is being converted to a NULL and breaking the copy as the resulting table does not allow nulls.

The row in question here has an int(11) 0 in the uid column.

If I just delete the row with the 0, it will copy fine.

Coming from tap-mysql it looks like it is providing the correct value for the row:

{
  "type": "RECORD",
  "stream": "user",
  "record": {
    "name": "",
    "mail": "",
    "access": "1970-01-01T00:00:00+00:00",
    "uid": 0,
    "field_participant_category_value": null,
    "roles": null,
    "login": "1970-01-01T00:00:00+00:00",
    "theme": "",
    "created": "1970-01-01T00:00:00+00:00",
    "status": 0,
    "uuid": "dde83629-ca10-42d6-b376-e4c26009c384"
  },
  "version": 1539107389565,
  "time_extracted": "2018-10-09T17:49:49.591099Z"
}
INFO COPY user_temp ("access", "created", "field_participant_category_value", "login", "mail", "name", "roles", "status", "theme", "uid", "uuid") FROM STDIN WITH (FORMAT CSV, ESCAPE '\')
Traceback (most recent call last):
  File "/usr/bin/target-postgres", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/target_postgres/__init__.py", line 138, in main
    state = persist_lines(config, input)
  File "/usr/lib/python3.6/site-packages/target_postgres/__init__.py", line 113, in persist_lines
    stream_to_sync[stream_name].load_csv(csv_files_to_load[stream_name], count)
  File "/usr/lib/python3.6/site-packages/target_postgres/db_sync.py", line 172, in load_csv
    file
psycopg2.IntegrityError: null value in column "uid" violates not-null constraint
DETAIL:  Failing row contains (1970-01-01 00:00:00, 1970-01-01 00:00:00, null, 1970-01-01 00:00:00, null, null, null, null, null, null, dde83629-ca10-42d6-b376-e4c26009c384).
CONTEXT:  COPY user_temp, line 1: ""1970-01-01T00:00:00+00:00","1970-01-01T00:00:00+00:00",,"1970-01-01T00:00:00+00:00",,,,,,,"dde83629..."
@koszti
Copy link

koszti commented Oct 14, 2018

try it with PR #9 . Interesting that we find the same issues independently :)

@djdevin
Copy link
Author

djdevin commented Oct 22, 2018

I confirmed this fixes the issue, thanks!

@robmoore
Copy link

I'm running into this same issue. Any chance this could be merged in?

@ifokeev
Copy link

ifokeev commented Apr 11, 2019

@robmoore try this, maybe it will for you https://github.com/datamill-co/target-redshift

@djdevin
Copy link
Author

djdevin commented May 1, 2019

That project doesn't support STATE which is a no-go for us. No way we could possibly do full table reloads.

@robmoore I made a fork with this and #6 that seems to be working well for us

pip install git+https://github.com/djdevin/target-postgres.git

@robmoore
Copy link

robmoore commented May 2, 2019

@djdevin You might want to take a look at the 'other' version of target-postgres: https://github.com/datamill-co/target-postgres

I've been using it and found it handles things like null values better. Also, it seems to be more actively developed.

@djdevin djdevin linked a pull request Mar 30, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

4 participants