CSV-File with dtypes specified being cast as TEXT in Postgres Destination

  • Is this your first time deploying Airbyte?: Yes
  • OS Version / Instance: Linux
  • Memory / Disk: 16GB
  • Deployment: Docker
  • Airbyte Version: What version are you using now? 0.40.22
  • Source name/version: -
  • Destination name/version: N/A
  • Step: Adding Source, Connection with File connector 0.2.31
  • Description:

I have a bunch of CSVs I’ve added as a Source for the File-Connector.
I’m specifying the dtypes in the “Reader Options” like this:

{"dtype": {"Open": "float64", "High": "float64", "Low": "float64", "Close": "float64", "Adj Close": "float64", "Volume": "int64"}}

However when I have a connection set-up with a Postgres destination all columns are CAST into texts.

It seems to be specific to Yahoo Finance (Example URL here) where I’m getting the data from. Other sources providing CSVs work correctly.

RAW-JSON from the File-Source looks like this:

 {"Low": 287.119995, "Date": "1987-03-09", "High": 290.660004, "Open": 290.660004, "Close": 288.299988, "Volume": 165400000, "Adj Close": 288.299988}

In the logs there is this:

i.a.w.g.DefaultReplicationWorker(lambda$readFromSrcAndWriteToDstRunnable$5):336 - Schema validation errors found for stream _YF_^GSPC_1D. Error messages: [$.Low is of an incorrect type. Expected it to be [string, null], $.Close is of an incorrect type. Expected it to be [string, null], $.Adj Close is of an incorrect type. Expected it to be [string, null], $.Volume is of an incorrect type. Expected it to be [string, null], $.High is of an incorrect type. Expected it to be [string, null], $.Open is of an incorrect type. Expected it to be [string, null]]

Any idea why this like this and how this can be changed?

Hello there! You are receiving this message because none of your fellow community members has stepped in to respond to your topic post. (If you are a community member and you are reading this response, feel free to jump in if you have the answer!) As a result, the Community Assistance Team has been made aware of this topic and will be investigating and responding as quickly as possible.
Some important considerations that will help your to get your issue solved faster:

  • It is best to use our topic creation template; if you haven’t yet, we recommend posting a followup with the requested information. With that information the team will be able to more quickly search for similar issues with connectors and the platform and troubleshoot more quickly your specific question or problem.
  • Make sure to upload the complete log file; a common investigation roadblock is that sometimes the error for the issue happens well before the problem is surfaced to the user, and so having the tail of the log is less useful than having the whole log to scan through.
  • Be as descriptive and specific as possible; when investigating it is extremely valuable to know what steps were taken to encounter the issue, what version of connector / platform / Java / Python / docker / k8s was used, etc. The more context supplied, the quicker the investigation can start on your topic and the faster we can drive towards an answer.
  • We in the Community Assistance Team are glad you’ve made yourself part of our community, and we’ll do our best to answer your questions and resolve the problems as quickly as possible. Expect to hear from a specific team member as soon as possible.

Thank you for your time and attention.
The Community Assistance Team

My suspicion is that it’s due to the long floats being recognized as object-types by read_csv. This is being converted to a string as it’s the default mapping-type of an object dtype. (also see here)

However adding {"float_precision": "round_trip"} to the source-config doesn’t solve the issue, so I guess it should be added when creating/validating the schema.

Can you check this issue on Github? https://github.com/airbytehq/airbyte/issues/19901 Probably is the same as yours.

Yes, it sounds indeed quite similar, although it’s about timestamps and not (long) floats. Do you think it makes sense to open another issue or is this one enough?

The issue is about data type in reader_options right?

I’m the one who entered the timestamp issue, and I don’t think I’d characterize it as an issue with reader_options per se. In my case, I’d expect Airbyte to recognize timestamps with or without the correct reader_options. I tried the reader_options possibilities as a possible work-around.

Also, TBC I’m using Airbyte on datasets I haven’t seen, so I will not be able to explicitly assign datatypes.

Well I’d appreciate not having to specify the data types either - it seems to be an issue that long floats with more than two decimal places are not being recognized correctly as floats but as strings. The specification of the data types was just a workardound (that didn’t work out).

So I agree - there seem to be some issues around recognizing the correct dtype (be it a timestamp or float) that’s the root cause in both cases.