laurent
02/19/2021, 11:25 PMtarget-postgres
(datamill-co variant): is the target schema expected to be empty? I tried using public
on a db which has pre-existing tables, and it failed because the description of some tables was not valid JSON (here https://github.com/datamill-co/target-postgres/blob/9c095d91e215f932caa897a6587c6dc6278db8cf/target_postgres/postgres.py#L223 json.loads
didn't like that it was fed text for humans)douwe_maan
02/19/2021, 11:26 PMlaurent
02/19/2021, 11:31 PMmeltano elt tap-csv target-postgres --job_id=xxxx
and it failed with the following stacktrace:
target-postgres | ERROR Exception writing records
target-postgres | Traceback (most recent call last):
target-postgres | File "/.../ays-elt/.meltano/loaders/target-postgres/venv/lib/python3.8/site-packages/target_postgres/postgres.py", line 236, in write_batch
target-postgres | self.setup_table_mapping_cache(cur)
target-postgres | File "/.../ays-elt/.meltano/loaders/target-postgres/venv/lib/python3.8/site-packages/target_postgres/postgres.py", line 223, in setup_table_mapping_cache
target-postgres | table_path = json.loads(raw_json).get('path', None)
target-postgres | File "/home/laurent/.pyenv/versions/3.8.7/lib/python3.8/json/__init__.py", line 357, in loads
target-postgres | return _default_decoder.decode(s)
target-postgres | File "/home/laurent/.pyenv/versions/3.8.7/lib/python3.8/json/decoder.py", line 337, in decode
target-postgres | obj, end = self.raw_decode(s, idx=_w(s, 0).end())
target-postgres | File "/home/laurent/.pyenv/versions/3.8.7/lib/python3.8/json/decoder.py", line 355, in raw_decode
target-postgres | raise JSONDecodeError("Expecting value", s, err.value) from None
target-postgres | json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
douwe_maan
02/19/2021, 11:32 PMraw_json
variable if it's not valid JSON?laurent
02/19/2021, 11:32 PMraw_json
is the description of an existing table, something like "the list of our clients"douwe_maan
02/19/2021, 11:32 PMobj_description(c.oid, 'pg_class')
in the query on line 214, so it's odd that Postgres would return anything for that function other than a JSON object descriptionlaurent
02/19/2021, 11:32 PMdouwe_maan
02/19/2021, 11:33 PMthe list of our clients
... Does that value look familiar to you?douwe_maan
02/19/2021, 11:33 PMlaurent
02/19/2021, 11:33 PMlaurent
02/19/2021, 11:33 PMlaurent
02/19/2021, 11:33 PMdouwe_maan
02/19/2021, 11:34 PMlaurent
02/19/2021, 11:35 PMCOMMENT ON TABLE public.employees IS 'the comment I mentioned above'
douwe_maan
02/19/2021, 11:35 PMdouwe_maan
02/19/2021, 11:35 PMdouwe_maan
02/19/2021, 11:35 PMdouwe_maan
02/19/2021, 11:36 PMpostgres_schema
at all, the default is actually to use a name derived from the tap you used: https://meltano.com/plugins/loaders/postgres.html#postgres-schemalaurent
02/19/2021, 11:36 PMdouwe_maan
02/19/2021, 11:36 PMlaurent
02/19/2021, 11:37 PMdouwe_maan
02/19/2021, 11:37 PMlaurent
02/19/2021, 11:37 PMlaurent
02/19/2021, 11:38 PMdouwe_maan
02/19/2021, 11:38 PMlaurent
02/19/2021, 11:38 PMlaurent
02/19/2021, 11:41 PMmeltano | Loading failed (1): target_postgres.exceptions.PostgresError: ('Exception writing records', InvalidSchemaName('schema "tap_csv" does not exist\nLINE 1: CREATE TABLE "tap_csv"."mytable" ();\n
douwe_maan
02/19/2021, 11:41 PMlaurent
02/19/2021, 11:43 PMbefore_run_sql
which could be used to create the schema, but it feels a little hackish. Maybe an option like autocreate_schema
(true/false) would make sense?douwe_maan
02/19/2021, 11:44 PMbefore_run_sql
sounds like a good option for now, but I think a dedicated option definitely wouldn't hurt. We'd probably set it to true
by default in Meltano. Wanna create an issue on https://github.com/datamill-co/target-postgres?laurent
02/19/2021, 11:46 PMdouwe_maan
02/19/2021, 11:46 PMlaurent
02/19/2021, 11:48 PMdouwe_maan
02/19/2021, 11:48 PMlaurent
02/20/2021, 12:07 AMdouwe_maan
02/20/2021, 12:08 AMlaurent
02/20/2021, 12:09 AMdouwe_maan
02/20/2021, 12:09 AMlaurent
02/20/2021, 12:09 AM