2

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

Software Engineer
  • 3,906
  • 1
  • 26
  • 35
user1459963
  • 21
  • 1
  • 2

1 Answers1

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.

Craig Citro
  • 6,505
  • 1
  • 31
  • 28
  • 1
    It seems like the bug is still there, I had the same error today. I had to do this to make it work: INTEGER(count (distinct myField, 10000)) – YABADABADOU Apr 11 '14 at 17:29