Mark McGown
Mark McGown

Reputation: 1095

Bad int value BigQuery

I have the following column of strings like:

1635188264984-384-2141356

And I'd like it as an integer type

16351882649843842141356

But when I use the following query:

cast(REPLACE(my_table.my_column,'-','') as int)

I get the following error in BigQuery:

Bad int64 value: 16351882649843842141356

What am I doing wrong and how can I accomplish converting string such as this to integers?

Upvotes: 2

Views: 7442

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172954

Range for INT is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (see more at https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#integer_type)

So, use NUMERIC instead as in below example

cast(REPLACE(my_table.my_column,'-','') as numeric)

Upvotes: 3

Related Questions