Reputation: 9
I want to execute MERGE query in BigQuery tables which contain numeric column.When I used below query to execute I am getting error as Query error: Value of type FLOAT64 cannot be assigned to Numeric
, which has type NUMERIC.
In my case, Its not possible to recognize datatype of number fields otherwise I can cast as per datatype of column.
Query =
MERGE Target T USING
(SELECT * FROM (SELECT 874 as ID,1012.0 as numericVal) S ON T.numericVal= S .numericVal WHEN MATCHED THEN UPDATE SET ID= S .ID,numericVal = S .numericVal
WHEN NOT MATCHED THEN INSERT ROW;
Upvotes: 0
Views: 297
Reputation: 3964
If you are not able to change the source, try casting as numeric and it'll be rounded accordingly
SELECT 874 as ID, CAST(1012.0 as NUMERIC) as numericVal
Upvotes: 1