Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cast Integer type to float in BigQuery Standard Sql

In BigQuery Legacy Sql, we can cast Integer column to float type using float() function.

What is its equivalent in BigQuery Standard Sql? I have tried these commands:

I have tried these commands:

SELECT float( author.time_sec ) FROM bigquery-public-data.github_repos.commits LIMIT 1000

SELECT cast( author.time_sec as float) FROM bigquery-public-data.github_repos.commits LIMIT 1000

Both of them failed.

like image 854
abhishek jha Avatar asked Aug 15 '16 09:08

abhishek jha


People also ask

What is INT64 in BigQuery?

BigQuery Data Types: NUMERIC Integer(INT 64): Represents numbers within the range of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and numbers that do not have fractional components. Float (Float 64): Numbers with approximate numeric values and fractional components.


1 Answers

Standard SQL supports the CAST function with the FLOAT64 data type, e.g.:

SELECT CAST(author.time_sec as FLOAT64)
FROM `bigquery-public-data.github_repos.commits`
LIMIT 1000;
like image 59
Elliott Brossard Avatar answered Oct 19 '22 13:10

Elliott Brossard