Member since
09-01-2016
2
Posts
0
Kudos Received
0
Solutions
01-11-2017
12:51 PM
Thank you very much for your very quick and useful answer! Glad to know that it is a known bug. Anyway, I have been playing around, and made it work! For some reason it does work. Have no idea why though.. select
a+b+c+d segment
,min(r)
,max(r)
,count(ANYID) COUNTER
from (
select
ANYID
,r
,if(r >= 0.005,1,0) a
,if(r >= 0.0175,1,0) b
,if(r >= 0.08,1,0) c
,if(r >= 0.025,1,0) d
from (
select ANYID,RAND(unix_timestamp()) r from ANYTABLE
) foo
) bar
group by segment
order by segment
Do you have any idea why It does work? 🙂 Thanks Andras
... View more
01-11-2017
07:12 AM
Hi Everyone, I've come across a very strange behavior of impala. My aim is to generate random numbers for each rows, and then classified based on the probability to each segment. For some reason, the below query fails, and mixing up segments. select
case when random < 0.005 then 1
when random < 0.0175 and random >= 0.005 then 2
when random < 0.0175 and random >= 0.0175 then 3
when random < 0.2500 and random >= 0.0800 then 4
else 0 end segment,
min(random),max(random),
count(ANYID)
from (
select ANYID,RAND(unix_timestamp()) random from ANYTABLE limit 1000000) j
group by segment
Can anyone help me with any explanation? I simply can't get my head around. Thank you so much, Andras
... View more
Labels:
- Labels:
-
Apache Impala
-
Cloudera Hue