<#1831 bug: JSON serialization of `date` types cau...
# meltano-repo-activity
g
#1831 bug: JSON serialization of
date
types causes schema validation to fail in
target-postgres
Issue created by dluftspring Singer SDK Version 0.30.0 Meltano version 2.19.1 Is this a regression? • Yes Python Version 3.10 Bug scope Targets (data type handling, batching, SQL object generation, etc.) Operating System Linux, Mac OS Description When syncing data between
tap-snowflake
and
target-postgres
this line causes JSON schema validation to fail because the inferred json schema from Snowflake is a date but this coerces the type into a datetime. To summarize • Column is of type
date
in Snowflake • Target column is of type
date
in Postgres • Because of the type conformation code schema validation fails in the target because it is expecting
format: string type: date
and instead receives
format: string type: date-time
. Why is that extra timestamp string being added on? Additionally you can verify that this is a problem by syncing any snowflake date colum into target-jsonl and see that it is being serialized as a timestamp instead of a regular date even though json.dumps(datetime.date(<year>,<month>,<day>).isoformat()) produces perfectly valid JSON. There's probably a reason that little string is added where it is but it does cause some problems for Meltano. Code 2023-07-10T092522.412171Z [info ] jsonschema.exceptions.ValidationError: '2019-08-31T000000+00:00' is not a 'date' cmd_type=elb consumer=True name=target-postgres producer=False stdio=stderr string_id=target-postgres 2023-07-10T092522.412300Z [info ] cmd_type=elb consumer=True name=target-postgres producer=False stdio=stderr string_id=target-postgres 2023-07-10T092522.412421Z [info ] Failed validating 'format' in schema['properties']['expiration_date']: cmd_type=elb consumer=True name=target-postgres producer=False stdio=stderr string_id=target-postgres 2023-07-10T092522.412552Z [info ] {'format': 'date', 'type': ['string', 'null']} cmd_type=elb consumer=True name=target-postgres producer=False stdio=stderr string_id=target-postgres 2023-07-10T092522.412667Z [info ] cmd_type=elb consumer=True name=target-postgres producer=False stdio=stderr string_id=target-postgres 2023-07-10T092522.412781Z [info ] On instance['expiration_date']: cmd_type=elb consumer=True name=target-postgres producer=False stdio=stderr string_id=target-postgres 2023-07-10T092522.412895Z [info ] '2019-08-31T000000+00:00' cmd_type=elb consumer=True name=target-postgres producer=False stdio=stderr string_id=target-postgres 2023-07-10T092522.476401Z [error ] Loader failed 2023-07-10T092522.476859Z [error ] Block run completed. block_type=ExtractLoadBlocks err=RunnerError('Loader failed') exit_codes={<PluginType.LOADERS: 'loaders'>: 1} set_number=0 success=False meltano/sdk