[ 
https://issues.apache.org/jira/browse/PHOENIX-1516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14246220#comment-14246220
 ] 

James Taylor commented on PHOENIX-1516:
---------------------------------------

If each call to RAND generates a new number, then you can't select the RAND 
that's use in the WHERE clause in a single statement. For example, this 
wouldn't be possible (which may be fine, but I just wanted to point it out):
{code}
SELECT RAND() FROM T WHERE RAND()<0.1
{code}
If we generate a new random number with each call, then we need to add a new 
Determinism enum (PER_INVOCATION), and make sure that the existing logic that's 
in place will work for this (it may just be fine, but we'll need some new tests 
around this).

The seed could be an expression. I think the following implementation would 
work:
- the RAND function would have Determinism.ALWAYS if the seed is a constant, 
otherwise
- the Determinism would be PER_INVOCATION and the evaluate method would just 
call the random function for every evaluate call.


> Add RANDOM built-in function
> ----------------------------
>
>                 Key: PHOENIX-1516
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1516
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Lars Hofhansl
>            Assignee: Lars Hofhansl
>         Attachments: 1516.txt
>
>
> I often find it useful to generate some rows with random data.
> Here's a simple RANDOM() function that we could use for that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to