【问题标题】:Cast Integer type to float in BigQuery Standard Sql将整数类型转换为在 BigQuery 标准 Sql 中浮动
【发布时间】:2016-12-21 12:05:49
【问题描述】:

在 BigQuery Legacy Sql 中,我们可以使用 float() 函数将 Integer 列转换为 float 类型。

BigQuery 标准 Sql 中的等价物是什么? 我试过这些命令:

我已经尝试过这些命令:

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

他们都失败了。

【问题讨论】:

  • 到目前为止您尝试过什么? cloud.google.com/bigquery/sql-reference/…
  • 我试过这些命令: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 他们都失败了

标签: google-bigquery


【解决方案1】:

标准 SQL 支持 CAST 函数和 FLOAT64 data type,例如:

SELECT CAST(author.time_sec as FLOAT64)
FROM `bigquery-public-data.github_repos.commits`
LIMIT 1000;

【讨论】:

  • 感谢您的提问,顺便说一句!尝试标准 SQL 的其他用户可能正在寻找类似的信息,因此问题和答案也会对他们有所帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-11
  • 1970-01-01
  • 2018-08-27
相关资源
最近更新 更多