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

Liang-Chi Hsieh commented on SPARK-27836:
-----------------------------------------

rand function initializes only once with given seed at beginning when running 
the task. Then it generates the random values.

> Issue with seeded rand() function in Spark SQL
> ----------------------------------------------
>
>                 Key: SPARK-27836
>                 URL: https://issues.apache.org/jira/browse/SPARK-27836
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.4.0
>            Reporter: Jason Ferrell
>            Priority: Major
>
> This SQL:
> with a as
> (
>  select 123 val1
>  union all
>  select 123 val1
>  union all
>  select 123 val1
> )
> select val1,rand(123)
> from a
> Results in:
> |val1|rand(123)|
> |123|0.502953|
> |123|0.52307|
> |123|0.853569|
>  
> It should result in three rows all with value 0.502953



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to