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

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

Thanks for the patch, [~lhofhansl]. Looks like some RDBMS use RAND as the 
function name and allow an optional integer seed argument: 
http://msdn.microsoft.com/en-us/library/ms177610.aspx while others like 
Postgres use RANDOM and have a separate way to set the seed: 
http://www.techonthenet.com/postgresql/functions/random.php while Oracle has a 
dbms_random.random that can be used... Sigh... That's not much help. :-(

I do think It's important that we follow the SQL standards as this is what our 
users expect, though. If it's not specified, then IMHO we should follow what 
other databases do. [~julianhyde] - do you know off the top of your head how 
RAND built-in *should* work? In particular, what would this return?
{code}
SELECT RAND() A, RAND() B FROM T LIMIT 2;
{code}
IMO, the same expression should return the same value when used multiple times 
in the same statement. Otherwise, we couldn't do any common expression 
factoring.

FWIW, I found this interesting blog: 
http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-set-based-random-numbers/.
 So it looks like SQL Server doesn't even vary the random number for different 
rows.

IMO, we should use RAND( [ seed] ) and have it evaluate once per row.


> 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