doc-exports/docs/dli/sqlreference/dli_spark_reverse.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
4.8 KiB
HTML

<a name="dli_spark_reverse"></a><a name="dli_spark_reverse"></a>
<h1 class="topictitle1">reverse</h1>
<div id="body8662426"><p id="dli_spark_reverse__en-us_topic_0000001647939914_p011317973211">This function is used to return a string in reverse order.</p>
<div class="section" id="dli_spark_reverse__en-us_topic_0000001647939914_section45291954203217"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="dli_spark_reverse__en-us_topic_0000001647939914_screen10637184423619">reverse(string &lt;str&gt;)</pre>
</div>
<div class="section" id="dli_spark_reverse__en-us_topic_0000001647939914_section992014913317"><h4 class="sectiontitle">Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_spark_reverse__en-us_topic_0000001647939914_table1829154762513" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter</caption><thead align="left"><tr id="dli_spark_reverse__en-us_topic_0000001647939914_row8830104792517"><th align="left" class="cellrowborder" valign="top" width="19.220000000000002%" id="mcps1.3.3.2.2.5.1.1"><p id="dli_spark_reverse__en-us_topic_0000001647939914_p983074711252">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="13.420000000000002%" id="mcps1.3.3.2.2.5.1.2"><p id="dli_spark_reverse__en-us_topic_0000001647939914_p6830124732517">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.590000000000002%" id="mcps1.3.3.2.2.5.1.3"><p id="dli_spark_reverse__en-us_topic_0000001647939914_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_reverse__en-us_topic_0000001647939914_p08301547132513">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_spark_reverse__en-us_topic_0000001647939914_row199266231004"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_reverse__en-us_topic_0000001647939914_p1084712712254">str</p>
</td>
<td class="cellrowborder" valign="top" width="13.420000000000002%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_spark_reverse__en-us_topic_0000001647939914_p1937912389241">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="15.590000000000002%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_spark_reverse__en-us_topic_0000001647939914_p183791038192411">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="51.77%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_spark_reverse__en-us_topic_0000001647939914_p99134255019">If the value is of the BIGINT, DOUBLE, DECIMAL, or DATETIME type, the value is implicitly converted to the STRING type for calculation.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_spark_reverse__en-us_topic_0000001647939914_section210162513312"><h4 class="sectiontitle">Return Values</h4><p id="dli_spark_reverse__en-us_topic_0000001647939914_p45601107915">The return value is of the STRING type.</p>
<div class="note" id="dli_spark_reverse__en-us_topic_0000001647939914_note61422099395"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="dli_spark_reverse__en-us_topic_0000001647939914_ul1378265112713"><li id="dli_spark_reverse__en-us_topic_0000001647939914_li1398314342912">If the value of <strong id="dli_spark_reverse__en-us_topic_0000001647939914_b143645326443452">str</strong> is not of the STRING, BIGINT, DOUBLE, DECIMAL, or DATETIME type, an error is reported.</li><li id="dli_spark_reverse__en-us_topic_0000001647939914_li89848343920">If the value of <strong id="dli_spark_reverse__en-us_topic_0000001647939914_b1277478743459">str</strong> is <strong id="dli_spark_reverse__en-us_topic_0000001647939914_b173087375543459">NULL</strong>, <strong id="dli_spark_reverse__en-us_topic_0000001647939914_b123328939443459">NULL</strong> is returned.</li></ul>
</div></div>
</div>
<div class="section" id="dli_spark_reverse__en-us_topic_0000001647939914_section13277192233920"><h4 class="sectiontitle">Example Code</h4><p id="dli_spark_reverse__en-us_topic_0000001647939914_p8786534248">The value <strong id="dli_spark_reverse__en-us_topic_0000001647939914_b183195578593">LQS krapS</strong> is returned.</p>
<pre class="screen" id="dli_spark_reverse__en-us_topic_0000001647939914_screen1831191248">SELECT reverse('Spark SQL'); </pre>
<p id="dli_spark_reverse__en-us_topic_0000001647939914_p3786133142413">The value <strong id="dli_spark_reverse__en-us_topic_0000001647939914_b6697241505">[3,4,1,2]</strong> is returned.</p>
<pre class="screen" id="dli_spark_reverse__en-us_topic_0000001647939914_screen68161772413">SELECT reverse(array(2, 1, 4, 3)); </pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0472.html">String Functions</a></div>
</div>
</div>