Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
822 views
in Technique[技术] by (71.8m points)

bigquery udf - Google Big Query: How to alter data type from string to float?

I have the following query and I would like to change the data type for the field "Reach" from string to Float.

The query that I am working on is the following:

SELECT 
  Account,
  Campaign_name,
   Date,
  Impressions,
  Cost__GBP_,
  Link_clicks,
  Ad_set_name,
  Ad_name,
  Reach,   
  Website_conversions   
From 'TableA'

And I am receiving the following Issue: (google big query Could not convert the value to float. Row 8; Col 8)

I have tried to use to amend the query by doing : CAST (Reach AS Float64) As Reach , but it is not working.

Someone can help me with this?

Thank you

question from:https://stackoverflow.com/questions/66051121/google-big-query-how-to-alter-data-type-from-string-to-float

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
SELECT Account, Campaign_name, Date, Impressions, Cost__GBP_, Link_clicks, Ad_set_name, Ad_name, 
  SAFE_CAST(Reach AS FLOAT64) AS Reach, Website_conversions
From TableA

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...