https://slingdata.io logo
I'm replicating a Postgres table that
# sling-help
s
I'm replicating a Postgres table that uses the somewhat rare
time
data type. Since I'm replicating to TimescaleDB which is also Postgres, in theory I should be able to retain the same data type but it gets converted to varchar in the destination table. This would be fine if it wasn't adding some random date ("0000-01-01") to the field. Is there a way to disable inference for a couple fields in the config YAML? Or does it have to be managed with custom SQL with an explicit cast to text for the time columns? I was hoping to avoid that since I use
SELECT *
to pick up all columns in case of changes to the source. Thanks in advance.
For example, in one source record I see 02:00:00 with data type
time
but in the destination table, the same record is "0000-01-01T02:00:00Z" with data type
character varying
. I know I can probably do some substring parsing to extract the time value but I was just wondering why Postgres to Postgres doesn't retain the native
time
type.
SELECT split_part(split_part(time_column, 'T', 2), 'Z', 1);
does seem to do the trick as a workaround.
f
Hey, yeah
time
is not currently handled by sling, see https://github.com/slingdata-io/sling-cli/blob/main/core/dbio/templates/types_general_to_native.tsv it looks like the golang postgres driver actually does receive it as a timestamp with year 0, month 1, day 1, which is interesting. It is on the roadmap to allow some flexibility in handling more "rare" native types. So you'll have to do some extra workaround for now.
s
Thanks for confirming, glad to see it's on the roadmap too