问题
I tried to run a query on google BigQuery api and got an exception as follows:
"Argument type mismatch in function IF: 'distinctPlayers' is type 'TYPE_UINT64', '0' is type 'TYPE_INT32'."
The query is too big so I wrote only part of it where it fails.
QUERY : sum(if(action_type == 3, distinctPlayers, 0)) as Game_Viral_Acceptor_Count
What I understood is:
if condition is true
then set distinctPlayers of type unsigned int64
otherwise set 0 which is of type int32
Can anyone throw some light on how to convert unsigned int64
to signed int
through BigQuery
.
Thanks in advance, Omkar
回答1:
To answer your question, the way you cast to signed int is via the INTEGER
function. So you should be able to successfully run
... SUM(IF(action_type == 3, INTEGER(distinctPlayers), 0)) AS ...
However, the message you're seeing actually points to a bug in BigQuery -- I'm filing the bug internally right now.
来源:https://stackoverflow.com/questions/11059778/convert-unsigned-int-to-signed-int-through-google-bigquery