FLOAT4 Values Contain Additional Decimal Places When Synced to BigQuery
Issue
When I sync values of the data type FLOAT4 from a PostgreSQL source to a BigQuery destination, the destination values contain more decimal places than the source values.
Environment
- Connector: PostgreSQL
- Destination: BigQuery
- Data type: FLOAT4
Resolution
To resolve this issue, choose any of the following options:
- In PostgreSQL, convert your data to type FLOAT8.
- In PostgreSQL, convert your data to a fixed-point numeric data type like NUMERIC or DECIMAL to ensure exact precision.
- Utilize transformations to round the values to a specified number of decimal places in your destination.
Cause
This issue occurs when you attempt to sync FLOAT4 data from a PostgreSQL source to a BigQuery destination.
The data type FLOAT4 is a single-precision floating-point number that BigQuery doesn't support. To ensure compatibility, we convert FLOAT4 values to the FLOAT64, a double-precision floating-point number. This increases the value's precision, allowing for more decimal places that may not have been visible in PostgreSQL.