Can we cast the type in BigQuery?

前端 未结 2 1044
天涯浪人
天涯浪人 2020-12-10 10:38

Following my query :

SELECT SQRT((D_o_latitude - T_s_lat)^2+(D_o_longitude - T_s_long)^2)/0.00001 FROM [datasetName.tableName]

相关标签:
2条回答
  • 2020-12-10 11:16

    Under legacy SQL, you can cast types in BigQuery using the following functions: INTEGER(), STRING(), BOOLEAN() TIMESTAMP(), and FLOAT().

    Use cast() for standard SQL (see opensourcegeek's answer).

    In your case, you could write:

    SELECT SQRT((INTEGER(D_o_latitude) - T_s_lat)^2+(INTEGER(D_o_longitude) - T_s_long)^2)/0.00001 
    FROM [datasetName.tableName]
    
    0 讨论(0)
  • 2020-12-10 11:41

    With standard SQL you can use CAST function, eg. cast(numStringColumn as int64). Look out for standard SQL type names, as they aren't exactly same as legacy SQL.

    0 讨论(0)
提交回复
热议问题