Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

DataStream CloudSQL Postgres to BigQuery: Numeric synced as String

Seems to be happening with this specific data type, I have the following fields in my source.

Datastream->Objetcs->View Details:

jairoperezaquin_0-1732546055122.png

But BigQuery shows the column as strings, so I can't perform math operations

jairoperezaquin_1-1732546165397.png

Is there anything in the stream I should look into? Thanks!!

Solved Solved
0 2 201
1 ACCEPTED SOLUTION

Hi @jairoperezaquin,

Welcome to the Google Cloud Community!

This type of data discrepancy during streaming from Datastream to BigQuery can occur because of several reasons such as:

In our case, when PostgreSQL NUMERIC columns are set with undefined precision (indicated by a precision value of -1), Datastream maps them to BigQuery STRING columns. Refer to the data type conversion table under PostgreSQL NUMERIC for more details.

To resolve this, we can either change the arbitrary precision to a positive value, or use a data type other than NUMERIC. You can also consider mapping PostgreSQL data types to Datastream unified types instead to make them more generally supported if ever you decide to change data destinations or want to have multiple data destinations in the future.

I hope this helps!

View solution in original post

2 REPLIES 2

Hi @jairoperezaquin,

Welcome to the Google Cloud Community!

This type of data discrepancy during streaming from Datastream to BigQuery can occur because of several reasons such as:

In our case, when PostgreSQL NUMERIC columns are set with undefined precision (indicated by a precision value of -1), Datastream maps them to BigQuery STRING columns. Refer to the data type conversion table under PostgreSQL NUMERIC for more details.

To resolve this, we can either change the arbitrary precision to a positive value, or use a data type other than NUMERIC. You can also consider mapping PostgreSQL data types to Datastream unified types instead to make them more generally supported if ever you decide to change data destinations or want to have multiple data destinations in the future.

I hope this helps!

Thanks a lot!