9
votes

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.

1
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 faliedabhishek jha

1 Answers

14
votes

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;