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;
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.