https://meltano.com/ logo
#announcements
Title
# announcements
t

thousands-library-17999

12/17/2020, 7:02 PM
I'm using tap-outbrain to send data to target-postgres. But when loading data to Postgres i get some NotNullViolation error. has anyone experienced this berfore?? I've tried to send the same data using Stitch and it creates the schema correctly and loads the data (same postgres server)
r

ripe-musician-59933

12/17/2020, 8:38 PM
@thousands-library-17999 Can you share some more details of the error, like the stacktrace and the specific SCHEMA or RECORD message that's causing the issue? If you enable debug mode (https://meltano.com/docs/command-line-interface.html#debugging), you should see each message output by the tap printed with a
tap-outbrain (out)
prefix. The one(s) printed just before the error are the likely culprits 🙂
t

thousands-library-17999

12/17/2020, 8:42 PM
Actually, the problem comes from target-postgres
r

ripe-musician-59933

12/17/2020, 8:42 PM
Right, but presumably it's caused by a specific message coming from the tap, that the target is failing to process
t

thousands-library-17999

12/17/2020, 8:43 PM
Copy code
target-postgres | ERROR Exception writing records
target-postgres | Traceback (most recent call last):
target-postgres | File "/home/ubuntu/meltano-projects/taboola2bigquery/.meltano/loaders/target-postgres/venv/lib/python3.8/site-packages/target_postgres/postgres.py", line 295, in write_batch
target-postgres | written_batches_details = self.write_batch_helper(cur,
target-postgres | File "/home/ubuntu/meltano-projects/taboola2bigquery/.meltano/loaders/target-postgres/venv/lib/python3.8/site-packages/target_postgres/sql_base.py", line 834, in write_batch_helper
target-postgres | batch_rows_persisted = self.write_table_batch(
target-postgres | File "/home/ubuntu/meltano-projects/taboola2bigquery/.meltano/loaders/target-postgres/venv/lib/python3.8/site-packages/target_postgres/postgres.py", line 609, in write_table_batch
target-postgres | self.persist_csv_rows(cur,
target-postgres | File "/home/ubuntu/meltano-projects/taboola2bigquery/.meltano/loaders/target-postgres/venv/lib/python3.8/site-packages/target_postgres/postgres.py", line 563, in persist_csv_rows
target-postgres | cur.copy_expert(copy, csv_rows)
target-postgres | psycopg2.errors.NotNullViolation: null value in column "campaignonair" violates not-null constraint
target-postgres | DETAIL: Failing row contains (00e5cac90872acdff6e41d66fc63cd4ed6, ES_BMG_BLOG_ART2, null, null, f, 006d1f4f4dc46dfd9b02934416355f6883, ES_BMG_BLOG_ART2, f, 30, EUR, null, null, 2020-04-22 09:46:01+00, 2020-05-06 11:48:20+00, 2020-04-22, 2021-05-31, f, DAILY, SPEND_ASAP, null, null, 0.1, 2020-12-17 00:13:32.7786+00, 1608165459, null, 2020-12-17 00:37:39.9168+00).
target-postgres | CONTEXT: COPY tmp_0c7ed48b_b33b_4ad1_8f70_80812500d2a8, line 1: "00e5cac90872acdff6e41d66fc63cd4ed6,ES_BMG_BLOG_ART2,NULL,NULL,False,006d1f4f4dc46dfd9b02934416355f68..."
target-postgres |
target-postgres | CRITICAL ('Exception writing records', NotNullViolation('null value in column "campaignonair" violates not-null constraint\nDETAIL: Failing row contains (00e5cac90872acdff6e41d66fc63cd4ed6, ES_BMG_BLOG_ART2, null, null, f, 006d1f4f4dc46dfd9b02934416355f6883, ES_BMG_BLOG_ART2, f, 30, EUR, null, null, 2020-04-22 09:46:01+00, 2020-05-06 11:48:20+00, 2020-04-22, 2021-05-31, f, DAILY, SPEND_ASAP, null, null, 0.1, 2020-12-17 00:13:32.7786+00, 1608165459, null, 2020-12-17 00:37:39.9168+00).\nCONTEXT: COPY tmp_0c7ed48b_b33b_4ad1_8f70_80812500d2a8, line 1: "00e5cac90872acdff6e41d66fc63cd4ed6,ES_BMG_BLOG_ART2,NULL,NULL,False,006d1f4f4dc46dfd9b02934416355f68..."\n'))
Sorry for the long copy
Tap-outbrain runs correctly, but i'll try enabling debug
r

ripe-musician-59933

12/17/2020, 8:44 PM
All right, it looks like the
campaignOnAir
column should hold a non-null boolean value: https://github.com/singer-io/tap-outbrain/blob/a111e43b64047219eacd70d8920f3d431c0b62b2/tap_outbrain/schemas.py#L98, but the target is receiving a record from the tap where it is null anyway
Since the target created the table/column not expecting nulls, it's raising NotNullViolation now that a null is trying to make its way into the table anyway
I'm trying this. But not sure if I'm doing this correctly
r

ripe-musician-59933

12/17/2020, 8:48 PM
Ah you fixed that already 😄 That looks right
Did you drop the table and let it be recreated after making those changes to make sure the new type is used?
Also, try using debug mode to confirm that the tap actually uses the correct types in its SCHEMA messages now
t

thousands-library-17999

12/17/2020, 8:51 PM
Not yet, i've forgot to merge on my master. I'm on it now
But i though Stitch where using the same tap version.
r

ripe-musician-59933

12/17/2020, 8:52 PM
It's possible that their own target for postgres assumes every column can be
null
anyway
They're using their own proprietary version, not one of the open source targets
So tap-outbrain may work as-is with theirs, but not with the open source version(s) of target-postgres that take the advertised type (and its lack of "null") literally
t

thousands-library-17999

12/17/2020, 8:54 PM
That makes sense
r

ripe-musician-59933

12/17/2020, 8:54 PM
Once you've updated the
pip_url
for
tap-outbrain
in your project, don't forget to reinstall it using
meltano install extractor tap-outbrain