You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by ma...@brother.co.jp on 2015/12/15 08:10:54 UTC

rand() is not random by row

Hi,

I found that rand() function does not reply random value.
When I used it, all rows are same values through all rows.

You can see this result with bellow query:
  select *, rand() from sys.boot limit 10


ver: 1.3.0
client: Web( drillhost:8047 )
environment: distributed on EMR

Thanks.

-- 
Miura, Masahide


RE: rand() is not random by row

Posted by ma...@brother.co.jp.
Hello, Jason

Thank you for your explanation.
I see how rand function goes.

> Drill comes with it's own native random() function that does what you want.
I didn't know it!
This is what I want, as you told.
Thank you so much.

-- 
Miura, Masahide


Re: rand() is not random by row

Posted by Jason Altekruse <al...@gmail.com>.
Hello, welcome to the Drill community!

The rand function is actually being pulled in from Hive, we need to fix how
we are evaluating it. As it doesn't take parameters, we are likely trying
to optimize by evaluating it just once and copying the result for the
entire current batch of records. We need to probe the Hive metadata to see
when this optimization is not appropriate (when the function is
non-deterministic).

Drill comes with it's own native random() function that does what you want.


On Mon, Dec 14, 2015 at 11:10 PM, <ma...@brother.co.jp> wrote:

> Hi,
>
> I found that rand() function does not reply random value.
> When I used it, all rows are same values through all rows.
>
> You can see this result with bellow query:
>   select *, rand() from sys.boot limit 10
>
>
> ver: 1.3.0
> client: Web( drillhost:8047 )
> environment: distributed on EMR
>
> Thanks.
>
> --
> Miura, Masahide
>
>