doc-exports/docs/dli/sqlreference/dli_spark_rand.html
Su, Xiaomeng 76a5b1ee83 dli_sqlreference_20240227
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2024-03-27 22:02:33 +00:00

47 lines
3.9 KiB
HTML

<a name="dli_spark_rand"></a><a name="dli_spark_rand"></a>
<h1 class="topictitle1">rand</h1>
<div id="body8662426"><p id="dli_spark_rand__en-us_topic_0000001696282285_p18471163815215">This function is used to return an evenly distributed random number that is greater than or equal to 0 and less than 1.</p>
<div class="section" id="dli_spark_rand__en-us_topic_0000001696282285_section45291954203217"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="dli_spark_rand__en-us_topic_0000001696282285_screen19928459112517">rand(INT seed)</pre>
</div>
<div class="section" id="dli_spark_rand__en-us_topic_0000001696282285_section992014913317"><h4 class="sectiontitle">Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_spark_rand__en-us_topic_0000001696282285_table1829154762513" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter</caption><thead align="left"><tr id="dli_spark_rand__en-us_topic_0000001696282285_row8830104792517"><th align="left" class="cellrowborder" valign="top" width="19.220000000000002%" id="mcps1.3.3.2.2.5.1.1"><p id="dli_spark_rand__en-us_topic_0000001696282285_p983074711252">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="13.44%" id="mcps1.3.3.2.2.5.1.2"><p id="dli_spark_rand__en-us_topic_0000001696282285_p6830124732517">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.57%" id="mcps1.3.3.2.2.5.1.3"><p id="dli_spark_rand__en-us_topic_0000001696282285_p13318164512614">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="51.77%" id="mcps1.3.3.2.2.5.1.4"><p id="dli_spark_rand__en-us_topic_0000001696282285_p08301547132513">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_spark_rand__en-us_topic_0000001696282285_row15830184792511"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_rand__en-us_topic_0000001696282285_p683034714250">seed</p>
</td>
<td class="cellrowborder" valign="top" width="13.44%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_spark_rand__en-us_topic_0000001696282285_p12830184752518">No</p>
</td>
<td class="cellrowborder" valign="top" width="15.57%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_spark_rand__en-us_topic_0000001696282285_p4646848132813">INT</p>
</td>
<td class="cellrowborder" valign="top" width="51.77%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_spark_rand__en-us_topic_0000001696282285_p146631651162915">The value can be a float, integer, or string.</p>
<p id="dli_spark_rand__en-us_topic_0000001696282285_p18653154615263">If this parameter is specified, a stable random number sequence is obtained within the same running environment.</p>
<p id="dli_spark_rand__en-us_topic_0000001696282285_p9484232112711"></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_spark_rand__en-us_topic_0000001696282285_section210162513312"><h4 class="sectiontitle">Return Values</h4><p id="dli_spark_rand__en-us_topic_0000001696282285_p184124317231">The return value is of the DOUBLE type.</p>
</div>
<div class="section" id="dli_spark_rand__en-us_topic_0000001696282285_section13277192233920"><h4 class="sectiontitle">Example Code</h4><p id="dli_spark_rand__en-us_topic_0000001696282285_p11579125491914">The value <strong id="dli_spark_rand__en-us_topic_0000001696282285_b167321936103711">0.3668915240363728</strong> is returned.</p>
<pre class="screen" id="dli_spark_rand__en-us_topic_0000001696282285_screen171991114208">select rand();</pre>
<p id="dli_spark_rand__en-us_topic_0000001696282285_p1356217569194">The value <strong id="dli_spark_rand__en-us_topic_0000001696282285_b133901848153720">0.25738143505962285</strong> is returned.</p>
<pre class="screen" id="dli_spark_rand__en-us_topic_0000001696282285_screen1743541715201">select rand(3);</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0473.html">Mathematical Functions</a></div>
</div>
</div>