Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cast float to string with no exponents in BigQuery

I have float data in a BigQuery table like 5302014.2 and 5102014.4.

I'd like to run a BigQuery SQL that returns the values in String format, but the following SQL yields this result:

select a, string(a) from my_table

5302014.2    "5.30201e+06"
5102014.4    "5.10201e+06"

How can I rewrite my SQL to return:

5302014.2    "5302014.2"
5102014.4    "5102014.4"
like image 373
j_c Avatar asked Aug 04 '14 16:08

j_c


Video Answer


1 Answers

use standardSQL doesn't have the problem

$ bq query '#standardSQL
SELECT a, CAST(a AS STRING) AS a_str FROM UNNEST(ARRAY[530201111114.2, 5302014.4]) a'
+-------------------+----------------+
|         a         |     a_str      |
+-------------------+----------------+
|         5302014.4 | 5302014.4      |
| 5.302011111142E11 | 530201111114.2 |
+-------------------+----------------+
like image 51
user5672998 Avatar answered Oct 12 '22 17:10

user5672998