Convert unsigned int to signed int through google BigQuery

只愿长相守 提交于 2019-12-23 23:05:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!