Imad
Imad

Reputation: 2741

How to set the precision of a FLOAT in BigQuery schema

In BigQuery, if I want to round a FLOAT type field in a query I use the ROUND() function. Is it possible to set the precision in the schema or through some option/parameter?

Example :

A data file contains some FLOAT type fields that contain too many digits after the decimal point (18), I want to round it up during the upload process, by specifying some parameter or option within the schema.

[
 {"mode": "NULLABLE", "name": "BRAND", "type": "STRING", "description": null},
 {"mode": "NULLABLE", "name": "PRICE", "type": "FLOAT", "description": null [, "<precision>":"2"]}
]

Upvotes: 0

Views: 1711

Answers (1)

Chandra Mochahary
Chandra Mochahary

Reputation: 405

No data transformation can be performed when you upload data into BigQuery.

In general you can try some other methods :

Create a new table from uploaded table. For this you can create a query and can perform required transformation in it. eg: CREATE TABLE project_name.dataset_name.new_table_name as SELECT Brand, round(price,5) as Price from project_name.dataset_name.uploaded_table_name;

Creating a table from a query result. https://cloud.google.com/bigquery/docs/tables#creating_a_table_from_a_query_result

Upvotes: 1

Related Questions