Hello! :wave: I'm using `target-postgres` with the...
# singer-targets
m
Hello! 👋 I'm using
target-postgres
with the following schema definition (shortened):
Copy code
{"type":"SCHEMA","stream":"data_platform_raw-tbii_daily_gmv_nmv","schema":{"properties":{"platform":{"type":["string","null"]},"at_brand_id":{"type":["integer","null"]} ...
The field
at_brand_id
gets created in Postgres with type bigint (i.e int(8)). How can I make
target-postgres
create it as a standard integer (i.e. int(4)) ?
e
Hi @Massimiliano Marcon! It's not currently supported. It can be done by updating this line: https://github.com/MeltanoLabs/target-postgres/blob/edbfad723b6f67d3da0ef2849760304e4876c41e/target_postgres/connector.py#L263 to use a function that checks for certain JSON schema metadata to decide what type of int column to return. I'll log an issue in the GH repo later, unless you beat me to it.
🙌 1
m
Hi @Edgar Ramírez (Arch.dev) and thank you for the very clear answer!
e
Let me know if the approach makes sense, specially given the suggestion I added to the readme of how to use Meltano to hint the target at a specific integer type.
m
Oh man I had completely overlooked the section in the README, which answers precisely the question I asked here. Sorry about that! Thank you for the PR. I added a couple of comments there
🙏 1
v
The thing we should probably add to the readme is the reason most datatypes aren't supported and we haven't pushed to really do that is because the general premise with ELT is to get the data into the database and do the mapping stuff at your transform step, so using a tool like DBT to map those fields to the type you actually need them to be is doable later and it keeps the target a bit simpler and less finicky
So the priority is to get as much data as possible to "just work" and load into postgres even if the data typing isn't perfect