forked from docs/doc-exports
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>
50 lines
5.9 KiB
HTML
50 lines
5.9 KiB
HTML
<a name="dli_spark_length"></a><a name="dli_spark_length"></a>
|
|
|
|
<h1 class="topictitle1">length</h1>
|
|
<div id="body8662426"><p id="dli_spark_length__en-us_topic_0000001696338809_p158837516483">This function is used to return the length of a string.</p>
|
|
<p id="dli_spark_length__en-us_topic_0000001696338809_p12471148153910">Similar function: <a href="dli_spark_lengthb.html#dli_spark_lengthb">lengthb</a>. The <strong id="dli_spark_length__en-us_topic_0000001696338809_b2339163741117">lengthb</strong> function is used to return the length of string <strong id="dli_spark_length__en-us_topic_0000001696338809_b13364194614119">str</strong> in bytes and return a value of the STRING type.</p>
|
|
<div class="section" id="dli_spark_length__en-us_topic_0000001696338809_section45291954203217"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="dli_spark_length__en-us_topic_0000001696338809_screen10637184423619">length(string <str>)</pre>
|
|
</div>
|
|
<div class="section" id="dli_spark_length__en-us_topic_0000001696338809_section992014913317"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_spark_length__en-us_topic_0000001696338809_table1829154762513" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter</caption><thead align="left"><tr id="dli_spark_length__en-us_topic_0000001696338809_row8830104792517"><th align="left" class="cellrowborder" valign="top" width="19.220000000000002%" id="mcps1.3.4.2.2.5.1.1"><p id="dli_spark_length__en-us_topic_0000001696338809_p983074711252">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="13.420000000000002%" id="mcps1.3.4.2.2.5.1.2"><p id="dli_spark_length__en-us_topic_0000001696338809_p6830124732517">Mandatory</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="15.590000000000002%" id="mcps1.3.4.2.2.5.1.3"><p id="dli_spark_length__en-us_topic_0000001696338809_p13318164512614">Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="51.77%" id="mcps1.3.4.2.2.5.1.4"><p id="dli_spark_length__en-us_topic_0000001696338809_p08301547132513">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_spark_length__en-us_topic_0000001696338809_row138881330152418"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.4.2.2.5.1.1 "><p id="dli_spark_length__en-us_topic_0000001696338809_p16689132714493">str</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.420000000000002%" headers="mcps1.3.4.2.2.5.1.2 "><p id="dli_spark_length__en-us_topic_0000001696338809_p1937912389241">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.590000000000002%" headers="mcps1.3.4.2.2.5.1.3 "><p id="dli_spark_length__en-us_topic_0000001696338809_p183791038192411">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.77%" headers="mcps1.3.4.2.2.5.1.4 "><p id="dli_spark_length__en-us_topic_0000001696338809_p99134255019">Target string to be searched for</p>
|
|
<p id="dli_spark_length__en-us_topic_0000001696338809_p19379638122412">If the value is of the BIGINT, DOUBLE, DECIMAL, or DATETIME type, the value is implicitly converted to the STRING type for calculation. For other types of values, an error is reported.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_spark_length__en-us_topic_0000001696338809_section210162513312"><h4 class="sectiontitle">Return Values</h4><p id="dli_spark_length__en-us_topic_0000001696338809_p42871014516">The return value is of the BIGINT type.</p>
|
|
<div class="note" id="dli_spark_length__en-us_topic_0000001696338809_note61422099395"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="dli_spark_length__en-us_topic_0000001696338809_ul17575154913546"><li id="dli_spark_length__en-us_topic_0000001696338809_li957510499542">If the value of <strong id="dli_spark_length__en-us_topic_0000001696338809_b7188835343449">str</strong> is not of the STRING, BIGINT, DOUBLE, DECIMAL, or DATETIME type, an error is reported.</li><li id="dli_spark_length__en-us_topic_0000001696338809_li1957594919543">If the value of <strong id="dli_spark_length__en-us_topic_0000001696338809_b126924132243458">str</strong> is <strong id="dli_spark_length__en-us_topic_0000001696338809_b212072295043458">NULL</strong>, <strong id="dli_spark_length__en-us_topic_0000001696338809_b73890132943458">NULL</strong> is returned.</li></ul>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="dli_spark_length__en-us_topic_0000001696338809_section13277192233920"><h4 class="sectiontitle">Example Code</h4><ul id="dli_spark_length__en-us_topic_0000001696338809_ul15711310105517"><li id="dli_spark_length__en-us_topic_0000001696338809_li5571310145519">Calculate the length of string abc. An example command is as follows:<p id="dli_spark_length__en-us_topic_0000001696338809_p935316171587"><a name="dli_spark_length__en-us_topic_0000001696338809_li5571310145519"></a><a name="en-us_topic_0000001696338809_li5571310145519"></a>The value <strong id="dli_spark_length__en-us_topic_0000001696338809_b657029294104041">3</strong> is returned.</p>
|
|
<pre class="screen" id="dli_spark_length__en-us_topic_0000001696338809_screen15361123586">select length('abc');</pre>
|
|
</li><li id="dli_spark_length__en-us_topic_0000001696338809_li185713109551">The value of the input parameter is <strong id="dli_spark_length__en-us_topic_0000001696338809_b103401403143624">NULL</strong>. An example command is as follows:<p id="dli_spark_length__en-us_topic_0000001696338809_p62811729588">The value <strong id="dli_spark_length__en-us_topic_0000001696338809_b3231738175019">NULL</strong> is returned.</p>
|
|
<pre class="screen" id="dli_spark_length__en-us_topic_0000001696338809_screen187174341283">select length(null);</pre>
|
|
</li></ul>
|
|
</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>
|
|
|