blob: 2aeeb4ad99bfc5225e97ce9c25cc7069ca91d0c5 [file] [log] [blame]
Ian Maxon1befeb12021-07-16 12:40:15 -07001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from target/generated-site/markdown/sqlpp/builtins.md at 2021-07-16
4 | Rendered using Apache Maven Fluido Skin 1.7
5-->
6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <meta charset="UTF-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <meta name="Date-Revision-yyyymmdd" content="20210716" />
11 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB &#x2013; Builtin Functions</title>
13 <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
14 <link rel="stylesheet" href="../css/site.css" />
15 <link rel="stylesheet" href="../css/print.css" media="print" />
16 <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
17
18 </head>
19 <body class="topBarDisabled">
20 <div class="container-fluid">
21 <div id="banner">
22 <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
23 <div class="pull-right"></div>
24 <div class="clear"><hr/></div>
25 </div>
26
27 <div id="breadcrumbs">
28 <ul class="breadcrumb">
29 <li id="publishDate">Last Published: 2021-07-16</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.7</li>
31 <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
32 </ul>
33 </div>
34 <div class="row-fluid">
35 <div id="leftColumn" class="span2">
36 <div class="well sidebar-nav">
37 <ul class="nav nav-list">
38 <li class="nav-header">Get Started - Installation</li>
39 <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
40 <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
41 <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
42 <li class="nav-header">AsterixDB Primer</li>
43 <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
44 <li class="nav-header">Data Model</li>
45 <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
46 <li class="nav-header">Queries</li>
47 <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
48 <li><a href="../SQLPP.html" title="Raw SQL++ Grammar"><span class="none"></span>Raw SQL++ Grammar</a></li>
49 <li class="active"><a href="#"><span class="none"></span>Builtin Functions</a></li>
50 <li class="nav-header">API/SDK</li>
51 <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
52 <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
53 <li class="nav-header">Advanced Features</li>
54 <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
55 <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
56 <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
57 <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
58 <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
59 <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
60 <li><a href="../interval_join.html" title="Support of Interval Joins"><span class="none"></span>Support of Interval Joins</a></li>
61 <li><a href="../sqlpp/arrayindex.html" title="Support of Array Indexes"><span class="none"></span>Support of Array Indexes</a></li>
62 <li class="nav-header">Deprecated</li>
63 <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
64 <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
65 <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
66</ul>
67 <hr />
68 <div id="poweredBy">
69 <div class="clear"></div>
70 <div class="clear"></div>
71 <div class="clear"></div>
72 <div class="clear"></div>
73<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
74 </div>
75 </div>
76 </div>
77 <div id="bodyColumn" class="span10" >
78<!--
79 ! Licensed to the Apache Software Foundation (ASF) under one
80 ! or more contributor license agreements. See the NOTICE file
81 ! distributed with this work for additional information
82 ! regarding copyright ownership. The ASF licenses this file
83 ! to you under the Apache License, Version 2.0 (the
84 ! "License"); you may not use this file except in compliance
85 ! with the License. You may obtain a copy of the License at
86 !
87 ! http://www.apache.org/licenses/LICENSE-2.0
88 !
89 ! Unless required by applicable law or agreed to in writing,
90 ! software distributed under the License is distributed on an
91 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
92 ! KIND, either express or implied. See the License for the
93 ! specific language governing permissions and limitations
94 ! under the License.
95 !-->
96<h1>Builtin Functions</h1><!--
97 ! Licensed to the Apache Software Foundation (ASF) under one
98 ! or more contributor license agreements. See the NOTICE file
99 ! distributed with this work for additional information
100 ! regarding copyright ownership. The ASF licenses this file
101 ! to you under the Apache License, Version 2.0 (the
102 ! "License"); you may not use this file except in compliance
103 ! with the License. You may obtain a copy of the License at
104 !
105 ! http://www.apache.org/licenses/LICENSE-2.0
106 !
107 ! Unless required by applicable law or agreed to in writing,
108 ! software distributed under the License is distributed on an
109 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
110 ! KIND, either express or implied. See the License for the
111 ! specific language governing permissions and limitations
112 ! under the License.
113 !-->
114
115<div class="section">
116<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
117<ul>
118
119<li><a href="#NumericFunctions">Numeric Functions</a></li>
120<li><a href="#StringFunctions">String Functions</a></li>
121<li><a href="#BinaryFunctions">Binary Functions</a></li>
122<li><a href="#SpatialFunctions">Spatial Functions</a></li>
123<li><a href="#SimilarityFunctions">Similarity Functions</a></li>
124<li><a href="#TokenizingFunctions">Tokenizing Functions</a></li>
125<li><a href="#TemporalFunctions">Temporal Functions</a></li>
126<li><a href="#ObjectFunctions">Object Functions</a></li>
127<li><a href="#AggregateFunctions">Aggregate Functions (Array Functions)</a></li>
128<li><a href="#ComparisonFunctions">Comparison Functions</a></li>
129<li><a href="#TypeFunctions">Type Functions</a></li>
130<li><a href="#ConditionalFunctions">Conditional Functions</a></li>
131<li><a href="#MiscFunctions">Miscellaneous Functions</a></li>
132<li><a href="#BitwiseFunctions">Bitwise Functions</a></li>
133<li><a href="#WindowFunctions">Window Functions</a></li>
134</ul><!--
135 ! Licensed to the Apache Software Foundation (ASF) under one
136 ! or more contributor license agreements. See the NOTICE file
137 ! distributed with this work for additional information
138 ! regarding copyright ownership. The ASF licenses this file
139 ! to you under the Apache License, Version 2.0 (the
140 ! "License"); you may not use this file except in compliance
141 ! with the License. You may obtain a copy of the License at
142 !
143 ! http://www.apache.org/licenses/LICENSE-2.0
144 !
145 ! Unless required by applicable law or agreed to in writing,
146 ! software distributed under the License is distributed on an
147 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
148 ! KIND, either express or implied. See the License for the
149 ! specific language governing permissions and limitations
150 ! under the License.
151 !-->
152
153<p>The system provides various classes of functions to support operations on numeric, string, spatial, and temporal data. This document explains how to use these functions.</p><!--
154 ! Licensed to the Apache Software Foundation (ASF) under one
155 ! or more contributor license agreements. See the NOTICE file
156 ! distributed with this work for additional information
157 ! regarding copyright ownership. The ASF licenses this file
158 ! to you under the Apache License, Version 2.0 (the
159 ! "License"); you may not use this file except in compliance
160 ! with the License. You may obtain a copy of the License at
161 !
162 ! http://www.apache.org/licenses/LICENSE-2.0
163 !
164 ! Unless required by applicable law or agreed to in writing,
165 ! software distributed under the License is distributed on an
166 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
167 ! KIND, either express or implied. See the License for the
168 ! specific language governing permissions and limitations
169 ! under the License.
170 !-->
171</div>
172<div class="section">
173<h2><a name="Numeric_Functions"></a><a name="NumericFunctions" id="NumericFunctions">Numeric Functions</a></h2>
174<div class="section">
175<h3><a name="abs"></a>abs</h3>
176<ul>
177
178<li>
179
180<p>Syntax:</p>
181
182<div>
183<div>
184<pre class="source">abs(numeric_value)
185</pre></div></div>
186</li>
187<li>
188
189<p>Computes the absolute value of the argument.</p>
190</li>
191<li>Arguments:
192<ul>
193
194<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
195</ul>
196</li>
197<li>Return Value:
198<ul>
199
200<li>The absolute value of the argument with the same type as the input argument,</li>
201<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
202<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
203<li>any other non-numeric input value will cause a type error.</li>
204</ul>
205</li>
206<li>
207
208<p>Example:</p>
209
210<div>
211<div>
212<pre class="source">{ &quot;v1&quot;: abs(2013), &quot;v2&quot;: abs(-4036), &quot;v3&quot;: abs(0), &quot;v4&quot;: abs(float(&quot;-2013.5&quot;)), &quot;v5&quot;: abs(double(&quot;-2013.593823748327284&quot;)) };
213</pre></div></div>
214</li>
215<li>
216
217<p>The expected result is:</p>
218
219<div>
220<div>
221<pre class="source">{ &quot;v1&quot;: 2013, &quot;v2&quot;: 4036, &quot;v3&quot;: 0, &quot;v4&quot;: 2013.5, &quot;v5&quot;: 2013.5938237483274 }
222</pre></div></div>
223</li>
224</ul></div>
225<div class="section">
226<h3><a name="acos"></a>acos</h3>
227<ul>
228
229<li>
230
231<p>Syntax:</p>
232
233<div>
234<div>
235<pre class="source">acos(numeric_value)
236</pre></div></div>
237</li>
238<li>
239
240<p>Computes the arc cosine value of the argument.</p>
241</li>
242<li>Arguments:
243<ul>
244
245<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
246</ul>
247</li>
248<li>Return Value:
249<ul>
250
251<li>the <tt>double</tt> arc cosine in radians for the argument, if the argument is in the range of -1 (inclusive) to 1 (inclusive),</li>
252<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
253<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
254<li>any other non-numeric input value will cause a type error,</li>
255<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
256</ul>
257</li>
258<li>
259
260<p>Example:</p>
261
262<div>
263<div>
264<pre class="source">{ &quot;v1&quot;: acos(1), &quot;v2&quot;: acos(2), &quot;v3&quot;: acos(0), &quot;v4&quot;: acos(float(&quot;0.5&quot;)), &quot;v5&quot;: acos(double(&quot;-0.5&quot;)) };
265</pre></div></div>
266</li>
267<li>
268
269<p>The expected result is:</p>
270
271<div>
272<div>
273<pre class="source">{ &quot;v1&quot;: 0.0, &quot;v2&quot;: &quot;NaN&quot;, &quot;v3&quot;: 1.5707963267948966, &quot;v4&quot;: 1.0471975511965979, &quot;v5&quot;: 2.0943951023931957 }
274</pre></div></div>
275</li>
276</ul></div>
277<div class="section">
278<h3><a name="asin"></a>asin</h3>
279<ul>
280
281<li>
282
283<p>Syntax:</p>
284
285<div>
286<div>
287<pre class="source">asin(numeric_value)
288</pre></div></div>
289</li>
290<li>
291
292<p>Computes the arc sine value of the argument.</p>
293</li>
294<li>Arguments:
295<ul>
296
297<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
298</ul>
299</li>
300<li>Return Value:
301<ul>
302
303<li>the <tt>double</tt> arc sin in radians for the argument, if the argument is in the range of -1 (inclusive) to 1 (inclusive),</li>
304<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
305<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
306<li>any other non-numeric input value will cause a type error,</li>
307<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
308</ul>
309</li>
310<li>
311
312<p>Example:</p>
313
314<div>
315<div>
316<pre class="source">{ &quot;v1&quot;: asin(1), &quot;v2&quot;: asin(2), &quot;v3&quot;: asin(0), &quot;v4&quot;: asin(float(&quot;0.5&quot;)), &quot;v5&quot;: asin(double(&quot;-0.5&quot;)) };
317</pre></div></div>
318</li>
319<li>
320
321<p>The expected result is:</p>
322
323<div>
324<div>
325<pre class="source">{ &quot;v1&quot;: 1.5707963267948966, &quot;v2&quot;: &quot;NaN&quot;, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.5235987755982989, &quot;v5&quot;: -0.5235987755982989 }
326</pre></div></div>
327</li>
328</ul></div>
329<div class="section">
330<h3><a name="atan"></a>atan</h3>
331<ul>
332
333<li>
334
335<p>Syntax:</p>
336
337<div>
338<div>
339<pre class="source">atan(numeric_value)
340</pre></div></div>
341</li>
342<li>
343
344<p>Computes the arc tangent value of the argument.</p>
345</li>
346<li>Arguments:
347<ul>
348
349<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
350</ul>
351</li>
352<li>Return Value:
353<ul>
354
355<li>the <tt>double</tt> arc tangent in radians for the argument,</li>
356<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
357<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
358<li>any other non-numeric input value will cause a type error.</li>
359</ul>
360</li>
361<li>
362
363<p>Example:</p>
364
365<div>
366<div>
367<pre class="source">{ &quot;v1&quot;: atan(1), &quot;v2&quot;: atan(2), &quot;v3&quot;: atan(0), &quot;v4&quot;: atan(float(&quot;0.5&quot;)), &quot;v5&quot;: atan(double(&quot;1000&quot;)) };
368</pre></div></div>
369</li>
370<li>
371
372<p>The expected result is:</p>
373
374<div>
375<div>
376<pre class="source">{ &quot;v1&quot;: 0.7853981633974483, &quot;v2&quot;: 1.1071487177940904, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.4636476090008061, &quot;v5&quot;: 1.5697963271282298 }
377</pre></div></div>
378</li>
379</ul></div>
380<div class="section">
381<h3><a name="atan2"></a>atan2</h3>
382<ul>
383
384<li>
385
386<p>Syntax:</p>
387
388<div>
389<div>
390<pre class="source">atan2(numeric_value1, numeric_value2)
391</pre></div></div>
392</li>
393<li>
394
395<p>Computes the arc tangent value of numeric_value2/numeric_value1.</p>
396</li>
397<li>Arguments:
398<ul>
399
400<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
401<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
402</ul>
403</li>
404<li>Return Value:
405<ul>
406
407<li>the <tt>double</tt> arc tangent in radians for <tt>numeric_value1</tt> and <tt>numeric_value2</tt>,</li>
408<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
409<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
410<li>any other non-numeric input value will cause a type error.</li>
411</ul>
412</li>
413<li>
414
415<p>Example:</p>
416
417<div>
418<div>
419<pre class="source">{ &quot;v1&quot;: atan2(1, 2), &quot;v2&quot;: atan2(0, 4), &quot;v3&quot;: atan2(float(&quot;0.5&quot;), double(&quot;-0.5&quot;)) };
420</pre></div></div>
421</li>
422<li>
423
424<p>The expected result is:</p>
425
426<div>
427<div>
428<pre class="source">{ &quot;v1&quot;: 0.4636476090008061, &quot;v2&quot;: 0.0, &quot;v3&quot;: 2.356194490192345 }
429</pre></div></div>
430</li>
431</ul></div>
432<div class="section">
433<h3><a name="ceil"></a>ceil</h3>
434<ul>
435
436<li>
437
438<p>Syntax:</p>
439
440<div>
441<div>
442<pre class="source">ceil(numeric_value)
443</pre></div></div>
444</li>
445<li>
446
447<p>Computes the smallest (closest to negative infinity) number with no fractional part that is not less than the value of the argument. If the argument is already equal to mathematical integer, then the result is the same as the argument.</p>
448</li>
449<li>Arguments:
450<ul>
451
452<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
453</ul>
454</li>
455<li>Return Value:
456<ul>
457
458<li>The ceiling value for the given number in the same type as the input argument,</li>
459<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
460<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
461<li>any other non-numeric input value will cause a type error.</li>
462</ul>
463</li>
464<li>
465
466<p>Example:</p>
467
468<div>
469<div>
470<pre class="source">{
471 &quot;v1&quot;: ceil(2013),
472 &quot;v2&quot;: ceil(-4036),
473 &quot;v3&quot;: ceil(0.3),
474 &quot;v4&quot;: ceil(float(&quot;-2013.2&quot;)),
475 &quot;v5&quot;: ceil(double(&quot;-2013.893823748327284&quot;))
476};
477</pre></div></div>
478</li>
479<li>
480
481<p>The expected result is:</p>
482
483<div>
484<div>
485<pre class="source">{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2013.0 }
486</pre></div></div>
487</li>
488</ul></div>
489<div class="section">
490<h3><a name="cos"></a>cos</h3>
491<ul>
492
493<li>
494
495<p>Syntax:</p>
496
497<div>
498<div>
499<pre class="source">cos(numeric_value)
500</pre></div></div>
501</li>
502<li>
503
504<p>Computes the cosine value of the argument.</p>
505</li>
506<li>Arguments:
507<ul>
508
509<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
510</ul>
511</li>
512<li>Return Value:
513<ul>
514
515<li>the <tt>double</tt> cosine value for the argument,</li>
516<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
517<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
518<li>any other non-numeric input value will cause a type error.</li>
519</ul>
520</li>
521<li>
522
523<p>Example:</p>
524
525<div>
526<div>
527<pre class="source">{ &quot;v1&quot;: cos(1), &quot;v2&quot;: cos(2), &quot;v3&quot;: cos(0), &quot;v4&quot;: cos(float(&quot;0.5&quot;)), &quot;v5&quot;: cos(double(&quot;1000&quot;)) };
528</pre></div></div>
529</li>
530<li>
531
532<p>The expected result is:</p>
533
534<div>
535<div>
536<pre class="source">{ &quot;v1&quot;: 0.5403023058681398, &quot;v2&quot;: -0.4161468365471424, &quot;v3&quot;: 1.0, &quot;v4&quot;: 0.8775825618903728, &quot;v5&quot;: 0.562379076290703 }
537</pre></div></div>
538</li>
539</ul></div>
540<div class="section">
541<h3><a name="cosh"></a>cosh</h3>
542<ul>
543
544<li>
545
546<p>Syntax:</p>
547
548<div>
549<div>
550<pre class="source">cosh(numeric_value)
551</pre></div></div>
552</li>
553<li>
554
555<p>Computes the hyperbolic cosine value of the argument.</p>
556</li>
557<li>Arguments:
558<ul>
559
560<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
561</ul>
562</li>
563<li>Return Value:
564<ul>
565
566<li>the <tt>double</tt> hyperbolic cosine value for the argument,</li>
567<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
568<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
569<li>any other non-numeric input value will cause a type error.</li>
570</ul>
571</li>
572<li>
573
574<p>Example:</p>
575
576<div>
577<div>
578<pre class="source">{ &quot;v1&quot;: cosh(1), &quot;v2&quot;: cosh(2), &quot;v3&quot;: cosh(0), &quot;v4&quot;: cosh(float(&quot;0.5&quot;)), &quot;v5&quot;: cosh(double(&quot;8&quot;)) };
579</pre></div></div>
580</li>
581<li>
582
583<p>The expected result is:</p>
584
585<div>
586<div>
587<pre class="source">{ &quot;v1&quot;: 1.5430806348152437, &quot;v2&quot;: 3.7621956910836314, &quot;v3&quot;: 1.0, &quot;v4&quot;: 1.1276259652063807, &quot;v5&quot;: 1490.479161252178 }
588</pre></div></div>
589</li>
590</ul></div>
591<div class="section">
592<h3><a name="degrees"></a>degrees</h3>
593<ul>
594
595<li>
596
597<p>Syntax:</p>
598
599<div>
600<div>
601<pre class="source">degrees(numeric_value)
602</pre></div></div>
603</li>
604<li>
605
606<p>Converts radians to degrees</p>
607</li>
608<li>Arguments:
609<ul>
610
611<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
612</ul>
613</li>
614<li>Return Value:
615<ul>
616
617<li>The degrees value for the given radians value. The returned value has type <tt>double</tt>,</li>
618<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
619<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
620<li>any other non-numeric input value will cause a type error.</li>
621</ul>
622</li>
623<li>
624
625<p>Example:</p>
626
627<div>
628<div>
629<pre class="source">{ &quot;v1&quot;: degrees(pi()) };
630</pre></div></div>
631</li>
632<li>
633
634<p>The expected result is:</p>
635
636<div>
637<div>
638<pre class="source">{ &quot;v1&quot;: 180.0 }
639</pre></div></div>
640</li>
641</ul></div>
642<div class="section">
643<h3><a name="e"></a>e</h3>
644<ul>
645
646<li>
647
648<p>Syntax:</p>
649
650<div>
651<div>
652<pre class="source">e()
653</pre></div></div>
654</li>
655<li>
656
657<p>Return Value:</p>
658<ul>
659
660<li>e (base of the natural logarithm)</li>
661</ul>
662</li>
663<li>
664
665<p>Example:</p>
666
667<div>
668<div>
669<pre class="source">{ &quot;v1&quot;: e() };
670</pre></div></div>
671</li>
672<li>
673
674<p>The expected result is:</p>
675
676<div>
677<div>
678<pre class="source">{ &quot;v1&quot;: 2.718281828459045 }
679</pre></div></div>
680</li>
681</ul></div>
682<div class="section">
683<h3><a name="exp"></a>exp</h3>
684<ul>
685
686<li>
687
688<p>Syntax:</p>
689
690<div>
691<div>
692<pre class="source">exp(numeric_value)
693</pre></div></div>
694</li>
695<li>
696
697<p>Computes e<sup>numeric_value</sup>.</p>
698</li>
699<li>Arguments:
700<ul>
701
702<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
703</ul>
704</li>
705<li>Return Value:
706<ul>
707
708<li>e<sup>numeric_value</sup>,</li>
709<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
710<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
711<li>any other non-numeric input value will cause a type error.</li>
712</ul>
713</li>
714<li>
715
716<p>Example:</p>
717
718<div>
719<div>
720<pre class="source">{ &quot;v1&quot;: exp(1), &quot;v2&quot;: exp(2), &quot;v3&quot;: exp(0), &quot;v4&quot;: exp(float(&quot;0.5&quot;)), &quot;v5&quot;: exp(double(&quot;1000&quot;)) };
721</pre></div></div>
722</li>
723<li>
724
725<p>The expected result is:</p>
726
727<div>
728<div>
729<pre class="source">{ &quot;v1&quot;: 2.718281828459045, &quot;v2&quot;: 7.38905609893065, &quot;v3&quot;: 1.0, &quot;v4&quot;: 1.6487212707001282, &quot;v5&quot;: &quot;Infinity&quot; }
730</pre></div></div>
731</li>
732</ul></div>
733<div class="section">
734<h3><a name="floor"></a>floor</h3>
735<ul>
736
737<li>
738
739<p>Syntax:</p>
740
741<div>
742<div>
743<pre class="source">floor(numeric_value)
744</pre></div></div>
745</li>
746<li>
747
748<p>Computes the largest (closest to positive infinity) number with no fractional part that is not greater than the value. If the argument is already equal to mathematical integer, then the result is the same as the argument.</p>
749</li>
750<li>Arguments:
751<ul>
752
753<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
754</ul>
755</li>
756<li>Return Value:
757<ul>
758
759<li>The floor value for the given number in the same type as the input argument,</li>
760<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
761<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
762<li>any other non-numeric input value will cause a type error.</li>
763</ul>
764</li>
765<li>
766
767<p>Example:</p>
768
769<div>
770<div>
771<pre class="source">{
772 &quot;v1&quot;: floor(2013),
773 &quot;v2&quot;: floor(-4036),
774 &quot;v3&quot;: floor(0.8),
775 &quot;v4&quot;: floor(float(&quot;-2013.2&quot;)),
776 &quot;v5&quot;: floor(double(&quot;-2013.893823748327284&quot;))
777};
778</pre></div></div>
779</li>
780<li>
781
782<p>The expected result is:</p>
783
784<div>
785<div>
786<pre class="source">{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 0.0, &quot;v4&quot;: -2014.0, &quot;v5&quot;: -2014.0 }
787</pre></div></div>
788</li>
789</ul></div>
790<div class="section">
791<h3><a name="ln"></a>ln</h3>
792<ul>
793
794<li>
795
796<p>Syntax:</p>
797
798<div>
799<div>
800<pre class="source">ln(numeric_value)
801</pre></div></div>
802</li>
803<li>
804
805<p>Computes log<sub>e</sub>numeric_value.</p>
806</li>
807<li>Arguments:
808<ul>
809
810<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
811</ul>
812</li>
813<li>Return Value:
814<ul>
815
816<li>log<sub>e</sub>numeric_value,</li>
817<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
818<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
819<li>any other non-numeric input value will cause a type error.</li>
820</ul>
821</li>
822<li>
823
824<p>Example:</p>
825
826<div>
827<div>
828<pre class="source">{ &quot;v1&quot;: ln(1), &quot;v2&quot;: ln(2), &quot;v3&quot;: ln(0), &quot;v4&quot;: ln(float(&quot;0.5&quot;)), &quot;v5&quot;: ln(double(&quot;1000&quot;)) };
829</pre></div></div>
830</li>
831<li>
832
833<p>The expected result is:</p>
834
835<div>
836<div>
837<pre class="source">{ &quot;v1&quot;: 0.0, &quot;v2&quot;: 0.6931471805599453, &quot;v3&quot;: &quot;-Infinity&quot;, &quot;v4&quot;: -0.6931471805599453, &quot;v5&quot;: 6.907755278982137 }
838</pre></div></div>
839</li>
840</ul></div>
841<div class="section">
842<h3><a name="log"></a>log</h3>
843<ul>
844
845<li>
846
847<p>Syntax:</p>
848
849<div>
850<div>
851<pre class="source">log(numeric_value)
852</pre></div></div>
853</li>
854<li>
855
856<p>Computes log<sub>10</sub>numeric_value.</p>
857</li>
858<li>Arguments:
859<ul>
860
861<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
862</ul>
863</li>
864<li>Return Value:
865<ul>
866
867<li>log<sub>10</sub>numeric_value,</li>
868<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
869<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
870<li>any other non-numeric input value will cause a type error.</li>
871</ul>
872</li>
873<li>
874
875<p>Example:</p>
876
877<div>
878<div>
879<pre class="source">{ &quot;v1&quot;: log(1), &quot;v2&quot;: log(2), &quot;v3&quot;: log(0), &quot;v4&quot;: log(float(&quot;0.5&quot;)), &quot;v5&quot;: log(double(&quot;1000&quot;)) };
880</pre></div></div>
881</li>
882<li>
883
884<p>The expected result is:</p>
885
886<div>
887<div>
888<pre class="source">{ &quot;v1&quot;: 0.0, &quot;v2&quot;: 0.3010299956639812, &quot;v3&quot;: &quot;-Infinity&quot;, &quot;v4&quot;: -0.3010299956639812, &quot;v5&quot;: 3.0 }
889</pre></div></div>
890</li>
891</ul></div>
892<div class="section">
893<h3><a name="pi"></a>pi</h3>
894<ul>
895
896<li>
897
898<p>Syntax:</p>
899
900<div>
901<div>
902<pre class="source">pi()
903</pre></div></div>
904</li>
905<li>
906
907<p>Return Value:</p>
908<ul>
909
910<li>Pi</li>
911</ul>
912</li>
913<li>
914
915<p>Example:</p>
916
917<div>
918<div>
919<pre class="source">{ &quot;v1&quot;: pi() };
920</pre></div></div>
921</li>
922<li>
923
924<p>The expected result is:</p>
925
926<div>
927<div>
928<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
929</pre></div></div>
930</li>
931</ul></div>
932<div class="section">
933<h3><a name="power"></a>power</h3>
934<ul>
935
936<li>
937
938<p>Syntax:</p>
939
940<div>
941<div>
942<pre class="source">power(numeric_value1, numeric_value2)
943</pre></div></div>
944</li>
945<li>
946
947<p>Computes numeric_value1<sup>numeric_value2</sup>.</p>
948</li>
949<li>Arguments:
950<ul>
951
952<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
953<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
954</ul>
955</li>
956<li>Return Value:
957<ul>
958
959<li>numeric_value1<sup>numeric_value2</sup>,</li>
960<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
961<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
962<li>any other non-numeric input value will cause a type error.</li>
963</ul>
964</li>
965<li>
966
967<p>Example:</p>
968
969<div>
970<div>
971<pre class="source">{ &quot;v1&quot;: power(1, 2), &quot;v3&quot;: power(0, 4), &quot;v4&quot;: power(float(&quot;0.5&quot;), double(&quot;-0.5&quot;)) };
972</pre></div></div>
973</li>
974<li>
975
976<p>The expected result is:</p>
977
978<div>
979<div>
980<pre class="source">{ &quot;v1&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1.4142135623730951 }
981</pre></div></div>
982</li>
983</ul></div>
984<div class="section">
985<h3><a name="radians"></a>radians</h3>
986<ul>
987
988<li>
989
990<p>Syntax:</p>
991
992<div>
993<div>
994<pre class="source">radians(numeric_value)
995</pre></div></div>
996</li>
997<li>
998
999<p>Converts degrees to radians</p>
1000</li>
1001<li>Arguments:
1002<ul>
1003
1004<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1005</ul>
1006</li>
1007<li>Return Value:
1008<ul>
1009
1010<li>The radians value for the given degrees value. The returned value has type <tt>double</tt>,</li>
1011<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1012<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1013<li>any other non-numeric input value will cause a type error.</li>
1014</ul>
1015</li>
1016<li>
1017
1018<p>Example:</p>
1019
1020<div>
1021<div>
1022<pre class="source">{ &quot;v1&quot;: radians(180) };
1023</pre></div></div>
1024</li>
1025<li>
1026
1027<p>The expected result is:</p>
1028
1029<div>
1030<div>
1031<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
1032</pre></div></div>
1033</li>
1034</ul></div>
1035<div class="section">
1036<h3><a name="round"></a>round</h3>
1037<ul>
1038
1039<li>
1040
1041<p>Syntax:</p>
1042
1043<div>
1044<div>
1045<pre class="source">round(numeric_value[, round_digit])
1046</pre></div></div>
1047</li>
1048<li>
1049
1050<p>Rounds the value to the given number of integer digits to the right of the decimal point, or to the left of the decimal point if the number of digits is negative.</p>
1051</li>
1052<li>
1053
1054<p>Arguments:</p>
1055<ul>
1056
1057<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value that represents the numeric value to be rounded.</li>
1058<li><tt>round_digit</tt>: (Optional) a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value that specifies the digit to round to. This argument may be positive or negative; positive indicating that rounding needs to be to the right of the decimal point, and negative indicating that rounding needs to be to the left of the decimal point. Values such as 1.0 and 2.0 are acceptable, but values such as 1.3 and 1.5 result in a <tt>null</tt>. If omitted, the default is 0.</li>
1059</ul>
1060</li>
1061<li>Return Value:
1062<ul>
1063
1064<li>The rounded value for the given number. The returned value has the following type:
1065<ul>
1066
1067<li><tt>bigint</tt> if the input value has type <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt> or <tt>bigint</tt>,</li>
1068<li><tt>float</tt> if the input value has type <tt>float</tt>,</li>
1069<li><tt>double</tt> if the input value has type <tt>double</tt>;</li>
1070</ul>
1071</li>
1072<li><tt>missing</tt> if the input value is a <tt>missing</tt> value,</li>
1073<li><tt>null</tt> if the input value is a <tt>null</tt> value,</li>
1074<li>any other non-numeric input value will return a <tt>null</tt> value.</li>
1075</ul>
1076</li>
1077<li>
1078
1079<p>Example:</p>
1080
1081<div>
1082<div>
1083<pre class="source">{
1084 &quot;v1&quot;: round(2013),
1085 &quot;v2&quot;: round(-4036),
1086 &quot;v3&quot;: round(0.8),
1087 &quot;v4&quot;: round(float(&quot;-2013.256&quot;)),
1088 &quot;v5&quot;: round(double(&quot;-2013.893823748327284&quot;))
1089 &quot;v6&quot;: round(123456, -1),
1090 &quot;v7&quot;: round(456.456, 2),
1091 &quot;v8&quot;: round(456.456, -1),
1092 &quot;v9&quot;: round(-456.456, -2)
1093};
1094</pre></div></div>
1095</li>
1096<li>
1097
1098<p>The expected result is:</p>
1099
1100<div>
1101<div>
1102<pre class="source">{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2014.0, &quot;v6&quot;: 123460, &quot;v7&quot;: 456.46, &quot;v8&quot;: 460, &quot;v9&quot;: -500 }
1103</pre></div></div>
1104</li>
1105</ul></div>
1106<div class="section">
1107<h3><a name="sign"></a>sign</h3>
1108<ul>
1109
1110<li>
1111
1112<p>Syntax:</p>
1113
1114<div>
1115<div>
1116<pre class="source">sign(numeric_value)
1117</pre></div></div>
1118</li>
1119<li>
1120
1121<p>Computes the sign of the argument.</p>
1122</li>
1123<li>Arguments:
1124<ul>
1125
1126<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1127</ul>
1128</li>
1129<li>Return Value:
1130<ul>
1131
1132<li>the sign (a <tt>tinyint</tt>) of the argument, -1 for negative values, 0 for 0, and 1 for positive values,</li>
1133<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1134<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1135<li>any other non-numeric input value will cause a type error.</li>
1136</ul>
1137</li>
1138<li>
1139
1140<p>Example:</p>
1141
1142<div>
1143<div>
1144<pre class="source">{ &quot;v1&quot;: sign(1), &quot;v2&quot;: sign(2), &quot;v3&quot;: sign(0), &quot;v4&quot;: sign(float(&quot;0.5&quot;)), &quot;v5&quot;: sign(double(&quot;-1000&quot;)) };
1145</pre></div></div>
1146</li>
1147<li>
1148
1149<p>The expected result is:</p>
1150
1151<div>
1152<div>
1153<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1, &quot;v5&quot;: -1 }
1154</pre></div></div>
1155</li>
1156</ul></div>
1157<div class="section">
1158<h3><a name="sin"></a>sin</h3>
1159<ul>
1160
1161<li>
1162
1163<p>Syntax:</p>
1164
1165<div>
1166<div>
1167<pre class="source">sin(numeric_value)
1168</pre></div></div>
1169</li>
1170<li>
1171
1172<p>Computes the sine value of the argument.</p>
1173</li>
1174<li>Arguments:
1175<ul>
1176
1177<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1178</ul>
1179</li>
1180<li>Return Value:
1181<ul>
1182
1183<li>the <tt>double</tt> sine value for the argument,</li>
1184<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1185<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1186<li>any other non-numeric input value will cause a type error.</li>
1187</ul>
1188</li>
1189<li>
1190
1191<p>Example:</p>
1192
1193<div>
1194<div>
1195<pre class="source">{ &quot;v1&quot;: sin(1), &quot;v2&quot;: sin(2), &quot;v3&quot;: sin(0), &quot;v4&quot;: sin(float(&quot;0.5&quot;)), &quot;v5&quot;: sin(double(&quot;1000&quot;)) };
1196</pre></div></div>
1197</li>
1198<li>
1199
1200<p>The expected result is:</p>
1201
1202<div>
1203<div>
1204<pre class="source">{ &quot;v1&quot;: 0.8414709848078965, &quot;v2&quot;: 0.9092974268256817, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.479425538604203, &quot;v5&quot;: 0.8268795405320025 }
1205</pre></div></div>
1206</li>
1207</ul></div>
1208<div class="section">
1209<h3><a name="sinh"></a>sinh</h3>
1210<ul>
1211
1212<li>
1213
1214<p>Syntax:</p>
1215
1216<div>
1217<div>
1218<pre class="source">sinh(numeric_value)
1219</pre></div></div>
1220</li>
1221<li>
1222
1223<p>Computes the hyperbolic sine value of the argument.</p>
1224</li>
1225<li>Arguments:
1226<ul>
1227
1228<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1229</ul>
1230</li>
1231<li>Return Value:
1232<ul>
1233
1234<li>the <tt>double</tt> hyperbolic sine value for the argument,</li>
1235<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1236<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1237<li>any other non-numeric input value will cause a type error.</li>
1238</ul>
1239</li>
1240<li>
1241
1242<p>Example:</p>
1243
1244<div>
1245<div>
1246<pre class="source">{ &quot;v1&quot;: sinh(1), &quot;v2&quot;: sinh(2), &quot;v3&quot;: sinh(0), &quot;v4&quot;: sinh(float(&quot;0.5&quot;)), &quot;v5&quot;: sinh(double(&quot;8&quot;)) };
1247</pre></div></div>
1248</li>
1249<li>
1250
1251<p>The expected result is:</p>
1252
1253<div>
1254<div>
1255<pre class="source">{ &quot;v1&quot;: 1.1752011936438014, &quot;v2&quot;: 3.626860407847019, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.5210953054937474, &quot;v5&quot;: 1490.4788257895502 }
1256</pre></div></div>
1257</li>
1258</ul></div>
1259<div class="section">
1260<h3><a name="sqrt"></a>sqrt</h3>
1261<ul>
1262
1263<li>
1264
1265<p>Syntax:</p>
1266
1267<div>
1268<div>
1269<pre class="source">sqrt(numeric_value)
1270</pre></div></div>
1271</li>
1272<li>
1273
1274<p>Computes the square root of the argument.</p>
1275</li>
1276<li>Arguments:
1277<ul>
1278
1279<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1280</ul>
1281</li>
1282<li>Return Value:
1283<ul>
1284
1285<li>the <tt>double</tt> square root value for the argument,</li>
1286<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1287<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1288<li>any other non-numeric input value will cause a type error.</li>
1289</ul>
1290</li>
1291<li>
1292
1293<p>Example:</p>
1294
1295<div>
1296<div>
1297<pre class="source">{ &quot;v1&quot;: sqrt(1), &quot;v2&quot;: sqrt(2), &quot;v3&quot;: sqrt(0), &quot;v4&quot;: sqrt(float(&quot;0.5&quot;)), &quot;v5&quot;: sqrt(double(&quot;1000&quot;)) };
1298</pre></div></div>
1299</li>
1300<li>
1301
1302<p>The expected result is:</p>
1303
1304<div>
1305<div>
1306<pre class="source">{ &quot;v1&quot;: 1.0, &quot;v2&quot;: 1.4142135623730951, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.7071067811865476, &quot;v5&quot;: 31.622776601683793 }
1307</pre></div></div>
1308</li>
1309</ul></div>
1310<div class="section">
1311<h3><a name="tan"></a>tan</h3>
1312<ul>
1313
1314<li>
1315
1316<p>Syntax:</p>
1317
1318<div>
1319<div>
1320<pre class="source">tan(numeric_value)
1321</pre></div></div>
1322</li>
1323<li>
1324
1325<p>Computes the tangent value of the argument.</p>
1326</li>
1327<li>Arguments:
1328<ul>
1329
1330<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1331</ul>
1332</li>
1333<li>Return Value:
1334<ul>
1335
1336<li>the <tt>double</tt> tangent value for the argument,</li>
1337<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1338<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1339<li>any other non-numeric input value will cause a type error.</li>
1340</ul>
1341</li>
1342<li>
1343
1344<p>Example:</p>
1345
1346<div>
1347<div>
1348<pre class="source">{ &quot;v1&quot;: tan(1), &quot;v2&quot;: tan(2), &quot;v3&quot;: tan(0), &quot;v4&quot;: tan(float(&quot;0.5&quot;)), &quot;v5&quot;: tan(double(&quot;1000&quot;)) };
1349</pre></div></div>
1350</li>
1351<li>
1352
1353<p>The expected result is:</p>
1354
1355<div>
1356<div>
1357<pre class="source">{ &quot;v1&quot;: 1.5574077246549023, &quot;v2&quot;: -2.185039863261519, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.5463024898437905, &quot;v5&quot;: 1.4703241557027185 }
1358</pre></div></div>
1359</li>
1360</ul></div>
1361<div class="section">
1362<h3><a name="tanh"></a>tanh</h3>
1363<ul>
1364
1365<li>
1366
1367<p>Syntax:</p>
1368
1369<div>
1370<div>
1371<pre class="source">tanh(numeric_value)
1372</pre></div></div>
1373</li>
1374<li>
1375
1376<p>Computes the hyperbolic tangent value of the argument.</p>
1377</li>
1378<li>Arguments:
1379<ul>
1380
1381<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1382</ul>
1383</li>
1384<li>Return Value:
1385<ul>
1386
1387<li>the <tt>double</tt> hyperbolic tangent value for the argument,</li>
1388<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1389<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1390<li>any other non-numeric input value will cause a type error.</li>
1391</ul>
1392</li>
1393<li>
1394
1395<p>Example:</p>
1396
1397<div>
1398<div>
1399<pre class="source">{ &quot;v1&quot;: tanh(1), &quot;v2&quot;: tanh(2), &quot;v3&quot;: tanh(0), &quot;v4&quot;: tanh(float(&quot;0.5&quot;)), &quot;v5&quot;: tanh(double(&quot;8&quot;)) };
1400</pre></div></div>
1401</li>
1402<li>
1403
1404<p>The expected result is:</p>
1405
1406<div>
1407<div>
1408<pre class="source">{ &quot;v1&quot;: 0.7615941559557649, &quot;v2&quot;: 0.964027580075817, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.4621171572600098, &quot;v5&quot;: 0.999999774929676 }
1409</pre></div></div>
1410</li>
1411</ul></div>
1412<div class="section">
1413<h3><a name="trunc"></a>trunc</h3>
1414<ul>
1415
1416<li>
1417
1418<p>Syntax:</p>
1419
1420<div>
1421<div>
1422<pre class="source">trunc(numeric_value, number_digits)
1423</pre></div></div>
1424</li>
1425<li>
1426
1427<p>Truncates the number to the given number of integer digits to the right of the decimal point (left if digits is negative). Digits is 0 if not given.</p>
1428</li>
1429<li>Arguments:
1430<ul>
1431
1432<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
1433<li><tt>number_digits</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value.</li>
1434</ul>
1435</li>
1436<li>Return Value:
1437<ul>
1438
1439<li>the <tt>double</tt> tangent value for the argument,</li>
1440<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1441<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is <tt>missing</tt>,</li>
1442<li>a type error will be raised if:
1443<ul>
1444
1445<li>the first argument is any other non-numeric value,</li>
1446<li>the second argument is any other non-tinyint, non-smallint, non-integer, and non-bigint value.</li>
1447</ul>
1448</li>
1449</ul>
1450</li>
1451<li>
1452
1453<p>Example:</p>
1454
1455<div>
1456<div>
1457<pre class="source">{ &quot;v1&quot;: trunc(1, 1), &quot;v2&quot;: trunc(2, -2), &quot;v3&quot;: trunc(0.122, 2), &quot;v4&quot;: trunc(float(&quot;11.52&quot;), -1), &quot;v5&quot;: trunc(double(&quot;1000.5252&quot;), 3) };
1458</pre></div></div>
1459</li>
1460<li>
1461
1462<p>The expected result is:</p>
1463
1464<div>
1465<div>
1466<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: 2, &quot;v3&quot;: 0.12, &quot;v4&quot;: 10.0, &quot;v5&quot;: 1000.525 }
1467</pre></div></div>
1468</li>
1469</ul><!--
1470 ! Licensed to the Apache Software Foundation (ASF) under one
1471 ! or more contributor license agreements. See the NOTICE file
1472 ! distributed with this work for additional information
1473 ! regarding copyright ownership. The ASF licenses this file
1474 ! to you under the Apache License, Version 2.0 (the
1475 ! "License"); you may not use this file except in compliance
1476 ! with the License. You may obtain a copy of the License at
1477 !
1478 ! http://www.apache.org/licenses/LICENSE-2.0
1479 !
1480 ! Unless required by applicable law or agreed to in writing,
1481 ! software distributed under the License is distributed on an
1482 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1483 ! KIND, either express or implied. See the License for the
1484 ! specific language governing permissions and limitations
1485 ! under the License.
1486 !-->
1487</div>
1488<div class="section">
1489<h3><a name="round_half_to_even"></a>round_half_to_even</h3>
1490<ul>
1491
1492<li>
1493
1494<p>Syntax:</p>
1495
1496<div>
1497<div>
1498<pre class="source">round_half_to_even(numeric_value, [precision])
1499</pre></div></div>
1500</li>
1501<li>
1502
1503<p>Computes the closest numeric value to <tt>numeric_value</tt> that is a multiple of ten to the power of minus <tt>precision</tt>. <tt>precision</tt> is optional and by default value <tt>0</tt> is used.</p>
1504</li>
1505<li>Arguments:
1506<ul>
1507
1508<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1509<li><tt>precision</tt>: an optional <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> field representing the number of digits in the fraction of the the result</li>
1510</ul>
1511</li>
1512<li>Return Value:
1513<ul>
1514
1515<li>The rounded value for the given number in the same type as the input argument,</li>
1516<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1517<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1518<li>a type error will be raised if:
1519<ul>
1520
1521<li>the first argument is any other non-numeric value,</li>
1522<li>or, the second argument is any other non-tinyint, non-smallint, non-integer, or non-bigint value.</li>
1523</ul>
1524</li>
1525</ul>
1526</li>
1527<li>
1528
1529<p>Example:</p>
1530
1531<div>
1532<div>
1533<pre class="source">{
1534 &quot;v1&quot;: round_half_to_even(2013),
1535 &quot;v2&quot;: round_half_to_even(-4036),
1536 &quot;v3&quot;: round_half_to_even(0.8),
1537 &quot;v4&quot;: round_half_to_even(float(&quot;-2013.256&quot;)),
1538 &quot;v5&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;)),
1539 &quot;v6&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;), 2),
1540 &quot;v7&quot;: round_half_to_even(2013, 4),
1541 &quot;v8&quot;: round_half_to_even(float(&quot;-2013.256&quot;), 5)
1542};
1543</pre></div></div>
1544</li>
1545<li>
1546
1547<p>The expected result is:</p>
1548
1549<div>
1550<div>
1551<pre class="source">{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2014.0, &quot;v6&quot;: -2013.89, &quot;v7&quot;: 2013, &quot;v8&quot;: -2013.256 }
1552</pre></div></div>
1553</li>
1554</ul><!--
1555 ! Licensed to the Apache Software Foundation (ASF) under one
1556 ! or more contributor license agreements. See the NOTICE file
1557 ! distributed with this work for additional information
1558 ! regarding copyright ownership. The ASF licenses this file
1559 ! to you under the Apache License, Version 2.0 (the
1560 ! "License"); you may not use this file except in compliance
1561 ! with the License. You may obtain a copy of the License at
1562 !
1563 ! http://www.apache.org/licenses/LICENSE-2.0
1564 !
1565 ! Unless required by applicable law or agreed to in writing,
1566 ! software distributed under the License is distributed on an
1567 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1568 ! KIND, either express or implied. See the License for the
1569 ! specific language governing permissions and limitations
1570 ! under the License.
1571 !-->
1572</div></div>
1573<div class="section">
1574<h2><a name="String_Functions"></a><a name="StringFunctions" id="StringFunctions">String Functions</a></h2>
1575<div class="section">
1576<h3><a name="concat"></a>concat</h3>
1577<ul>
1578
1579<li>
1580
1581<p>Syntax:</p>
1582
1583<div>
1584<div>
1585<pre class="source">concat(string1, string2, ...)
1586</pre></div></div>
1587</li>
1588<li>
1589
1590<p>Returns a concatenated string from arguments.</p>
1591</li>
1592<li>Arguments:
1593<ul>
1594
1595<li><tt>string1</tt>: a string value,</li>
1596<li><tt>string2</tt>: a string value,</li>
1597<li>&#x2026;.</li>
1598</ul>
1599</li>
1600<li>Return Value:
1601<ul>
1602
1603<li>a concatenated string from arguments,</li>
1604<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1605<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1606<li>any other non-string input value will cause a type error.</li>
1607</ul>
1608</li>
1609<li>
1610
1611<p>Example:</p>
1612
1613<div>
1614<div>
1615<pre class="source">concat(&quot;test &quot;, &quot;driven &quot;, &quot;development&quot;);
1616</pre></div></div>
1617</li>
1618<li>
1619
1620<p>The expected result is:</p>
1621
1622<div>
1623<div>
1624<pre class="source">&quot;test driven development&quot;
1625</pre></div></div>
1626</li>
1627</ul></div>
1628<div class="section">
1629<h3><a name="contains"></a>contains</h3>
1630<ul>
1631
1632<li>
1633
1634<p>Syntax:</p>
1635
1636<div>
1637<div>
1638<pre class="source">contains(string, substring_to_contain)
1639</pre></div></div>
1640</li>
1641<li>
1642
1643<p>Checks whether the string <tt>string</tt> contains the string <tt>substring_to_contain</tt></p>
1644</li>
1645<li>Arguments:
1646<ul>
1647
1648<li><tt>string</tt> : a <tt>string</tt> that might contain the given substring,</li>
1649<li><tt>substring_to_contain</tt> : a target <tt>string</tt> that might be contained.</li>
1650</ul>
1651</li>
1652<li>Return Value:
1653<ul>
1654
1655<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1656<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1657<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1658<li>any other non-string input value will cause a type error,</li>
1659<li><tt>false</tt> otherwise.</li>
1660</ul>
1661</li>
1662<li>
1663
1664<p>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</p>
1665</li>
1666<li>Example:
1667
1668<div>
1669<div>
1670<pre class="source">{ &quot;v1&quot;: contains(&quot;I like x-phone&quot;, &quot;phone&quot;), &quot;v2&quot;: contains(&quot;one&quot;, &quot;phone&quot;) };
1671</pre></div></div>
1672</li>
1673<li>
1674
1675<p>The expected result is:</p>
1676
1677<div>
1678<div>
1679<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1680</pre></div></div>
1681</li>
1682</ul></div>
1683<div class="section">
1684<h3><a name="ends_with"></a>ends_with</h3>
1685<ul>
1686
1687<li>
1688
1689<p>Syntax:</p>
1690
1691<div>
1692<div>
1693<pre class="source">ends_with(string, substring_to_end_with)
1694</pre></div></div>
1695</li>
1696<li>
1697
1698<p>Checks whether the string <tt>string</tt> ends with the string <tt>substring_to_end_with</tt>.</p>
1699</li>
1700<li>Arguments:
1701<ul>
1702
1703<li><tt>string</tt> : a <tt>string</tt> that might end with the given string,</li>
1704<li><tt>substring_to_end_with</tt> : a <tt>string</tt> that might be contained as the ending substring.</li>
1705</ul>
1706</li>
1707<li>Return Value:
1708<ul>
1709
1710<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1711<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1712<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1713<li>any other non-string input value will cause a type error,</li>
1714<li><tt>false</tt> otherwise.</li>
1715</ul>
1716</li>
1717<li>
1718
1719<p>Example:</p>
1720
1721<div>
1722<div>
1723<pre class="source">{
1724 &quot;v1&quot;: ends_with(&quot; love product-b its shortcut_menu is awesome:)&quot;, &quot;:)&quot;),
1725 &quot;v2&quot;: ends_with(&quot; awsome:)&quot;, &quot;:-)&quot;)
1726};
1727</pre></div></div>
1728</li>
1729<li>
1730
1731<p>The expected result is:</p>
1732
1733<div>
1734<div>
1735<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1736</pre></div></div>
1737</li>
1738</ul></div>
1739<div class="section">
1740<h3><a name="initcap_.28or_title.29"></a>initcap (or title)</h3>
1741<ul>
1742
1743<li>
1744
1745<p>Syntax:</p>
1746
1747<div>
1748<div>
1749<pre class="source">initcap(string)
1750</pre></div></div>
1751</li>
1752<li>
1753
1754<p>Converts a given string <tt>string</tt> so that the first letter of each word is uppercase and every other letter is lowercase. The function has an alias called &#x201c;title&#x201d;.</p>
1755</li>
1756<li>Arguments:
1757<ul>
1758
1759<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1760</ul>
1761</li>
1762<li>Return Value:
1763<ul>
1764
1765<li>a <tt>string</tt> as the title form of the given <tt>string</tt>,</li>
1766<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1767<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1768<li>any other non-string input value will cause a type error.</li>
1769</ul>
1770</li>
1771<li>
1772
1773<p>Example:</p>
1774
1775<div>
1776<div>
1777<pre class="source">{ &quot;v1&quot;: initcap(&quot;ASTERIXDB is here!&quot;), &quot;v2&quot;: title(&quot;ASTERIXDB is here!&quot;) };
1778</pre></div></div>
1779</li>
1780<li>
1781
1782<p>The expected result is:</p>
1783
1784<div>
1785<div>
1786<pre class="source">{ &quot;v1&quot;: &quot;Asterixdb Is Here!&quot;, &quot;v2&quot;: &quot;Asterixdb Is Here!&quot; }
1787</pre></div></div>
1788</li>
1789</ul></div>
1790<div class="section">
1791<h3><a name="length"></a>length</h3>
1792<ul>
1793
1794<li>
1795
1796<p>Syntax:</p>
1797
1798<div>
1799<div>
1800<pre class="source">length(string)
1801</pre></div></div>
1802</li>
1803<li>
1804
1805<p>Returns the length of the string <tt>string</tt>. Note that the length is in the unit of code point. See the following examples for more details.</p>
1806</li>
1807<li>Arguments:
1808<ul>
1809
1810<li><tt>string</tt> : a <tt>string</tt> or <tt>null</tt> that represents the string to be checked.</li>
1811</ul>
1812</li>
1813<li>Return Value:
1814<ul>
1815
1816<li>an <tt>bigint</tt> that represents the length of <tt>string</tt>,</li>
1817<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1818<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1819<li>any other non-string input value will cause a type error.</li>
1820</ul>
1821</li>
1822<li>
1823
1824<p>Example:</p>
1825
1826<div>
1827<div>
1828<pre class="source">length(&quot;test string&quot;);
1829</pre></div></div>
1830</li>
1831<li>
1832
1833<p>The expected result is:</p>
1834
1835<div>
1836<div>
1837<pre class="source">11
1838</pre></div></div>
1839</li>
1840<li>
1841
1842<p>Example:</p>
1843
1844<div>
1845<div>
1846<pre class="source">length(&quot;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;);
1847</pre></div></div>
1848</li>
1849<li>
1850
1851<p>The expected result is (the emoji character &#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466; has 7 code points):</p>
1852
1853<div>
1854<div>
1855<pre class="source">7
1856</pre></div></div>
1857</li>
1858</ul></div>
1859<div class="section">
1860<h3><a name="lower"></a>lower</h3>
1861<ul>
1862
1863<li>
1864
1865<p>Syntax:</p>
1866
1867<div>
1868<div>
1869<pre class="source">lower(string)
1870</pre></div></div>
1871</li>
1872<li>
1873
1874<p>Converts a given string <tt>string</tt> to its lowercase form.</p>
1875</li>
1876<li>Arguments:
1877<ul>
1878
1879<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1880</ul>
1881</li>
1882<li>Return Value:
1883<ul>
1884
1885<li>a <tt>string</tt> as the lowercase form of the given <tt>string</tt>,</li>
1886<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1887<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1888<li>any other non-string input value will cause a type error.</li>
1889</ul>
1890</li>
1891<li>
1892
1893<p>Example:</p>
1894
1895<div>
1896<div>
1897<pre class="source">lower(&quot;ASTERIXDB&quot;);
1898</pre></div></div>
1899</li>
1900<li>
1901
1902<p>The expected result is:</p>
1903
1904<div>
1905<div>
1906<pre class="source">&quot;asterixdb&quot;
1907</pre></div></div>
1908</li>
1909</ul></div>
1910<div class="section">
1911<h3><a name="ltrim"></a>ltrim</h3>
1912<ul>
1913
1914<li>
1915
1916<p>Syntax:</p>
1917
1918<div>
1919<div>
1920<pre class="source">ltrim(string[, chars]);
1921</pre></div></div>
1922</li>
1923<li>
1924
1925<p>Returns a new string with all leading characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
1926</li>
1927<li>Arguments:
1928<ul>
1929
1930<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
1931<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
1932</ul>
1933</li>
1934<li>Return Value:
1935<ul>
1936
1937<li>a trimmed, new <tt>string</tt>,</li>
1938<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1939<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1940<li>any other non-string input value will cause a type error.</li>
1941</ul>
1942</li>
1943<li>Related functions: see <tt>trim()</tt>, <tt>rtrim()</tt></li>
1944<li>
1945
1946<p>Example:</p>
1947
1948<div>
1949<div>
1950<pre class="source">ltrim(&quot;me like x-phone&quot;, &quot;eml&quot;);
1951</pre></div></div>
1952</li>
1953<li>
1954
1955<p>The expected result is:</p>
1956
1957<div>
1958<div>
1959<pre class="source">&quot; like x-phone&quot;
1960</pre></div></div>
1961</li>
1962<li>
1963
1964<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
1965
1966<div>
1967<div>
1968<pre class="source">ltrim(&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;, &quot;&#x1f468;&#x200d;&#x1f466;&quot;)
1969</pre></div></div>
1970</li>
1971<li>
1972
1973<p>The expected result is (only woman, girl and boy are left in the family):</p>
1974
1975<div>
1976<div>
1977<pre class="source">&quot;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;
1978</pre></div></div>
1979</li>
1980</ul></div>
1981<div class="section">
1982<h3><a name="position"></a>position</h3>
1983<ul>
1984
1985<li>
1986
1987<p>Syntax:</p>
1988
1989<div>
1990<div>
1991<pre class="source">position(string, string_pattern)
1992</pre></div></div>
1993</li>
1994<li>
1995
1996<p>Returns the first position of <tt>string_pattern</tt> within <tt>string</tt>. The result is counted in the unit of code points. See the following example for more details.</p>
1997</li>
1998<li>
1999
2000<p>The function returns the 0-based position. Another version of the function returns the 1-based position. Below are the aliases for each version:</p>
2001<ul>
2002
2003<li>0-based: <tt>position</tt>, <tt>pos</tt>, <tt>position0</tt>, <tt>pos0</tt>.</li>
2004<li>1-based: <tt>position1</tt>, <tt>pos1</tt>.</li>
2005</ul>
2006</li>
2007<li>
2008
2009<p>Arguments:</p>
2010<ul>
2011
2012<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2013<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2014</ul>
2015</li>
2016<li>Return Value:
2017<ul>
2018
2019<li>the first position that <tt>string_pattern</tt> appears within <tt>string</tt> (starting at 0), or -1 if it does not appear,</li>
2020<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2021<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2022<li>any other non-string input value will return a <tt>null</tt>.</li>
2023</ul>
2024</li>
2025<li>
2026
2027<p>Example:</p>
2028
2029<div>
2030<div>
2031<pre class="source">{
2032 &quot;v1&quot;: position(&quot;ppphonepp&quot;, &quot;phone&quot;),
2033 &quot;v2&quot;: position(&quot;hone&quot;, &quot;phone&quot;),
2034 &quot;v3&quot;: position1(&quot;ppphonepp&quot;, &quot;phone&quot;),
2035 &quot;v4&quot;: position1(&quot;hone&quot;, &quot;phone&quot;)
2036};
2037</pre></div></div>
2038</li>
2039<li>
2040
2041<p>The expected result is:</p>
2042
2043<div>
2044<div>
2045<pre class="source">{ &quot;v1&quot;: 2, &quot;v2&quot;: -1, v3&quot;: 3, &quot;v4&quot;: -1 }
2046</pre></div></div>
2047</li>
2048<li>
2049
2050<p>Example of multi-code-point character:</p>
2051
2052<div>
2053<div>
2054<pre class="source">position(&quot;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x1f3c0;&quot;, &quot;&#x1f3c0;&quot;);
2055</pre></div></div>
2056</li>
2057<li>
2058
2059<p>The expected result is (the emoji family character has 7 code points):</p>
2060
2061<div>
2062<div>
2063<pre class="source">7
2064</pre></div></div>
2065</li>
2066</ul></div>
2067<div class="section">
2068<h3><a name="regexp_contains"></a>regexp_contains</h3>
2069<ul>
2070
2071<li>
2072
2073<p>Syntax:</p>
2074
2075<div>
2076<div>
2077<pre class="source">regexp_contains(string, string_pattern[, string_flags])
2078</pre></div></div>
2079</li>
2080<li>
2081
2082<p>Checks whether the strings <tt>string</tt> contains the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2083</li>
2084<li>
2085
2086<p>Aliases:</p>
2087<ul>
2088
2089<li><tt>regexp_contains</tt>, <tt>regex_contains</tt>, <tt>contains_regexp</tt>, <tt>contains_regex</tt>.</li>
2090</ul>
2091</li>
2092<li>
2093
2094<p>Arguments:</p>
2095<ul>
2096
2097<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2098<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2099<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2100<ul>
2101
2102<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2103</ul>
2104</li>
2105</ul>
2106</li>
2107<li>Return Value:
2108<ul>
2109
2110<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> contains the pattern <tt>string_pattern</tt>, <tt>false</tt> otherwise.</li>
2111<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2112<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2113<li>any other non-string input value will return a <tt>null</tt>.</li>
2114</ul>
2115</li>
2116<li>
2117
2118<p>Example:</p>
2119
2120<div>
2121<div>
2122<pre class="source">{
2123 &quot;v1&quot;: regexp_contains(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2124 &quot;v2&quot;: regexp_contains(&quot;hone&quot;, &quot;p+hone&quot;)
2125};
2126</pre></div></div>
2127</li>
2128<li>
2129
2130<p>The expected result is:</p>
2131
2132<div>
2133<div>
2134<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2135</pre></div></div>
2136</li>
2137</ul></div>
2138<div class="section">
2139<h3><a name="regexp_like"></a>regexp_like</h3>
2140<ul>
2141
2142<li>
2143
2144<p>Syntax:</p>
2145
2146<div>
2147<div>
2148<pre class="source">regexp_like(string, string_pattern[, string_flags])
2149</pre></div></div>
2150</li>
2151<li>
2152
2153<p>Checks whether the string <tt>string</tt> exactly matches the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2154</li>
2155<li>
2156
2157<p>Aliases:</p>
2158<ul>
2159
2160<li><tt>regexp_like</tt>, <tt>regex_like</tt>.</li>
2161</ul>
2162</li>
2163<li>
2164
2165<p>Arguments:</p>
2166<ul>
2167
2168<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2169<li><tt>string_pattern</tt> : a pattern <tt>string</tt> that might be contained.</li>
2170<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2171<ul>
2172
2173<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2174</ul>
2175</li>
2176</ul>
2177</li>
2178<li>Return Value:
2179<ul>
2180
2181<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains the pattern <tt>string_pattern</tt>, <tt>false</tt> otherwise.</li>
2182<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2183<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2184<li>any other non-string input value will return a <tt>null</tt>.</li>
2185</ul>
2186</li>
2187<li>
2188
2189<p>Example:</p>
2190
2191<div>
2192<div>
2193<pre class="source">{
2194 &quot;v1&quot;: regexp_like(&quot; can't stand acast the network is horrible:(&quot;, &quot;.*acast.*&quot;),
2195 &quot;v2&quot;: regexp_like(&quot;acast&quot;, &quot;.*acst.*&quot;)
2196};
2197</pre></div></div>
2198</li>
2199<li>
2200
2201<p>The expected result is:</p>
2202
2203<div>
2204<div>
2205<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2206</pre></div></div>
2207</li>
2208</ul></div>
2209<div class="section">
2210<h3><a name="regexp_position"></a>regexp_position</h3>
2211<ul>
2212
2213<li>
2214
2215<p>Syntax:</p>
2216
2217<div>
2218<div>
2219<pre class="source">regexp_position(string, string_pattern[, string_flags])
2220</pre></div></div>
2221</li>
2222<li>
2223
2224<p>Returns first position of the regular expression <tt>string_pattern</tt> (a Java regular expression pattern) within <tt>string</tt>. The function returns the 0-based position. Another version of the function returns the 1-based position. Below are the aliases for each version:</p>
2225</li>
2226<li>
2227
2228<p>Aliases:</p>
2229<ul>
2230
2231<li>0-Based: <tt>regexp_position</tt>, <tt>regexp_pos</tt>, <tt>regexp_position0</tt>, <tt>regexp_pos0</tt>, <tt>regex_position</tt>, <tt>regex_pos</tt>, <tt>regex_position0</tt>, <tt>regex_pos0</tt>.</li>
2232<li>1-Based: <tt>regexp_position1</tt>, <tt>regexp_pos1</tt>, <tt>regex_position1</tt> <tt>regex_pos1</tt>.</li>
2233</ul>
2234</li>
2235<li>
2236
2237<p>Arguments:</p>
2238<ul>
2239
2240<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2241<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2242<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2243<ul>
2244
2245<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2246</ul>
2247</li>
2248</ul>
2249</li>
2250<li>Return Value:
2251<ul>
2252
2253<li>the first position that the regular expression <tt>string_pattern</tt> appears in <tt>string</tt> (starting at 0), or -1 if it does not appear.</li>
2254<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2255<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2256<li>any other non-string input value will return a <tt>null</tt>.</li>
2257</ul>
2258</li>
2259<li>
2260
2261<p>Example:</p>
2262
2263<div>
2264<div>
2265<pre class="source">{
2266 &quot;v1&quot;: regexp_position(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2267 &quot;v2&quot;: regexp_position(&quot;hone&quot;, &quot;p+hone&quot;),
2268 &quot;v3&quot;: regexp_position1(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2269 &quot;v4&quot;: regexp_position1(&quot;hone&quot;, &quot;p+hone&quot;)
2270};
2271</pre></div></div>
2272</li>
2273<li>
2274
2275<p>The expected result is:</p>
2276
2277<div>
2278<div>
2279<pre class="source">{ &quot;v1&quot;: 0, &quot;v2&quot;: -1, &quot;v3&quot;: 1, &quot;v4&quot;: -1 }
2280</pre></div></div>
2281</li>
2282</ul></div>
2283<div class="section">
2284<h3><a name="regexp_replace"></a>regexp_replace</h3>
2285<ul>
2286
2287<li>
2288
2289<p>Syntax:</p>
2290
2291<div>
2292<div>
2293<pre class="source">regexp_replace(string, string_pattern, string_replacement[, string_flags])
2294regexp_replace(string, string_pattern, string_replacement[, replacement_limit])
2295</pre></div></div>
2296</li>
2297<li>
2298
2299<p>Checks whether the string <tt>string</tt> matches the given regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern), and replaces the matched pattern <tt>string_pattern</tt> with the new pattern <tt>string_replacement</tt>.</p>
2300</li>
2301<li>
2302
2303<p>Aliases:</p>
2304<ul>
2305
2306<li><tt>regexp_replace</tt>, <tt>regex_replace</tt>.</li>
2307</ul>
2308</li>
2309<li>
2310
2311<p>Arguments:</p>
2312<ul>
2313
2314<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2315<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2316<li><tt>string_replacement</tt> : a pattern <tt>string</tt> to be used as the replacement.</li>
2317<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during replace.
2318<ul>
2319
2320<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2321</ul>
2322</li>
2323<li><tt>replacement_limit</tt>: (Optional) an <tt>integer</tt> specifying the maximum number of replacements to make (if negative then all occurrences will be replaced)</li>
2324</ul>
2325</li>
2326<li>Return Value:
2327<ul>
2328
2329<li>Returns a <tt>string</tt> that is obtained after the replacements.</li>
2330<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2331<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2332<li>any other non-string input value will return a <tt>null</tt>.</li>
2333</ul>
2334</li>
2335<li>
2336
2337<p>Example:</p>
2338
2339<div>
2340<div>
2341<pre class="source">regexp_replace(&quot; like x-phone the voicemail_service is awesome&quot;, &quot; like x-phone&quot;, &quot;like product-a&quot;);
2342</pre></div></div>
2343</li>
2344<li>
2345
2346<p>The expected result is:</p>
2347
2348<div>
2349<div>
2350<pre class="source">&quot;like product-a the voicemail_service is awesome&quot;
2351</pre></div></div>
2352</li>
2353</ul></div>
2354<div class="section">
2355<h3><a name="repeat"></a>repeat</h3>
2356<ul>
2357
2358<li>
2359
2360<p>Syntax:</p>
2361
2362<div>
2363<div>
2364<pre class="source">repeat(string, n)
2365</pre></div></div>
2366</li>
2367<li>
2368
2369<p>Returns a string formed by repeating the input <tt>string</tt> <tt>n</tt> times.</p>
2370</li>
2371<li>Arguments:
2372<ul>
2373
2374<li><tt>string</tt> : a <tt>string</tt> to be repeated,</li>
2375<li><tt>n</tt> : an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value - how many times the string should be repeated.</li>
2376</ul>
2377</li>
2378<li>Return Value:
2379<ul>
2380
2381<li>a string that repeats the input <tt>string</tt> <tt>n</tt> times,</li>
2382<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2383<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2384<li>a type error will be raised if:
2385<ul>
2386
2387<li>the first argument is any other non-string value,</li>
2388<li>or, the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2389</ul>
2390</li>
2391</ul>
2392</li>
2393<li>
2394
2395<p>Example:</p>
2396
2397<div>
2398<div>
2399<pre class="source">repeat(&quot;test&quot;, 3);
2400</pre></div></div>
2401</li>
2402<li>
2403
2404<p>The expected result is:</p>
2405
2406<div>
2407<div>
2408<pre class="source">&quot;testtesttest&quot;
2409</pre></div></div>
2410</li>
2411</ul></div>
2412<div class="section">
2413<h3><a name="replace"></a>replace</h3>
2414<ul>
2415
2416<li>
2417
2418<p>Syntax:</p>
2419
2420<div>
2421<div>
2422<pre class="source">replace(string, search_string, replacement_string[, limit])
2423</pre></div></div>
2424</li>
2425<li>
2426
2427<p>Finds occurrences of the given substring <tt>search_string</tt> in the input string <tt>string</tt> and replaces them with the new substring <tt>replacement_string</tt>.</p>
2428</li>
2429<li>Arguments:
2430<ul>
2431
2432<li><tt>string</tt> : an input <tt>string</tt>,</li>
2433<li><tt>search_string</tt> : a <tt>string</tt> substring to be searched for,</li>
2434<li><tt>replacement_string</tt> : a <tt>string</tt> to be used as the replacement,</li>
2435<li><tt>limit</tt> : (Optional) an <tt>integer</tt> - maximum number of occurrences to be replaced. If not specified or negative then all occurrences will be replaced</li>
2436</ul>
2437</li>
2438<li>Return Value:
2439<ul>
2440
2441<li>Returns a <tt>string</tt> that is obtained after the replacements,</li>
2442<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2443<li>any other non-string input value or non-integer <tt>limit</tt> will cause a type error,</li>
2444<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2445</ul>
2446</li>
2447<li>
2448
2449<p>Example:</p>
2450
2451<div>
2452<div>
2453<pre class="source">{
2454 &quot;v1&quot;: replace(&quot; like x-phone the voicemail_service is awesome&quot;, &quot; like x-phone&quot;, &quot;like product-a&quot;),
2455 &quot;v2&quot;: replace(&quot;x-phone and x-phone&quot;, &quot;x-phone&quot;, &quot;product-a&quot;, 1)
2456};
2457</pre></div></div>
2458</li>
2459<li>
2460
2461<p>The expected result is:</p>
2462
2463<div>
2464<div>
2465<pre class="source">{
2466 &quot;v1&quot;: &quot;like product-a the voicemail_service is awesome&quot;,
2467 &quot;v2&quot;: &quot;product-a and x-phone&quot;
2468}
2469</pre></div></div>
2470</li>
2471</ul></div>
2472<div class="section">
2473<h3><a name="reverse"></a>reverse</h3>
2474<ul>
2475
2476<li>
2477
2478<p>Syntax:</p>
2479
2480<div>
2481<div>
2482<pre class="source">reverse(string)
2483</pre></div></div>
2484</li>
2485<li>
2486
2487<p>Returns a string formed by reversing characters in the input <tt>string</tt>. For characters of multiple code points, code point is the minimal unit to reverse. See the following examples for more details.</p>
2488</li>
2489<li>Arguments:
2490<ul>
2491
2492<li><tt>string</tt> : a <tt>string</tt> to be reversed</li>
2493</ul>
2494</li>
2495<li>Return Value:
2496<ul>
2497
2498<li>a string containing characters from the the input <tt>string</tt> in the reverse order,</li>
2499<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2500<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2501<li>a type error will be raised if:
2502<ul>
2503
2504<li>the first argument is any other non-string value</li>
2505</ul>
2506</li>
2507</ul>
2508</li>
2509<li>
2510
2511<p>Example:</p>
2512
2513<div>
2514<div>
2515<pre class="source">reverse(&quot;hello&quot;);
2516</pre></div></div>
2517</li>
2518<li>
2519
2520<p>The expected result is:</p>
2521
2522<div>
2523<div>
2524<pre class="source">&quot;olleh&quot;
2525</pre></div></div>
2526</li>
2527<li>
2528
2529<p>Example of multi-code-point character (Korean):</p>
2530
2531<div>
2532<div>
2533<pre class="source">reverse(&quot;&#x1112;&#x1161;&#x11ab;&#x1100;&#x1173;&#x11af;&quot;);
2534</pre></div></div>
2535</li>
2536<li>
2537
2538<p>The expected result is (the Korean characters are splitted into code points and then the code points are reversed):</p>
2539
2540<div>
2541<div>
2542<pre class="source">&quot;&#x11af;&#x1173;&#x1100;&#x11ab;&#x1161;&#x1112;&quot;
2543</pre></div></div>
2544</li>
2545</ul></div>
2546<div class="section">
2547<h3><a name="rtrim"></a>rtrim</h3>
2548<ul>
2549
2550<li>
2551
2552<p>Syntax:</p>
2553
2554<div>
2555<div>
2556<pre class="source">rtrim(string[, chars]);
2557</pre></div></div>
2558</li>
2559<li>
2560
2561<p>Returns a new string with all trailing characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
2562</li>
2563<li>Arguments:
2564<ul>
2565
2566<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2567<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2568</ul>
2569</li>
2570<li>Return Value:
2571<ul>
2572
2573<li>a trimmed, new <tt>string</tt>,</li>
2574<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2575<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2576<li>any other non-string input value will cause a type error.</li>
2577</ul>
2578</li>
2579<li>Related functions: see <tt>trim()</tt>, <tt>ltrim()</tt></li>
2580<li>
2581
2582<p>Example:</p>
2583
2584<div>
2585<div>
2586<pre class="source">{
2587 &quot;v1&quot;: rtrim(&quot;i like x-phone&quot;, &quot;x-phone&quot;),
2588 &quot;v2&quot;: rtrim(&quot;i like x-phone&quot;, &quot;onexph&quot;)
2589};
2590</pre></div></div>
2591</li>
2592<li>
2593
2594<p>The expected result is:</p>
2595
2596<div>
2597<div>
2598<pre class="source">{ &quot;v1&quot;: &quot;i like &quot;, &quot;v2&quot;: &quot;i like x-&quot; }
2599</pre></div></div>
2600</li>
2601<li>
2602
2603<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
2604
2605<div>
2606<div>
2607<pre class="source">rtrim(&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;, &quot;&#x1f468;&#x200d;&#x1f466;&quot;)
2608</pre></div></div>
2609</li>
2610<li>
2611
2612<p>The expected result is (only man, woman and girl are left in the family):</p>
2613
2614<div>
2615<div>
2616<pre class="source">&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&quot;
2617</pre></div></div>
2618</li>
2619</ul></div>
2620<div class="section">
2621<h3><a name="split"></a>split</h3>
2622<ul>
2623
2624<li>
2625
2626<p>Syntax:</p>
2627
2628<div>
2629<div>
2630<pre class="source">split(string, sep)
2631</pre></div></div>
2632</li>
2633<li>
2634
2635<p>Splits the input <tt>string</tt> into an array of substrings separated by the string <tt>sep</tt>.</p>
2636</li>
2637<li>Arguments:
2638<ul>
2639
2640<li><tt>string</tt> : a <tt>string</tt> to be split.</li>
2641</ul>
2642</li>
2643<li>Return Value:
2644<ul>
2645
2646<li>an array of substrings by splitting the input <tt>string</tt> by <tt>sep</tt>,</li>
2647<li>in case of two consecutive <tt>sep</tt>s in the <tt>string</tt>, the result of splitting the two consecutive <tt>sep</tt>s will be the empty string <tt>&quot;&quot;</tt>,</li>
2648<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2649<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2650<li>any other non-string input value will cause a type error.</li>
2651</ul>
2652</li>
2653<li>
2654
2655<p>Example:</p>
2656
2657<div>
2658<div>
2659<pre class="source">split(&quot;test driven development&quot;, &quot; &quot;);
2660</pre></div></div>
2661</li>
2662<li>
2663
2664<p>The expected result is:</p>
2665
2666<div>
2667<div>
2668<pre class="source">[ &quot;test&quot;, &quot;driven&quot;, &quot;development&quot; ]
2669</pre></div></div>
2670</li>
2671<li>
2672
2673<p>Example with two consecutive <tt>sep</tt>s in the <tt>string</tt>:</p>
2674
2675<div>
2676<div>
2677<pre class="source">split(&quot;123//456&quot;, &quot;/&quot;);
2678</pre></div></div>
2679</li>
2680<li>
2681
2682<p>The expected result is:</p>
2683
2684<div>
2685<div>
2686<pre class="source">[ &quot;123&quot;, &quot;&quot;, &quot;456&quot; ]
2687</pre></div></div>
2688</li>
2689</ul></div>
2690<div class="section">
2691<h3><a name="starts_with"></a>starts_with</h3>
2692<ul>
2693
2694<li>
2695
2696<p>Syntax:</p>
2697
2698<div>
2699<div>
2700<pre class="source">starts_with(string, substring_to_start_with)
2701</pre></div></div>
2702</li>
2703<li>
2704
2705<p>Checks whether the string <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>.</p>
2706</li>
2707<li>Arguments:
2708<ul>
2709
2710<li><tt>string</tt> : a <tt>string</tt> that might start with the given string.</li>
2711<li><tt>substring_to_start_with</tt> : a <tt>string</tt> that might be contained as the starting substring.</li>
2712</ul>
2713</li>
2714<li>Return Value:
2715<ul>
2716
2717<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>,</li>
2718<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2719<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2720<li>any other non-string input value will cause a type error,</li>
2721<li><tt>false</tt> otherwise.</li>
2722</ul>
2723</li>
2724<li>
2725
2726<p>Example:</p>
2727
2728<div>
2729<div>
2730<pre class="source">{
2731 &quot;v1&quot; : starts_with(&quot; like the plan, amazing&quot;, &quot; like&quot;),
2732 &quot;v2&quot; : starts_with(&quot;I like the plan, amazing&quot;, &quot; like&quot;)
2733};
2734</pre></div></div>
2735</li>
2736<li>
2737
2738<p>The expected result is:</p>
2739
2740<div>
2741<div>
2742<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2743</pre></div></div>
2744</li>
2745</ul></div>
2746<div class="section">
2747<h3><a name="substr"></a>substr</h3>
2748<ul>
2749
2750<li>
2751
2752<p>Syntax:</p>
2753
2754<div>
2755<div>
2756<pre class="source">substr(string, offset[, length])
2757</pre></div></div>
2758</li>
2759<li>
2760
2761<p>Returns the substring from the given string <tt>string</tt> based on the given start offset <tt>offset</tt> with the optional <tt>length</tt>. Note that both of the <tt>offset</tt> and <tt>length</tt> are in the unit of code point (e.g. the emoji family &#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466; has 7 code points). The function uses the 0-based position. Another version of the function uses the 1-based position. Below are the aliases for each version:</p>
2762</li>
2763<li>
2764
2765<p>Aliases:</p>
2766<ul>
2767
2768<li>0-Based: <tt>substring</tt>, <tt>substr</tt>, <tt>substring0</tt>, <tt>substr0</tt>.</li>
2769<li>1-Based: <tt>substring1</tt>, <tt>substr1</tt>.</li>
2770</ul>
2771</li>
2772<li>
2773
2774<p>Arguments:</p>
2775<ul>
2776
2777<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
2778<li><tt>offset</tt> : an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value as the starting offset of the substring in <tt>string</tt> (starting at 0). If negative then counted from the end of the string.</li>
2779<li><tt>length</tt> : (Optional) an an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value as the length of the substring.</li>
2780</ul>
2781</li>
2782<li>Return Value:
2783<ul>
2784
2785<li>a <tt>string</tt> that represents the substring,</li>
2786<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2787<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or if the substring could not be obtained because the starting offset is not within string bounds or <tt>length</tt> is negative.</li>
2788<li>a <tt>null</tt> will be returned if:
2789<ul>
2790
2791<li>the first argument is any other non-string value.</li>
2792<li>the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2793<li>the third argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> if the argument is present.</li>
2794</ul>
2795</li>
2796</ul>
2797</li>
2798<li>
2799
2800<p>Example:</p>
2801
2802<div>
2803<div>
2804<pre class="source">{ &quot;v1&quot;: substr(&quot;test string&quot;, 6, 3), &quot;v2&quot;: substr1(&quot;test string&quot;, 6, 3) };
2805</pre></div></div>
2806</li>
2807<li>
2808
2809<p>The expected result is:</p>
2810
2811<div>
2812<div>
2813<pre class="source">{ &quot;v1&quot;: &quot;tri&quot;, &quot;v2&quot;: &quot;str&quot; }
2814</pre></div></div>
2815</li>
2816</ul>
2817<p>The function has an alias <tt>substring</tt>.</p></div>
2818<div class="section">
2819<h3><a name="trim"></a>trim</h3>
2820<ul>
2821
2822<li>
2823
2824<p>Syntax:</p>
2825
2826<div>
2827<div>
2828<pre class="source">trim(string[, chars]);
2829</pre></div></div>
2830</li>
2831<li>
2832
2833<p>Returns a new string with all leading and trailing characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
2834</li>
2835<li>Arguments:
2836<ul>
2837
2838<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2839<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2840</ul>
2841</li>
2842<li>Return Value:
2843<ul>
2844
2845<li>a trimmed, new <tt>string</tt>,</li>
2846<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2847<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2848<li>any other non-string input value will cause a type error.</li>
2849</ul>
2850</li>
2851<li>Related functions: see <tt>ltrim()</tt>, <tt>rtrim()</tt></li>
2852<li>
2853
2854<p>Example:</p>
2855
2856<div>
2857<div>
2858<pre class="source">trim(&quot;i like x-phone&quot;, &quot;xphoen&quot;);
2859</pre></div></div>
2860</li>
2861<li>
2862
2863<p>The expected result is:</p>
2864
2865<div>
2866<div>
2867<pre class="source">&quot; like &quot;
2868</pre></div></div>
2869</li>
2870<li>
2871
2872<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
2873<p>trim(&#x201c;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d;, &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;)</p>
2874</li>
2875<li>
2876
2877<p>The expected result is (only woman and girl are left in the family):</p>
2878
2879<div>
2880<div>
2881<pre class="source"> &quot;&#x1f469;&#x200d;&#x1f467;&quot;
2882</pre></div></div>
2883</li>
2884</ul></div>
2885<div class="section">
2886<h3><a name="upper"></a>upper</h3>
2887<ul>
2888
2889<li>
2890
2891<p>Syntax:</p>
2892
2893<div>
2894<div>
2895<pre class="source">upper(string)
2896</pre></div></div>
2897</li>
2898<li>
2899
2900<p>Converts a given string <tt>string</tt> to its uppercase form.</p>
2901</li>
2902<li>Arguments:
2903<ul>
2904
2905<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
2906</ul>
2907</li>
2908<li>Return Value:
2909<ul>
2910
2911<li>a <tt>string</tt> as the uppercase form of the given <tt>string</tt>,</li>
2912<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2913<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2914<li>any other non-string input value will cause a type error.</li>
2915</ul>
2916</li>
2917<li>
2918
2919<p>Example:</p>
2920
2921<div>
2922<div>
2923<pre class="source">upper(&quot;hello&quot;)
2924</pre></div></div>
2925</li>
2926<li>
2927
2928<p>The expected result is:</p>
2929
2930<div>
2931<div>
2932<pre class="source">&quot;HELLO&quot;
2933</pre></div></div>
2934</li>
2935</ul><!--
2936 ! Licensed to the Apache Software Foundation (ASF) under one
2937 ! or more contributor license agreements. See the NOTICE file
2938 ! distributed with this work for additional information
2939 ! regarding copyright ownership. The ASF licenses this file
2940 ! to you under the Apache License, Version 2.0 (the
2941 ! "License"); you may not use this file except in compliance
2942 ! with the License. You may obtain a copy of the License at
2943 !
2944 ! http://www.apache.org/licenses/LICENSE-2.0
2945 !
2946 ! Unless required by applicable law or agreed to in writing,
2947 ! software distributed under the License is distributed on an
2948 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2949 ! KIND, either express or implied. See the License for the
2950 ! specific language governing permissions and limitations
2951 ! under the License.
2952 !-->
2953</div>
2954<div class="section">
2955<h3><a name="string_concat"></a>string_concat</h3>
2956<ul>
2957
2958<li>
2959
2960<p>Syntax:</p>
2961
2962<div>
2963<div>
2964<pre class="source">string_concat(array)
2965</pre></div></div>
2966</li>
2967<li>
2968
2969<p>Concatenates an array of strings <tt>array</tt> into a single string.</p>
2970</li>
2971<li>Arguments:
2972<ul>
2973
2974<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of <tt>string</tt>s (could be <tt>null</tt> or <tt>missing</tt>) to be concatenated.</li>
2975</ul>
2976</li>
2977<li>Return Value:
2978<ul>
2979
2980<li>the concatenated <tt>string</tt> value,</li>
2981<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2982<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2983<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
2984<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
2985<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
2986</ul>
2987</li>
2988<li>
2989
2990<p>Example:</p>
2991
2992<div>
2993<div>
2994<pre class="source">string_concat([&quot;ASTERIX&quot;, &quot; &quot;, &quot;ROCKS!&quot;]);
2995</pre></div></div>
2996</li>
2997<li>
2998
2999<p>The expected result is:</p>
3000
3001<div>
3002<div>
3003<pre class="source">&quot;ASTERIX ROCKS!&quot;
3004</pre></div></div>
3005</li>
3006</ul></div>
3007<div class="section">
3008<h3><a name="string_join"></a>string_join</h3>
3009<ul>
3010
3011<li>
3012
3013<p>Syntax:</p>
3014
3015<div>
3016<div>
3017<pre class="source">string_join(array, string)
3018</pre></div></div>
3019</li>
3020<li>
3021
3022<p>Joins an array or multiset of strings <tt>array</tt> with the given separator <tt>string</tt> into a single string.</p>
3023</li>
3024<li>Arguments:
3025<ul>
3026
3027<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of strings (could be <tt>null</tt>) to be joined.</li>
3028<li><tt>string</tt> : a <tt>string</tt> to serve as the separator.</li>
3029</ul>
3030</li>
3031<li>Return Value:
3032<ul>
3033
3034<li>the joined <tt>string</tt>,</li>
3035<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3036<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3037<li><tt>missing</tt> if the first argument array contains a <tt>missing</tt>,</li>
3038<li><tt>null</tt> if the first argument array contains a <tt>null</tt> but does not contain a <tt>missing</tt>,</li>
3039<li>a type error will be raised if:
3040<ul>
3041
3042<li>the first argument is any other non-array value, or contains any other non-string value,</li>
3043<li>or, the second argument is any other non-string value.</li>
3044</ul>
3045</li>
3046</ul>
3047</li>
3048<li>
3049
3050<p>Example:</p>
3051
3052<div>
3053<div>
3054<pre class="source">string_join([&quot;ASTERIX&quot;, &quot;ROCKS~&quot;], &quot;!! &quot;);
3055</pre></div></div>
3056</li>
3057<li>
3058
3059<p>The expected result is:</p>
3060
3061<div>
3062<div>
3063<pre class="source">&quot;ASTERIX!! ROCKS~&quot;
3064</pre></div></div>
3065</li>
3066</ul></div>
3067<div class="section">
3068<h3><a name="string_to_codepoint"></a>string_to_codepoint</h3>
3069<ul>
3070
3071<li>
3072
3073<p>Syntax:</p>
3074
3075<div>
3076<div>
3077<pre class="source">string_to_codepoint(string)
3078</pre></div></div>
3079</li>
3080<li>
3081
3082<p>Converts the string <tt>string</tt> to its code_based representation.</p>
3083</li>
3084<li>Arguments:
3085<ul>
3086
3087<li><tt>string</tt> : a <tt>string</tt> that will be converted.</li>
3088</ul>
3089</li>
3090<li>Return Value:
3091<ul>
3092
3093<li>an <tt>array</tt> of the code points for the string <tt>string</tt>,</li>
3094<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3095<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3096<li>any other non-string input value will cause a type error.</li>
3097</ul>
3098</li>
3099<li>
3100
3101<p>Example:</p>
3102
3103<div>
3104<div>
3105<pre class="source">string_to_codepoint(&quot;Hello ASTERIX!&quot;);
3106</pre></div></div>
3107</li>
3108<li>
3109
3110<p>The expected result is:</p>
3111
3112<div>
3113<div>
3114<pre class="source">[ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ]
3115</pre></div></div>
3116</li>
3117</ul></div>
3118<div class="section">
3119<h3><a name="codepoint_to_string"></a>codepoint_to_string</h3>
3120<ul>
3121
3122<li>
3123
3124<p>Syntax:</p>
3125
3126<div>
3127<div>
3128<pre class="source">codepoint_to_string(array)
3129</pre></div></div>
3130</li>
3131<li>
3132
3133<p>Converts the ordered code_based representation <tt>array</tt> to the corresponding string.</p>
3134</li>
3135<li>Arguments:
3136<ul>
3137
3138<li><tt>array</tt> : an <tt>array</tt> of integer code_points.</li>
3139</ul>
3140</li>
3141<li>Return Value:
3142<ul>
3143
3144<li>a <tt>string</tt> representation of <tt>array</tt>.</li>
3145<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3146<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3147<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3148<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
3149<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
3150</ul>
3151</li>
3152<li>
3153
3154<p>Example:</p>
3155
3156<div>
3157<div>
3158<pre class="source">codepoint_to_string([72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33]);
3159</pre></div></div>
3160</li>
3161<li>
3162
3163<p>The expected result is:</p>
3164
3165<div>
3166<div>
3167<pre class="source">&quot;Hello ASTERIX!&quot;
3168</pre></div></div>
3169</li>
3170</ul></div>
3171<div class="section">
3172<h3><a name="substring_before"></a>substring_before</h3>
3173<ul>
3174
3175<li>
3176
3177<p>Syntax:</p>
3178
3179<div>
3180<div>
3181<pre class="source">substring_before(string, string_pattern)
3182</pre></div></div>
3183</li>
3184<li>
3185
3186<p>Returns the substring from the given string <tt>string</tt> before the given pattern <tt>string_pattern</tt>.</p>
3187</li>
3188<li>Arguments:
3189<ul>
3190
3191<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3192<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3193</ul>
3194</li>
3195<li>Return Value:
3196<ul>
3197
3198<li>a <tt>string</tt> that represents the substring,</li>
3199<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3200<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3201<li>any other non-string input value will cause a type error.</li>
3202</ul>
3203</li>
3204<li>
3205
3206<p>Example:</p>
3207
3208<div>
3209<div>
3210<pre class="source">substring_before(&quot; like x-phone&quot;, &quot;x-phone&quot;);
3211</pre></div></div>
3212</li>
3213<li>
3214
3215<p>The expected result is:</p>
3216
3217<div>
3218<div>
3219<pre class="source">&quot; like &quot;
3220</pre></div></div>
3221</li>
3222</ul></div>
3223<div class="section">
3224<h3><a name="substring_after"></a>substring_after</h3>
3225<ul>
3226
3227<li>
3228
3229<p>Syntax:</p>
3230<p>substring_after(string, string_pattern);</p>
3231</li>
3232<li>
3233
3234<p>Returns the substring from the given string <tt>string</tt> after the given pattern <tt>string_pattern</tt>.</p>
3235</li>
3236<li>Arguments:
3237<ul>
3238
3239<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3240<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3241</ul>
3242</li>
3243<li>Return Value:
3244<ul>
3245
3246<li>a <tt>string</tt> that represents the substring,</li>
3247<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3248<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3249<li>any other non-string input value will cause a type error.</li>
3250</ul>
3251</li>
3252<li>
3253
3254<p>Example:</p>
3255
3256<div>
3257<div>
3258<pre class="source">substring_after(&quot; like x-phone&quot;, &quot;xph&quot;);
3259</pre></div></div>
3260</li>
3261<li>
3262
3263<p>The expected result is:</p>
3264
3265<div>
3266<div>
3267<pre class="source">&quot;one&quot;
3268</pre></div></div>
3269</li>
3270</ul><!--
3271 ! Licensed to the Apache Software Foundation (ASF) under one
3272 ! or more contributor license agreements. See the NOTICE file
3273 ! distributed with this work for additional information
3274 ! regarding copyright ownership. The ASF licenses this file
3275 ! to you under the Apache License, Version 2.0 (the
3276 ! "License"); you may not use this file except in compliance
3277 ! with the License. You may obtain a copy of the License at
3278 !
3279 ! http://www.apache.org/licenses/LICENSE-2.0
3280 !
3281 ! Unless required by applicable law or agreed to in writing,
3282 ! software distributed under the License is distributed on an
3283 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3284 ! KIND, either express or implied. See the License for the
3285 ! specific language governing permissions and limitations
3286 ! under the License.
3287 !-->
3288</div></div>
3289<div class="section">
3290<h2><a name="Binary_Functions"></a><a name="BinaryFunctions" id="BinaryFunctions">Binary Functions</a></h2>
3291<div class="section">
3292<h3><a name="parse_binary"></a>parse_binary</h3>
3293<ul>
3294
3295<li>
3296
3297<p>Syntax:</p>
3298<p>parse_binary(string, encoding)</p>
3299</li>
3300<li>
3301
3302<p>Creates a <tt>binary</tt> from an string encoded in <tt>encoding</tt> format.</p>
3303</li>
3304<li>Arguments:
3305<ul>
3306
3307<li><tt>string</tt> : an encoded <tt>string</tt>,</li>
3308<li><tt>encoding</tt> : a string notation specifies the encoding type of the given <tt>string</tt>. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
3309</ul>
3310</li>
3311<li>Return Value:
3312<ul>
3313
3314<li>a <tt>binary</tt> that is decoded from the given <tt>string</tt>,</li>
3315<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3316<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3317<li>any other non-string input value will cause a type error.</li>
3318</ul>
3319</li>
3320<li>
3321
3322<p>Example:</p>
3323<p>[ parse_binary(&#x201c;ABCDEF0123456789&#x201d;,&#x201c;hex&#x201d;), parse_binary(&#x201c;abcdef0123456789&#x201d;,&#x201c;HEX&#x201d;), parse_binary(&#x2018;QXN0ZXJpeAE=&#x2019;,&#x201c;base64&#x201d;) ];</p>
3324</li>
3325<li>
3326
3327<p>The expected result is:</p>
3328<p>[ hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;4173746572697801&#x201d;) ]</p>
3329</li>
3330</ul></div>
3331<div class="section">
3332<h3><a name="print_binary"></a>print_binary</h3>
3333<ul>
3334
3335<li>
3336
3337<p>Syntax:</p>
3338<p>print_binary(binary, encoding)</p>
3339</li>
3340<li>
3341
3342<p>Prints a <tt>binary</tt> to the required encoding <tt>string</tt> format.</p>
3343</li>
3344<li>Arguments:
3345<ul>
3346
3347<li><tt>binary</tt> : a <tt>binary</tt> data need to be printed.</li>
3348<li><tt>encoding</tt> : a string notation specifies the expected encoding type. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
3349</ul>
3350</li>
3351<li>Return Value:
3352<ul>
3353
3354<li>a <tt>string</tt> that represents the encoded format of a <tt>binary</tt>,</li>
3355<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3356<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3357<li>any other non-string input value will cause a type error.</li>
3358</ul>
3359</li>
3360<li>
3361
3362<p>Example:</p>
3363
3364<div>
3365<div>
3366<pre class="source">[ print_binary(hex(&quot;ABCDEF0123456789&quot;), &quot;base64&quot;), print_binary(base64(&quot;q83vASNFZ4k=&quot;), &quot;hex&quot;) ]
3367</pre></div></div>
3368</li>
3369<li>
3370
3371<p>The expected result are:</p>
3372
3373<div>
3374<div>
3375<pre class="source">[ &quot;q83vASNFZ4k=&quot;, &quot;ABCDEF0123456789&quot; ]
3376</pre></div></div>
3377</li>
3378</ul></div>
3379<div class="section">
3380<h3><a name="binary_length"></a>binary_length</h3>
3381<ul>
3382
3383<li>
3384
3385<p>Syntax:</p>
3386<p>binary_length(binary)</p>
3387</li>
3388<li>
3389
3390<p>Returns the number of bytes storing the binary data.</p>
3391</li>
3392<li>Arguments:
3393<ul>
3394
3395<li><tt>binary</tt> : a <tt>binary</tt> value to be checked.</li>
3396</ul>
3397</li>
3398<li>Return Value:
3399<ul>
3400
3401<li>an <tt>bigint</tt> that represents the number of bytes,</li>
3402<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3403<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3404<li>any other non-binary input value will cause a type error.</li>
3405</ul>
3406</li>
3407<li>
3408
3409<p>Example:</p>
3410
3411<div>
3412<div>
3413<pre class="source">binary_length(hex(&quot;00AA&quot;))
3414</pre></div></div>
3415</li>
3416<li>
3417
3418<p>The expected result is:</p>
3419<p>2</p>
3420</li>
3421</ul></div>
3422<div class="section">
3423<h3><a name="sub_binary"></a>sub_binary</h3>
3424<ul>
3425
3426<li>
3427
3428<p>Syntax:</p>
3429<p>sub_binary(binary, offset[, length])</p>
3430</li>
3431<li>
3432
3433<p>Returns the sub binary from the given <tt>binary</tt> based on the given start offset with the optional <tt>length</tt>.</p>
3434</li>
3435<li>Arguments:
3436<ul>
3437
3438<li><tt>binary</tt> : a <tt>binary</tt> to be extracted,</li>
3439<li><tt>offset</tt> : a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> value as the starting offset of the sub binary in <tt>binary</tt> (starting at 0),</li>
3440<li><tt>length</tt> : (Optional) a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> value as the length of the sub binary.</li>
3441</ul>
3442</li>
3443<li>Return Value:
3444<ul>
3445
3446<li>a <tt>binary</tt> that represents the sub binary,</li>
3447<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3448<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3449<li>a type error will be raised if:
3450<ul>
3451
3452<li>the first argument is any other non-binary value,</li>
3453<li>or, the second argument is any other non-integer value,</li>
3454<li>or, the third argument is any other non-integer value, if it is present.</li>
3455</ul>
3456</li>
3457</ul>
3458</li>
3459<li>
3460
3461<p>Example:</p>
3462
3463<div>
3464<div>
3465<pre class="source">sub_binary(hex(&quot;AABBCCDD&quot;), 4);
3466</pre></div></div>
3467</li>
3468<li>
3469
3470<p>The expected result is</p>
3471
3472<div>
3473<div>
3474<pre class="source">hex(&quot;DD&quot;)
3475</pre></div></div>
3476</li>
3477</ul></div>
3478<div class="section">
3479<h3><a name="binary_concat"></a>binary_concat</h3>
3480<ul>
3481
3482<li>
3483
3484<p>Syntax:</p>
3485<p>binary_concat(array)</p>
3486</li>
3487<li>
3488
3489<p>Concatenates a binary <tt>array</tt> or <tt>multiset</tt> into a single binary.</p>
3490</li>
3491<li>Arguments:
3492<ul>
3493
3494<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of binaries (could be <tt>null</tt> or <tt>missing</tt>) to be concatenated.</li>
3495</ul>
3496</li>
3497<li>Return Value :
3498<ul>
3499
3500<li>the concatenated <tt>binary</tt> value,</li>
3501<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3502<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3503<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3504<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
3505<li>any other non-array input value or non-binary element in the input array will cause a type error.</li>
3506</ul>
3507</li>
3508<li>
3509
3510<p>Example:</p>
3511<p>binary_concat([hex(&#x201c;42&#x201d;), hex(&quot;&quot;), hex(&#x2018;42&#x2019;)]);</p>
3512</li>
3513<li>
3514
3515<p>The expected result is</p>
3516<p>hex(&#x201c;4242&#x201d;)</p>
3517</li>
3518</ul><!--
3519 ! Licensed to the Apache Software Foundation (ASF) under one
3520 ! or more contributor license agreements. See the NOTICE file
3521 ! distributed with this work for additional information
3522 ! regarding copyright ownership. The ASF licenses this file
3523 ! to you under the Apache License, Version 2.0 (the
3524 ! "License"); you may not use this file except in compliance
3525 ! with the License. You may obtain a copy of the License at
3526 !
3527 ! http://www.apache.org/licenses/LICENSE-2.0
3528 !
3529 ! Unless required by applicable law or agreed to in writing,
3530 ! software distributed under the License is distributed on an
3531 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3532 ! KIND, either express or implied. See the License for the
3533 ! specific language governing permissions and limitations
3534 ! under the License.
3535 !-->
3536</div></div>
3537<div class="section">
3538<h2><a name="Spatial_Functions"></a><a name="SpatialFunctions" id="SpatialFunctions">Spatial Functions</a></h2>
3539<div class="section">
3540<h3><a name="create_point"></a>create_point</h3>
3541<ul>
3542
3543<li>
3544
3545<p>Syntax:</p>
3546
3547<div>
3548<div>
3549<pre class="source">create_point(x, y)
3550</pre></div></div>
3551</li>
3552<li>
3553
3554<p>Creates the primitive type <tt>point</tt> using an <tt>x</tt> and <tt>y</tt> value.</p>
3555</li>
3556<li>Arguments:</li>
3557<li><tt>x</tt> : a <tt>double</tt> that represents the x-coordinate,</li>
3558<li><tt>y</tt> : a <tt>double</tt> that represents the y-coordinate.</li>
3559<li>Return Value:</li>
3560<li>a <tt>point</tt> representing the ordered pair (<tt>x</tt>, <tt>y</tt>),</li>
3561<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3562<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3563<li>any other non-double input value will cause a type error.</li>
3564<li>
3565
3566<p>Example:</p>
3567
3568<div>
3569<div>
3570<pre class="source">{ &quot;point&quot;: create_point(30.0,70.0) };
3571</pre></div></div>
3572</li>
3573<li>
3574
3575<p>The expected result is:</p>
3576
3577<div>
3578<div>
3579<pre class="source">{ &quot;point&quot;: point(&quot;30.0,70.0&quot;) }
3580</pre></div></div>
3581</li>
3582</ul></div>
3583<div class="section">
3584<h3><a name="create_line"></a>create_line</h3>
3585<ul>
3586
3587<li>
3588
3589<p>Syntax:</p>
3590
3591<div>
3592<div>
3593<pre class="source">create_line(point1, point2)
3594</pre></div></div>
3595</li>
3596<li>
3597
3598<p>Creates the primitive type <tt>line</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3599</li>
3600<li>Arguments:
3601<ul>
3602
3603<li><tt>point1</tt> : a <tt>point</tt> that represents the start point of the line.</li>
3604<li><tt>point2</tt> : a <tt>point</tt> that represents the end point of the line.</li>
3605</ul>
3606</li>
3607<li>Return Value:
3608<ul>
3609
3610<li>a spatial <tt>line</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3611<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3612<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3613<li>any other non-point input value will cause a type error.</li>
3614</ul>
3615</li>
3616<li>
3617
3618<p>Example:</p>
3619
3620<div>
3621<div>
3622<pre class="source">{ &quot;line&quot;: create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
3623</pre></div></div>
3624</li>
3625<li>
3626
3627<p>The expected result is:</p>
3628
3629<div>
3630<div>
3631<pre class="source">{ &quot;line&quot;: line(&quot;30.0,70.0 50.0,90.0&quot;) }
3632</pre></div></div>
3633</li>
3634</ul></div>
3635<div class="section">
3636<h3><a name="create_rectangle"></a>create_rectangle</h3>
3637<ul>
3638
3639<li>
3640
3641<p>Syntax:</p>
3642
3643<div>
3644<div>
3645<pre class="source">create_rectangle(point1, point2)
3646</pre></div></div>
3647</li>
3648<li>
3649
3650<p>Creates the primitive type <tt>rectangle</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3651</li>
3652<li>Arguments:
3653<ul>
3654
3655<li><tt>point1</tt> : a <tt>point</tt> that represents the lower_left point of the rectangle.</li>
3656<li><tt>point2</tt> : a <tt>point</tt> that represents the upper_right point of the rectangle.</li>
3657</ul>
3658</li>
3659<li>Return Value:
3660<ul>
3661
3662<li>a spatial <tt>rectangle</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3663<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3664<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3665<li>any other non-point input value will cause a type error.</li>
3666</ul>
3667</li>
3668<li>
3669
3670<p>Example:</p>
3671
3672<div>
3673<div>
3674<pre class="source">{ &quot;rectangle&quot;: create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
3675</pre></div></div>
3676</li>
3677<li>
3678
3679<p>The expected result is:</p>
3680
3681<div>
3682<div>
3683<pre class="source">{ &quot;rectangle&quot;: rectangle(&quot;30.0,70.0 50.0,90.0&quot;) }
3684</pre></div></div>
3685</li>
3686</ul></div>
3687<div class="section">
3688<h3><a name="create_circle"></a>create_circle</h3>
3689<ul>
3690
3691<li>
3692
3693<p>Syntax:</p>
3694
3695<div>
3696<div>
3697<pre class="source">create_circle(point, radius)
3698</pre></div></div>
3699</li>
3700<li>
3701
3702<p>Creates the primitive type <tt>circle</tt> using <tt>point</tt> and <tt>radius</tt>.</p>
3703</li>
3704<li>Arguments:
3705<ul>
3706
3707<li><tt>point</tt> : a <tt>point</tt> that represents the center of the circle.</li>
3708<li><tt>radius</tt> : a <tt>double</tt> that represents the radius of the circle.</li>
3709</ul>
3710</li>
3711<li>Return Value:
3712<ul>
3713
3714<li>a spatial <tt>circle</tt> created using the center point and the radius provided in <tt>point</tt> and <tt>radius</tt>.</li>
3715<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3716<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3717<li>a type error will be raised if:
3718<ul>
3719
3720<li>the first argument is any other non-point value,</li>
3721<li>or, the second argument is any other non-double value.</li>
3722</ul>
3723</li>
3724</ul>
3725</li>
3726<li>
3727
3728<p>Example:</p>
3729
3730<div>
3731<div>
3732<pre class="source">{ &quot;circle&quot;: create_circle(create_point(30.0,70.0), 5.0) }
3733</pre></div></div>
3734</li>
3735<li>
3736
3737<p>The expected result is:</p>
3738
3739<div>
3740<div>
3741<pre class="source">{ &quot;circle&quot;: circle(&quot;30.0,70.0 5.0&quot;) }
3742</pre></div></div>
3743</li>
3744</ul></div>
3745<div class="section">
3746<h3><a name="create_polygon"></a>create_polygon</h3>
3747<ul>
3748
3749<li>
3750
3751<p>Syntax:</p>
3752
3753<div>
3754<div>
3755<pre class="source">create_polygon(array)
3756</pre></div></div>
3757</li>
3758<li>
3759
3760<p>Creates the primitive type <tt>polygon</tt> using the double values provided in the argument <tt>array</tt>. Each two consecutive double values represent a point starting from the first double value in the array. Note that at least six double values should be specified, meaning a total of three points.</p>
3761</li>
3762<li>Arguments:
3763<ul>
3764
3765<li><tt>array</tt> : an array of doubles representing the points of the polygon.</li>
3766</ul>
3767</li>
3768<li>Return Value:
3769<ul>
3770
3771<li>a <tt>polygon</tt>, represents a spatial simple polygon created using the points provided in <tt>array</tt>.</li>
3772<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3773<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3774<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3775<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
3776<li>any other non-array input value or non-double element in the input array will cause a type error.</li>
3777</ul>
3778</li>
3779<li>
3780
3781<p>Example:</p>
3782
3783<div>
3784<div>
3785<pre class="source">{ &quot;polygon&quot;: create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
3786</pre></div></div>
3787</li>
3788<li>
3789
3790<p>The expected result is:</p>
3791
3792<div>
3793<div>
3794<pre class="source">{ &quot;polygon&quot;: polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;) }
3795</pre></div></div>
3796</li>
3797</ul></div>
3798<div class="section">
3799<h3><a name="get_x.2Fget_y"></a>get_x/get_y</h3>
3800<ul>
3801
3802<li>
3803
3804<p>Syntax:</p>
3805
3806<div>
3807<div>
3808<pre class="source">get_x(point) or get_y(point)
3809</pre></div></div>
3810</li>
3811<li>
3812
3813<p>Returns the x or y coordinates of a point <tt>point</tt>.</p>
3814</li>
3815<li>Arguments:
3816<ul>
3817
3818<li><tt>point</tt> : a <tt>point</tt>.</li>
3819</ul>
3820</li>
3821<li>Return Value:
3822<ul>
3823
3824<li>a <tt>double</tt> representing the x or y coordinates of the point <tt>point</tt>,</li>
3825<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3826<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3827<li>any other non-point input value will cause a type error.</li>
3828</ul>
3829</li>
3830<li>
3831
3832<p>Example:</p>
3833
3834<div>
3835<div>
3836<pre class="source">{ &quot;x_coordinate&quot;: get_x(create_point(2.3,5.0)), &quot;y_coordinate&quot;: get_y(create_point(2.3,5.0)) };
3837</pre></div></div>
3838</li>
3839<li>
3840
3841<p>The expected result is:</p>
3842
3843<div>
3844<div>
3845<pre class="source">{ &quot;x_coordinate&quot;: 2.3, &quot;y_coordinate&quot;: 5.0 }
3846</pre></div></div>
3847</li>
3848</ul></div>
3849<div class="section">
3850<h3><a name="get_points"></a>get_points</h3>
3851<ul>
3852
3853<li>
3854
3855<p>Syntax:</p>
3856
3857<div>
3858<div>
3859<pre class="source">get_points(spatial_object)
3860</pre></div></div>
3861</li>
3862<li>
3863
3864<p>Returns an ordered array of the points forming the spatial object <tt>spatial_object</tt>.</p>
3865</li>
3866<li>Arguments:
3867<ul>
3868
3869<li><tt>spatial_object</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3870</ul>
3871</li>
3872<li>Return Value:
3873<ul>
3874
3875<li>an <tt>array</tt> of the points forming the spatial object <tt>spatial_object</tt>,</li>
3876<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3877<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3878<li>any other non-spatial-object input value will cause a type error.</li>
3879</ul>
3880</li>
3881<li>
3882
3883<p>Example:</p>
3884
3885<div>
3886<div>
3887<pre class="source">get_points(create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]))
3888</pre></div></div>
3889</li>
3890<li>
3891
3892<p>The expected result is:</p>
3893
3894<div>
3895<div>
3896<pre class="source">[ point(&quot;1.0,1.0&quot;), point(&quot;2.0,2.0&quot;), point(&quot;3.0,3.0&quot;), point(&quot;4.0,4.0&quot;) ]
3897</pre></div></div>
3898</li>
3899</ul></div>
3900<div class="section">
3901<h3><a name="get_center.2Fget_radius"></a>get_center/get_radius</h3>
3902<ul>
3903
3904<li>
3905
3906<p>Syntax:</p>
3907
3908<div>
3909<div>
3910<pre class="source">get_center(circle_expression) or get_radius(circle_expression)
3911</pre></div></div>
3912</li>
3913<li>
3914
3915<p>Returns the center and the radius of a circle <tt>circle_expression</tt>, respectively.</p>
3916</li>
3917<li>Arguments:
3918<ul>
3919
3920<li><tt>circle_expression</tt> : a <tt>circle</tt>.</li>
3921</ul>
3922</li>
3923<li>Return Value:
3924<ul>
3925
3926<li>a <tt>point</tt> or <tt>double</tt>, represent the center or radius of the circle <tt>circle_expression</tt>.</li>
3927<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3928<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3929<li>any other non-circle input value will cause a type error.</li>
3930</ul>
3931</li>
3932<li>
3933
3934<p>Example:</p>
3935
3936<div>
3937<div>
3938<pre class="source">{
3939 &quot;circle_radius&quot;: get_radius(create_circle(create_point(6.0,3.0), 1.0)),
3940 &quot;circle_center&quot;: get_center(create_circle(create_point(6.0,3.0), 1.0))
3941};
3942</pre></div></div>
3943</li>
3944<li>
3945
3946<p>The expected result is:</p>
3947
3948<div>
3949<div>
3950<pre class="source">{ &quot;circle_radius&quot;: 1.0, &quot;circle_center&quot;: point(&quot;6.0,3.0&quot;) }
3951</pre></div></div>
3952</li>
3953</ul></div>
3954<div class="section">
3955<h3><a name="spatial_distance"></a>spatial_distance</h3>
3956<ul>
3957
3958<li>
3959
3960<p>Syntax:</p>
3961
3962<div>
3963<div>
3964<pre class="source">spatial_distance(point1, point2)
3965</pre></div></div>
3966</li>
3967<li>
3968
3969<p>Returns the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</p>
3970</li>
3971<li>Arguments:
3972<ul>
3973
3974<li><tt>point1</tt> : a <tt>point</tt>.</li>
3975<li><tt>point2</tt> : a <tt>point</tt>.</li>
3976</ul>
3977</li>
3978<li>Return Value:
3979<ul>
3980
3981<li>a <tt>double</tt> as the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</li>
3982<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3983<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3984<li>any other non-point input value will cause a type error.</li>
3985</ul>
3986</li>
3987<li>
3988
3989<p>Example:</p>
3990
3991<div>
3992<div>
3993<pre class="source">spatial_distance(point(&quot;47.44,80.65&quot;), create_point(30.0,70.0));
3994</pre></div></div>
3995</li>
3996<li>
3997
3998<p>The expected result is:</p>
3999
4000<div>
4001<div>
4002<pre class="source">20.434678857275934
4003</pre></div></div>
4004</li>
4005</ul></div>
4006<div class="section">
4007<h3><a name="spatial_area"></a>spatial_area</h3>
4008<ul>
4009
4010<li>
4011
4012<p>Syntax:</p>
4013
4014<div>
4015<div>
4016<pre class="source">spatial_area(spatial_2d_expression)
4017</pre></div></div>
4018</li>
4019<li>
4020
4021<p>Returns the spatial area of <tt>spatial_2d_expression</tt>.</p>
4022</li>
4023<li>Arguments:
4024<ul>
4025
4026<li><tt>spatial_2d_expression</tt> : a <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4027</ul>
4028</li>
4029<li>Return Value:
4030<ul>
4031
4032<li>a <tt>double</tt> representing the area of <tt>spatial_2d_expression</tt>.</li>
4033<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4034<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4035<li>any other non-2d-spatial-object will cause a type error.</li>
4036</ul>
4037</li>
4038<li>
4039
4040<p>Example:</p>
4041
4042<div>
4043<div>
4044<pre class="source">spatial_area(create_circle(create_point(0.0,0.0), 5.0));
4045</pre></div></div>
4046</li>
4047<li>
4048
4049<p>The expected result is:</p>
4050
4051<div>
4052<div>
4053<pre class="source">78.53981625
4054</pre></div></div>
4055</li>
4056</ul></div>
4057<div class="section">
4058<h3><a name="spatial_intersect"></a>spatial_intersect</h3>
4059<ul>
4060
4061<li>
4062
4063<p>Syntax:</p>
4064
4065<div>
4066<div>
4067<pre class="source">spatial_intersect(spatial_object1, spatial_object2)
4068</pre></div></div>
4069</li>
4070<li>
4071
4072<p>Checks whether <tt>@arg1</tt> and <tt>@arg2</tt> spatially intersect each other.</p>
4073</li>
4074<li>Arguments:
4075<ul>
4076
4077<li><tt>spatial_object1</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4078<li><tt>spatial_object2</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4079</ul>
4080</li>
4081<li>Return Value:
4082<ul>
4083
4084<li>a <tt>boolean</tt> representing whether <tt>spatial_object1</tt> and <tt>spatial_object2</tt> spatially overlap with each other,</li>
4085<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4086<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4087<li>any other non-spatial-object input value will cause a type error.</li>
4088</ul>
4089</li>
4090<li>
4091
4092<p>Example:</p>
4093
4094<div>
4095<div>
4096<pre class="source">spatial_intersect(point(&quot;39.28,70.48&quot;), create_rectangle(create_point(30.0,70.0), create_point(40.0,80.0)));
4097</pre></div></div>
4098</li>
4099<li>
4100
4101<p>The expected result is:</p>
4102
4103<div>
4104<div>
4105<pre class="source">true
4106</pre></div></div>
4107</li>
4108</ul></div>
4109<div class="section">
4110<h3><a name="spatial_cell"></a>spatial_cell</h3>
4111<ul>
4112
4113<li>
4114
4115<p>Syntax:</p>
4116
4117<div>
4118<div>
4119<pre class="source">spatial_cell(point1, point2, x_increment, y_increment)
4120</pre></div></div>
4121</li>
4122<li>
4123
4124<p>Returns the grid cell that <tt>point1</tt> belongs to.</p>
4125</li>
4126<li>Arguments:
4127<ul>
4128
4129<li><tt>point1</tt> : a <tt>point</tt> representing the point of interest that its grid cell will be returned.</li>
4130<li><tt>point2</tt> : a <tt>point</tt> representing the origin of the grid.</li>
4131<li><tt>x_increment</tt> : a <tt>double</tt>, represents X increments.</li>
4132<li><tt>y_increment</tt> : a <tt>double</tt>, represents Y increments.</li>
4133</ul>
4134</li>
4135<li>Return Value:
4136<ul>
4137
4138<li>a <tt>rectangle</tt> representing the grid cell that <tt>point1</tt> belongs to,</li>
4139<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4140<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4141<li>a type error will be raised if:
4142<ul>
4143
4144<li>the first or second argument is any other non-point value,</li>
4145<li>or, the second or third argument is any other non-double value.</li>
4146</ul>
4147</li>
4148</ul>
4149</li>
4150<li>
4151
4152<p>Example:</p>
4153
4154<div>
4155<div>
4156<pre class="source">spatial_cell(point(&quot;39.28,70.48&quot;), create_point(20.0,50.0), 5.5, 6.0);
4157</pre></div></div>
4158</li>
4159<li>
4160
4161<p>The expected result is:</p>
4162
4163<div>
4164<div>
4165<pre class="source">rectangle(&quot;36.5,68.0 42.0,74.0&quot;);
4166</pre></div></div>
4167</li>
4168</ul><!--
4169 ! Licensed to the Apache Software Foundation (ASF) under one
4170 ! or more contributor license agreements. See the NOTICE file
4171 ! distributed with this work for additional information
4172 ! regarding copyright ownership. The ASF licenses this file
4173 ! to you under the Apache License, Version 2.0 (the
4174 ! "License"); you may not use this file except in compliance
4175 ! with the License. You may obtain a copy of the License at
4176 !
4177 ! http://www.apache.org/licenses/LICENSE-2.0
4178 !
4179 ! Unless required by applicable law or agreed to in writing,
4180 ! software distributed under the License is distributed on an
4181 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4182 ! KIND, either express or implied. See the License for the
4183 ! specific language governing permissions and limitations
4184 ! under the License.
4185 !-->
4186</div></div>
4187<div class="section">
4188<h2><a name="Similarity_Functions"></a><a name="SimilarityFunctions" id="SimilarityFunctions">Similarity Functions</a></h2>
4189<p>AsterixDB supports queries with different similarity functions, including <a class="externalLink" href="http://en.wikipedia.org/wiki/Levenshtein_distance">edit distance</a> and <a class="externalLink" href="https://en.wikipedia.org/wiki/Jaccard_index">Jaccard</a>.</p>
4190<div class="section">
4191<h3><a name="edit_distance"></a>edit_distance</h3>
4192<ul>
4193
4194<li>
4195
4196<p>Syntax:</p>
4197
4198<div>
4199<div>
4200<pre class="source">edit_distance(expression1, expression2)
4201</pre></div></div>
4202</li>
4203<li>
4204
4205<p>Returns the edit distance of <tt>expression1</tt> and <tt>expression2</tt>.</p>
4206</li>
4207<li>Arguments:
4208<ul>
4209
4210<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4211<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4212</ul>
4213</li>
4214<li>Return Value:
4215<ul>
4216
4217<li>an <tt>bigint</tt> that represents the edit distance between <tt>expression1</tt> and <tt>expression2</tt>,</li>
4218<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4219<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4220<li>any other non-string input value will cause a type error.</li>
4221</ul>
4222</li>
4223<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4224<li>Example:
4225
4226<div>
4227<div>
4228<pre class="source">edit_distance(&quot;SuzannaTillson&quot;, &quot;Suzanna Tilson&quot;);
4229</pre></div></div>
4230</li>
4231<li>
4232
4233<p>The expected result is:</p>
4234
4235<div>
4236<div>
4237<pre class="source">2
4238</pre></div></div>
4239</li>
4240</ul></div>
4241<div class="section">
4242<h3><a name="edit_distance_check"></a>edit_distance_check</h3>
4243<ul>
4244
4245<li>
4246
4247<p>Syntax:</p>
4248
4249<div>
4250<div>
4251<pre class="source">edit_distance_check(expression1, expression2, threshold)
4252</pre></div></div>
4253</li>
4254<li>
4255
4256<p>Checks whether the edit distance of <tt>expression1</tt> and <tt>expression2</tt> is within a given threshold.</p>
4257</li>
4258<li>
4259
4260<p>Arguments:</p>
4261<ul>
4262
4263<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4264<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4265<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4266</ul>
4267</li>
4268<li>Return Value:
4269<ul>
4270
4271<li>an <tt>array</tt> with two items:
4272<ul>
4273
4274<li>The first item contains a <tt>boolean</tt> value representing whether the edit distance of <tt>expression1</tt> and <tt>expression2</tt> is within the given threshold.</li>
4275<li>The second item contains an <tt>integer</tt> that represents the edit distance of <tt>expression1</tt> and <tt>expression2</tt> if the first item is true.</li>
4276<li>If the first item is false, then the second item is set to 2147483647.</li>
4277</ul>
4278</li>
4279<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4280<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4281<li>a type error will be raised if:
4282<ul>
4283
4284<li>the first or second argument is any other non-string value,</li>
4285<li>or, the third argument is any other non-bigint value.</li>
4286</ul>
4287</li>
4288</ul>
4289</li>
4290<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4291<li>Example:
4292
4293<div>
4294<div>
4295<pre class="source">edit_distance_check(&quot;happy&quot;,&quot;hapr&quot;,2);
4296</pre></div></div>
4297</li>
4298<li>
4299
4300<p>The expected result is:</p>
4301
4302<div>
4303<div>
4304<pre class="source">[ true, 2 ]
4305</pre></div></div>
4306</li>
4307</ul></div>
4308<div class="section">
4309<h3><a name="edit_distance_contains"></a>edit_distance_contains</h3>
4310<ul>
4311
4312<li>
4313
4314<p>Syntax:</p>
4315
4316<div>
4317<div>
4318<pre class="source">edit_distance_contains(expression1, expression2, threshold)
4319</pre></div></div>
4320</li>
4321<li>
4322
4323<p>Checks whether <tt>expression1</tt> contains <tt>expression2</tt> with an <a class="externalLink" href="http://en.wikipedia.org/wiki/Levenshtein_distance">edit distance</a> within a given threshold.</p>
4324</li>
4325<li>
4326
4327<p>Arguments:</p>
4328<ul>
4329
4330<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4331<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4332<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4333</ul>
4334</li>
4335<li>Return Value:
4336<ul>
4337
4338<li>an <tt>array</tt> with two items:
4339<ul>
4340
4341<li>The first item contains a <tt>boolean</tt> value representing whether <tt>expression1</tt> can contain <tt>expression2</tt>.</li>
4342<li>The second item contains an <tt>integer</tt> that represents the required edit distance for <tt>expression1</tt> to contain <tt>expression2</tt> if the first item is true.</li>
4343</ul>
4344</li>
4345<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4346<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4347<li>a type error will be raised if:
4348<ul>
4349
4350<li>the first or second argument is any other non-string value,</li>
4351<li>or, the third argument is any other non-bigint value.</li>
4352</ul>
4353</li>
4354</ul>
4355</li>
4356<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4357<li>Example:
4358
4359<div>
4360<div>
4361<pre class="source">edit_distance_contains(&quot;happy&quot;,&quot;hapr&quot;,2);
4362</pre></div></div>
4363</li>
4364<li>
4365
4366<p>The expected result is:</p>
4367
4368<div>
4369<div>
4370<pre class="source">[ true, 1 ]
4371</pre></div></div>
4372</li>
4373</ul></div>
4374<div class="section">
4375<h3><a name="similarity_jaccard"></a>similarity_jaccard</h3>
4376<ul>
4377
4378<li>
4379
4380<p>Syntax:</p>
4381
4382<div>
4383<div>
4384<pre class="source">similarity_jaccard(array1, array2)
4385</pre></div></div>
4386</li>
4387<li>
4388
4389<p>Returns the <a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard similarity</a> of <tt>array1</tt> and <tt>array2</tt>.</p>
4390</li>
4391<li>Arguments:
4392<ul>
4393
4394<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4395<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4396</ul>
4397</li>
4398<li>Return Value:
4399<ul>
4400
4401<li>a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt>,</li>
4402<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4403<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4404<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4405<li><tt>null</tt> if any element in any input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
4406<li>any other non-array input value or non-integer element in any input array will cause a type error.</li>
4407</ul>
4408</li>
4409<li>
4410
4411<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4412</li>
4413<li>Example:
4414
4415<div>
4416<div>
4417<pre class="source">similarity_jaccard([1,5,8,9], [1,5,9,10]);
4418</pre></div></div>
4419</li>
4420<li>
4421
4422<p>The expected result is:</p>
4423
4424<div>
4425<div>
4426<pre class="source">0.6
4427</pre></div></div>
4428</li>
4429</ul></div>
4430<div class="section">
4431<h3><a name="similarity_jaccard_check"></a>similarity_jaccard_check</h3>
4432<ul>
4433
4434<li>
4435
4436<p>Syntax:</p>
4437
4438<div>
4439<div>
4440<pre class="source">similarity_jaccard_check(array1, array2, threshold)
4441</pre></div></div>
4442</li>
4443<li>
4444
4445<p>Checks whether <tt>array1</tt> and <tt>array2</tt> have a <a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard similarity</a> greater than or equal to threshold. Again, the &#x201c;check&#x201d; version of Jaccard is faster than the &#x201c;non_check&#x201d; version.</p>
4446</li>
4447<li>
4448
4449<p>Arguments:</p>
4450<ul>
4451
4452<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4453<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4454<li><tt>threshold</tt> : a <tt>double</tt> that represents the similarity threshold.</li>
4455</ul>
4456</li>
4457<li>Return Value:
4458<ul>
4459
4460<li>an <tt>array</tt> with two items:
4461<ul>
4462
4463<li>The first item contains a <tt>boolean</tt> value representing whether <tt>array1</tt> and <tt>array2</tt> are similar.</li>
4464<li>The second item contains a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt> if it is greater than or equal to the threshold, or 0 otherwise.</li>
4465</ul>
4466</li>
4467<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4468<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4469<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4470<li><tt>null</tt> if any element in any input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
4471<li>a type error will be raised if:
4472<ul>
4473
4474<li>the first or second argument is any other non-array value,
4475<ul>
4476
4477<li>or, the third argument is any other non-double value.</li>
4478</ul>
4479</li>
4480</ul>
4481</li>
4482</ul>
4483</li>
4484<li>
4485
4486<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4487</li>
4488<li>Example:
4489
4490<div>
4491<div>
4492<pre class="source">similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
4493</pre></div></div>
4494</li>
4495<li>
4496
4497<p>The expected result is:</p>
4498
4499<div>
4500<div>
4501<pre class="source">[ false, 0.0 ]
4502</pre></div></div>
4503</li>
4504</ul><!--
4505 ! Licensed to the Apache Software Foundation (ASF) under one
4506 ! or more contributor license agreements. See the NOTICE file
4507 ! distributed with this work for additional information
4508 ! regarding copyright ownership. The ASF licenses this file
4509 ! to you under the Apache License, Version 2.0 (the
4510 ! "License"); you may not use this file except in compliance
4511 ! with the License. You may obtain a copy of the License at
4512 !
4513 ! http://www.apache.org/licenses/LICENSE-2.0
4514 !
4515 ! Unless required by applicable law or agreed to in writing,
4516 ! software distributed under the License is distributed on an
4517 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4518 ! KIND, either express or implied. See the License for the
4519 ! specific language governing permissions and limitations
4520 ! under the License.
4521 !-->
4522</div></div>
4523<div class="section">
4524<h2><a name="Tokenizing_Functions"></a><a name="TokenizingFunctions" id="TokenizingFunctions">Tokenizing Functions</a></h2>
4525<div class="section">
4526<h3><a name="word_tokens"></a>word_tokens</h3>
4527<ul>
4528
4529<li>
4530
4531<p>Syntax:</p>
4532
4533<div>
4534<div>
4535<pre class="source">word_tokens(string)
4536</pre></div></div>
4537</li>
4538<li>
4539
4540<p>Returns an array of word tokens of <tt>string</tt> using non_alphanumeric characters as delimiters.</p>
4541</li>
4542<li>Arguments:
4543<ul>
4544
4545<li><tt>string</tt> : a <tt>string</tt> that will be tokenized.</li>
4546</ul>
4547</li>
4548<li>Return Value:
4549<ul>
4550
4551<li>an <tt>array</tt> of <tt>string</tt> word tokens,</li>
4552<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4553<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4554<li>any other non-string input value will cause a type error.</li>
4555</ul>
4556</li>
4557<li>
4558
4559<p>Example:</p>
4560
4561<div>
4562<div>
4563<pre class="source">word_tokens(&quot;I like the phone, awesome!&quot;);
4564</pre></div></div>
4565</li>
4566<li>
4567
4568<p>The expected result is:</p>
4569
4570<div>
4571<div>
4572<pre class="source">[ &quot;i&quot;, &quot;like&quot;, &quot;the&quot;, &quot;phone&quot;, &quot;awesome&quot; ]
4573</pre></div></div>
4574</li>
4575</ul><!--
4576 ! Licensed to the Apache Software Foundation (ASF) under one
4577 ! or more contributor license agreements. See the NOTICE file
4578 ! distributed with this work for additional information
4579 ! regarding copyright ownership. The ASF licenses this file
4580 ! to you under the Apache License, Version 2.0 (the
4581 ! "License"); you may not use this file except in compliance
4582 ! with the License. You may obtain a copy of the License at
4583 !
4584 ! http://www.apache.org/licenses/LICENSE-2.0
4585 !
4586 ! Unless required by applicable law or agreed to in writing,
4587 ! software distributed under the License is distributed on an
4588 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4589 ! KIND, either express or implied. See the License for the
4590 ! specific language governing permissions and limitations
4591 ! under the License.
4592 !-->
4593</div></div>
4594<div class="section">
4595<h2><a name="Temporal_Functions"></a><a name="TemporalFunctions" id="TemporalFunctions">Temporal Functions</a></h2>
4596<div class="section">
4597<h3><a name="get_year.2Fget_month.2Fget_day.2Fget_hour.2Fget_minute.2Fget_second.2Fget_millisecond"></a>get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond</h3>
4598<ul>
4599
4600<li>
4601
4602<p>Syntax:</p>
4603
4604<div>
4605<div>
4606<pre class="source">get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond(temporal_value)
4607</pre></div></div>
4608</li>
4609<li>
4610
4611<p>Accessors for accessing fields in a temporal value</p>
4612</li>
4613<li>Arguments:
4614<ul>
4615
4616<li><tt>temporal_value</tt> : a temporal value represented as one of the following types: <tt>date</tt>, <tt>datetime</tt>, <tt>time</tt>, and <tt>duration</tt>.</li>
4617</ul>
4618</li>
4619<li>Return Value:
4620<ul>
4621
4622<li>an <tt>bigint</tt> value representing the field to be extracted,</li>
4623<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4624<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4625<li>any other non-interval input value will cause a type error.</li>
4626</ul>
4627</li>
4628<li>
4629
4630<p>Example:</p>
4631
4632<div>
4633<div>
4634<pre class="source">{
4635 &quot;year&quot;: get_year(date(&quot;2010-10-30&quot;)),
4636 &quot;month&quot;: get_month(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4637 &quot;day&quot;: get_day(date(&quot;2010-10-30&quot;)),
4638 &quot;hour&quot;: get_hour(time(&quot;12:23:34.930+07:00&quot;)),
4639 &quot;min&quot;: get_minute(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;)),
4640 &quot;second&quot;: get_second(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4641 &quot;ms&quot;: get_millisecond(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;))
4642};
4643</pre></div></div>
4644</li>
4645<li>
4646
4647<p>The expected result is:</p>
4648
4649<div>
4650<div>
4651<pre class="source">{ &quot;year&quot;: 2010, &quot;month&quot;: 11, &quot;day&quot;: 30, &quot;hour&quot;: 5, &quot;min&quot;: 28, &quot;second&quot;: 23, &quot;ms&quot;: 94 }
4652</pre></div></div>
4653</li>
4654</ul></div>
4655<div class="section">
4656<h3><a name="adjust_datetime_for_timezone"></a>adjust_datetime_for_timezone</h3>
4657<ul>
4658
4659<li>
4660
4661<p>Syntax:</p>
4662
4663<div>
4664<div>
4665<pre class="source">adjust_datetime_for_timezone(datetime, string)
4666</pre></div></div>
4667</li>
4668<li>
4669
4670<p>Adjusts the given datetime <tt>datetime</tt> by applying the timezone information <tt>string</tt>.</p>
4671</li>
4672<li>Arguments:
4673<ul>
4674
4675<li><tt>datetime</tt> : a <tt>datetime</tt> value to be adjusted.</li>
4676<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4677</ul>
4678</li>
4679<li>Return Value:
4680<ul>
4681
4682<li>a <tt>string</tt> value representing the new datetime after being adjusted by the timezone information,</li>
4683<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4684<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4685<li>a type error will be raised if:
4686<ul>
4687
4688<li>the first argument is any other non-datetime value,</li>
4689<li>or, the second argument is any other non-string value.</li>
4690</ul>
4691</li>
4692</ul>
4693</li>
4694<li>
4695
4696<p>Example:</p>
4697
4698<div>
4699<div>
4700<pre class="source">adjust_datetime_for_timezone(datetime(&quot;2008-04-26T10:10:00&quot;), &quot;+08:00&quot;);
4701</pre></div></div>
4702</li>
4703<li>
4704
4705<p>The expected result is:</p>
4706
4707<div>
4708<div>
4709<pre class="source">&quot;2008-04-26T18:10:00.000+08:00&quot;
4710</pre></div></div>
4711</li>
4712</ul></div>
4713<div class="section">
4714<h3><a name="adjust_time_for_timezone"></a>adjust_time_for_timezone</h3>
4715<ul>
4716
4717<li>
4718
4719<p>Syntax:</p>
4720
4721<div>
4722<div>
4723<pre class="source">adjust_time_for_timezone(time, string)
4724</pre></div></div>
4725</li>
4726<li>
4727
4728<p>Adjusts the given time <tt>time</tt> by applying the timezone information <tt>string</tt>.</p>
4729</li>
4730<li>Arguments:
4731<ul>
4732
4733<li><tt>time</tt> : a <tt>time</tt> value to be adjusted.</li>
4734<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4735</ul>
4736</li>
4737<li>Return Value:
4738<ul>
4739
4740<li>a <tt>string</tt> value representing the new time after being adjusted by the timezone information,</li>
4741<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4742<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4743<li>a type error will be raised if:
4744<ul>
4745
4746<li>the first argument is any other non-time value,</li>
4747<li>or, the second argument is any other non-string value.</li>
4748</ul>
4749</li>
4750</ul>
4751</li>
4752<li>
4753
4754<p>Example:</p>
4755
4756<div>
4757<div>
4758<pre class="source">adjust_time_for_timezone(get_time_from_datetime(datetime(&quot;2008-04-26T10:10:00&quot;)), &quot;+08:00&quot;);
4759</pre></div></div>
4760</li>
4761<li>
4762
4763<p>The expected result is:</p>
4764
4765<div>
4766<div>
4767<pre class="source">&quot;18:10:00.000+08:00&quot;
4768</pre></div></div>
4769</li>
4770</ul></div>
4771<div class="section">
4772<h3><a name="calendar_duration_from_datetime"></a>calendar_duration_from_datetime</h3>
4773<ul>
4774
4775<li>
4776
4777<p>Syntax:</p>
4778
4779<div>
4780<div>
4781<pre class="source">calendar_duration_from_datetime(datetime, duration_value)
4782</pre></div></div>
4783</li>
4784<li>
4785
4786<p>Gets a user_friendly representation of the duration <tt>duration_value</tt> based on the given datetime <tt>datetime</tt>.</p>
4787</li>
4788<li>Arguments:
4789<ul>
4790
4791<li><tt>datetime</tt> : a <tt>datetime</tt> value to be used as the reference time point.</li>
4792<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4793</ul>
4794</li>
4795<li>Return Value:
4796<ul>
4797
4798<li>a <tt>duration</tt> value with the duration as <tt>duration_value</tt> but with a user_friendly representation,</li>
4799<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4800<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4801<li>a type error will be raised if:
4802<ul>
4803
4804<li>the first argument is any other non-datetime value,</li>
4805<li>or, the second argument is any other non-duration input value.</li>
4806</ul>
4807</li>
4808</ul>
4809</li>
4810<li>
4811
4812<p>Example:</p>
4813
4814<div>
4815<div>
4816<pre class="source">calendar_duration_from_datetime(
4817 datetime(&quot;2016-03-26T10:10:00&quot;),
4818 datetime(&quot;2016-03-26T10:10:00&quot;) - datetime(&quot;2011-01-01T00:00:00&quot;)
4819);
4820</pre></div></div>
4821</li>
4822<li>
4823
4824<p>The expected result is:</p>
4825
4826<div>
4827<div>
4828<pre class="source">duration(&quot;P5Y2M24DT10H10M&quot;)
4829</pre></div></div>
4830</li>
4831</ul></div>
4832<div class="section">
4833<h3><a name="get_year_month_duration.2Fget_day_time_duration"></a>get_year_month_duration/get_day_time_duration</h3>
4834<ul>
4835
4836<li>
4837
4838<p>Syntax:</p>
4839
4840<div>
4841<div>
4842<pre class="source">get_year_month_duration/get_day_time_duration(duration_value)
4843</pre></div></div>
4844</li>
4845<li>
4846
4847<p>Extracts the correct <tt>duration</tt> subtype from <tt>duration_value</tt>.</p>
4848</li>
4849<li>Arguments:
4850<ul>
4851
4852<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4853</ul>
4854</li>
4855<li>Return Value:
4856<ul>
4857
4858<li>a <tt>year_month_duration</tt> value or a <tt>day_time_duration</tt> value,</li>
4859<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4860<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4861<li>any other non-duration input value will cause a type error.</li>
4862</ul>
4863</li>
4864<li>
4865
4866<p>Example:</p>
4867
4868<div>
4869<div>
4870<pre class="source">get_year_month_duration(duration(&quot;P12M50DT10H&quot;));
4871</pre></div></div>
4872</li>
4873<li>
4874
4875<p>The expected result is:</p>
4876
4877<div>
4878<div>
4879<pre class="source">year_month_duration(&quot;P1Y&quot;)
4880</pre></div></div>
4881</li>
4882</ul></div>
4883<div class="section">
4884<h3><a name="months_from_year_month_duration.2Fms_from_day_time_duration"></a>months_from_year_month_duration/ms_from_day_time_duration</h3>
4885<ul>
4886
4887<li>
4888
4889<p>Syntax:</p>
4890
4891<div>
4892<div>
4893<pre class="source">months_from_year_month_duration/ms_from_day_time_duration(duration_value)
4894</pre></div></div>
4895</li>
4896<li>
4897
4898<p>Extracts the number of months or the number of milliseconds from the <tt>duration</tt> subtype.</p>
4899</li>
4900<li>Arguments:
4901<ul>
4902
4903<li><tt>duration_value</tt> : a <tt>duration</tt> of the correct subtype.</li>
4904</ul>
4905</li>
4906<li>Return Value:
4907<ul>
4908
4909<li>a <tt>bigint</tt> representing the number of months/milliseconds,</li>
4910<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4911<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4912<li>any other non-duration input value will cause a type error.</li>
4913</ul>
4914</li>
4915<li>
4916
4917<p>Example:</p>
4918
4919<div>
4920<div>
4921<pre class="source">{
4922 &quot;months&quot;: months_from_year_month_duration(get_year_month_duration(duration(&quot;P5Y7MT50M&quot;))),
4923 &quot;milliseconds&quot;: ms_from_day_time_duration(get_day_time_duration(duration(&quot;P5Y7MT50M&quot;)))
4924};
4925</pre></div></div>
4926</li>
4927<li>
4928
4929<p>The expected result is:</p>
4930
4931<div>
4932<div>
4933<pre class="source">{&quot;months&quot;: 67, &quot;milliseconds&quot;: 3000000}
4934</pre></div></div>
4935</li>
4936</ul></div>
4937<div class="section">
4938<h3><a name="duration_from_months.2Fduration_from_ms"></a>duration_from_months/duration_from_ms</h3>
4939<ul>
4940
4941<li>
4942
4943<p>Syntax:</p>
4944
4945<div>
4946<div>
4947<pre class="source">duration_from_months/duration_from_ms(number_value)
4948</pre></div></div>
4949</li>
4950<li>
4951
4952<p>Creates a <tt>duration</tt> from <tt>number_value</tt>.</p>
4953</li>
4954<li>Arguments:
4955<ul>
4956
4957<li><tt>number_value</tt> : a <tt>bigint</tt> representing the number of months/milliseconds</li>
4958</ul>
4959</li>
4960<li>Return Value:
4961<ul>
4962
4963<li>a <tt>duration</tt> containing <tt>number_value</tt> value for months/milliseconds,</li>
4964<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4965<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4966<li>any other non-duration input value will cause a type error.</li>
4967</ul>
4968</li>
4969<li>
4970
4971<p>Example:</p>
4972
4973<div>
4974<div>
4975<pre class="source">duration_from_months(8);
4976</pre></div></div>
4977</li>
4978<li>
4979
4980<p>The expected result is:</p>
4981
4982<div>
4983<div>
4984<pre class="source">duration(&quot;P8M&quot;)
4985</pre></div></div>
4986</li>
4987</ul></div>
4988<div class="section">
4989<h3><a name="duration_from_interval"></a>duration_from_interval</h3>
4990<ul>
4991
4992<li>
4993
4994<p>Syntax:</p>
4995
4996<div>
4997<div>
4998<pre class="source">duration_from_interval(interval_value)
4999</pre></div></div>
5000</li>
5001<li>
5002
5003<p>Creates a <tt>duration</tt> from <tt>interval_value</tt>.</p>
5004</li>
5005<li>Arguments:
5006<ul>
5007
5008<li><tt>interval_value</tt> : an <tt>interval</tt> value</li>
5009</ul>
5010</li>
5011<li>Return Value:
5012<ul>
5013
5014<li>a <tt>duration</tt> representing the time in the <tt>interval_value</tt></li>
5015<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5016<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5017<li>any other non-duration input value will cause a type error.</li>
5018</ul>
5019</li>
5020<li>
5021
5022<p>Example:</p>
5023
5024<div>
5025<div>
5026<pre class="source">{
5027 &quot;dr1&quot; : duration_from_interval(interval(date(&quot;2010-10-30&quot;), date(&quot;2010-12-21&quot;))),
5028 &quot;dr2&quot; : duration_from_interval(interval(datetime(&quot;2012-06-26T01:01:01.111&quot;), datetime(&quot;2012-07-27T02:02:02.222&quot;))),
5029 &quot;dr3&quot; : duration_from_interval(interval(time(&quot;12:32:38&quot;), time(&quot;20:29:20&quot;))),
5030 &quot;dr4&quot; : duration_from_interval(null)
5031};
5032</pre></div></div>
5033</li>
5034<li>
5035
5036<p>The expected result is:</p>
5037
5038<div>
5039<div>
5040<pre class="source">{
5041 &quot;dr1&quot;: day_time_duration(&quot;P52D&quot;),
5042 &quot;dr2&quot;: day_time_duration(&quot;P31DT1H1M1.111S&quot;),
5043 &quot;dr3&quot;: day_time_duration(&quot;PT7H56M42S&quot;),
5044 &quot;dr4&quot;: null
5045}
5046</pre></div></div>
5047</li>
5048</ul></div>
5049<div class="section">
5050<h3><a name="current_date"></a>current_date</h3>
5051<ul>
5052
5053<li>
5054
5055<p>Syntax:</p>
5056
5057<div>
5058<div>
5059<pre class="source">current_date()
5060</pre></div></div>
5061</li>
5062<li>
5063
5064<p>Gets the current date.</p>
5065</li>
5066<li>Arguments: None</li>
5067<li>Return Value:
5068<ul>
5069
5070<li>a <tt>date</tt> value of the date when the function is called.</li>
5071</ul>
5072</li>
5073</ul></div>
5074<div class="section">
5075<h3><a name="current_time"></a>current_time</h3>
5076<ul>
5077
5078<li>
5079
5080<p>Syntax:</p>
5081
5082<div>
5083<div>
5084<pre class="source">current_time()
5085</pre></div></div>
5086</li>
5087<li>
5088
5089<p>Get the current time</p>
5090</li>
5091<li>Arguments: None</li>
5092<li>Return Value:
5093<ul>
5094
5095<li>a <tt>time</tt> value of the time when the function is called.</li>
5096</ul>
5097</li>
5098</ul></div>
5099<div class="section">
5100<h3><a name="current_datetime"></a>current_datetime</h3>
5101<ul>
5102
5103<li>
5104
5105<p>Syntax:</p>
5106
5107<div>
5108<div>
5109<pre class="source">current_datetime()
5110</pre></div></div>
5111</li>
5112<li>
5113
5114<p>Get the current datetime</p>
5115</li>
5116<li>Arguments: None</li>
5117<li>Return Value:
5118<ul>
5119
5120<li>a <tt>datetime</tt> value of the datetime when the function is called.</li>
5121</ul>
5122</li>
5123</ul></div>
5124<div class="section">
5125<h3><a name="get_date_from_datetime"></a>get_date_from_datetime</h3>
5126<ul>
5127
5128<li>
5129
5130<p>Syntax:</p>
5131
5132<div>
5133<div>
5134<pre class="source">get_date_from_datetime(datetime)
5135</pre></div></div>
5136</li>
5137<li>
5138
5139<p>Gets the date value from the given datetime value <tt>datetime</tt>.</p>
5140</li>
5141<li>Arguments:
5142<ul>
5143
5144<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5145</ul>
5146</li>
5147<li>Return Value:
5148<ul>
5149
5150<li>a <tt>date</tt> value from the datetime,</li>
5151<li>any other non-datetime input value will cause a type error.</li>
5152</ul>
5153</li>
5154</ul></div>
5155<div class="section">
5156<h3><a name="get_time_from_datetime"></a>get_time_from_datetime</h3>
5157<ul>
5158
5159<li>
5160
5161<p>Syntax:</p>
5162
5163<div>
5164<div>
5165<pre class="source">get_time_from_datetime(datetime)
5166</pre></div></div>
5167</li>
5168<li>
5169
5170<p>Get the time value from the given datetime value <tt>datetime</tt></p>
5171</li>
5172<li>Arguments:
5173<ul>
5174
5175<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5176</ul>
5177</li>
5178<li>Return Value:
5179<ul>
5180
5181<li>a <tt>time</tt> value from the datetime.</li>
5182<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5183<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5184<li>any other non-datetime input value will cause a type error.</li>
5185</ul>
5186</li>
5187<li>
5188
5189<p>Example:</p>
5190
5191<div>
5192<div>
5193<pre class="source">get_time_from_datetime(datetime(&quot;2016-03-26T10:10:00&quot;));
5194</pre></div></div>
5195</li>
5196<li>
5197
5198<p>The expected result is:</p>
5199
5200<div>
5201<div>
5202<pre class="source">time(&quot;10:10:00.000Z&quot;)
5203</pre></div></div>
5204</li>
5205</ul></div>
5206<div class="section">
5207<h3><a name="day_of_week"></a>day_of_week</h3>
5208<ul>
5209
5210<li>
5211
5212<p>Syntax:</p>
5213
5214<div>
5215<div>
5216<pre class="source">day_of_week(date)
5217</pre></div></div>
5218</li>
5219<li>
5220
5221<p>Finds the day of the week for a given date (1_7)</p>
5222</li>
5223<li>Arguments:
5224<ul>
5225
5226<li><tt>date</tt>: a <tt>date</tt> value (Can also be a <tt>datetime</tt>)</li>
5227</ul>
5228</li>
5229<li>Return Value:
5230<ul>
5231
5232<li>an <tt>tinyint</tt> representing the day of the week (1_7),</li>
5233<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5234<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5235<li>any other non-date input value will cause a type error.</li>
5236</ul>
5237</li>
5238<li>
5239
5240<p>Example:</p>
5241
5242<div>
5243<div>
5244<pre class="source">day_of_week(datetime(&quot;2012-12-30T12:12:12.039Z&quot;));
5245</pre></div></div>
5246</li>
5247<li>
5248
5249<p>The expected result is:</p>
5250
5251<div>
5252<div>
5253<pre class="source">7
5254</pre></div></div>
5255</li>
5256</ul></div>
5257<div class="section">
5258<h3><a name="date_from_unix_time_in_days"></a>date_from_unix_time_in_days</h3>
5259<ul>
5260
5261<li>
5262
5263<p>Syntax:</p>
5264
5265<div>
5266<div>
5267<pre class="source">date_from_unix_time_in_days(numeric_value)
5268</pre></div></div>
5269</li>
5270<li>
5271
5272<p>Gets a date representing the time after <tt>numeric_value</tt> days since 1970_01_01.</p>
5273</li>
5274<li>Arguments:
5275<ul>
5276
5277<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of days.</li>
5278</ul>
5279</li>
5280<li>Return Value:
5281<ul>
5282
5283<li>a <tt>date</tt> value as the time after <tt>numeric_value</tt> days since 1970-01-01,</li>
5284<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5285<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5286<li>any other non-numeric input value will cause a type error.</li>
5287</ul>
5288</li>
5289</ul></div>
5290<div class="section">
5291<h3><a name="datetime_from_unix_time_in_ms"></a>datetime_from_unix_time_in_ms</h3>
5292<ul>
5293
5294<li>
5295
5296<p>Syntax:</p>
5297
5298<div>
5299<div>
5300<pre class="source">datetime_from_unix_time_in_ms(numeric_value)
5301</pre></div></div>
5302</li>
5303<li>
5304
5305<p>Gets a datetime representing the time after <tt>numeric_value</tt> milliseconds since 1970_01_01T00:00:00Z.</p>
5306</li>
5307<li>Arguments:
5308<ul>
5309
5310<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of milliseconds.</li>
5311</ul>
5312</li>
5313<li>Return Value:
5314<ul>
5315
5316<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> milliseconds since 1970-01-01T00:00:00Z,</li>
5317<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5318<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5319<li>any other non-numeric input value will cause a type error.</li>
5320</ul>
5321</li>
5322</ul></div>
5323<div class="section">
5324<h3><a name="datetime_from_unix_time_in_secs"></a>datetime_from_unix_time_in_secs</h3>
5325<ul>
5326
5327<li>
5328
5329<p>Syntax:</p>
5330
5331<div>
5332<div>
5333<pre class="source">datetime_from_unix_time_in_secs(numeric_value)
5334</pre></div></div>
5335</li>
5336<li>
5337
5338<p>Gets a datetime representing the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z.</p>
5339</li>
5340<li>Arguments:
5341<ul>
5342
5343<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of seconds.</li>
5344</ul>
5345</li>
5346<li>Return Value:
5347<ul>
5348
5349<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z,</li>
5350<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5351<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5352<li>any other non-numeric input value will cause a type error.</li>
5353</ul>
5354</li>
5355</ul></div>
5356<div class="section">
5357<h3><a name="datetime_from_date_time"></a>datetime_from_date_time</h3>
5358<ul>
5359
5360<li>Syntax:</li>
5361</ul>
5362<p>datetime_from_date_time(date,time)</p>
5363<ul>
5364
5365<li>Gets a datetime representing the combination of <tt>date</tt> and <tt>time</tt>
5366<ul>
5367
5368<li>Arguments:</li>
5369<li><tt>date</tt>: a <tt>date</tt> value</li>
5370<li><tt>time</tt> a <tt>time</tt> value</li>
5371</ul>
5372</li>
5373<li>Return Value:
5374<ul>
5375
5376<li>a <tt>datetime</tt> value by combining <tt>date</tt> and <tt>time</tt>,</li>
5377<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5378<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5379<li>a type error will be raised if
5380<ul>
5381
5382<li>the first argument is any other non-date value,</li>
5383<li>or, the second argument is any other non-time value.</li>
5384</ul>
5385</li>
5386</ul>
5387</li>
5388</ul></div>
5389<div class="section">
5390<h3><a name="time_from_unix_time_in_ms"></a>time_from_unix_time_in_ms</h3>
5391<ul>
5392
5393<li>
5394
5395<p>Syntax:</p>
5396
5397<div>
5398<div>
5399<pre class="source">time_from_unix_time_in_ms(numeric_value)
5400</pre></div></div>
5401</li>
5402<li>
5403
5404<p>Gets a time representing the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z.</p>
5405</li>
5406<li>Arguments:
5407<ul>
5408
5409<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of milliseconds.</li>
5410</ul>
5411</li>
5412<li>Return Value:
5413<ul>
5414
5415<li>a <tt>time</tt> value as the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z,</li>
5416<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5417<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5418<li>any other non-numeric input value will cause a type error.</li>
5419</ul>
5420</li>
5421<li>
5422
5423<p>Example:</p>
5424
5425<div>
5426<div>
5427<pre class="source">{
5428 &quot;date&quot;: date_from_unix_time_in_days(15800),
5429 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5430 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5431};
5432</pre></div></div>
5433</li>
5434<li>
5435
5436<p>The expected result is:</p>
5437
5438<div>
5439<div>
5440<pre class="source">{ &quot;date&quot;: date(&quot;2013-04-05&quot;), &quot;datetime&quot;: datetime(&quot;2013-04-05T05:28:20.000Z&quot;), &quot;time&quot;: time(&quot;00:00:03.748Z&quot;) }
5441</pre></div></div>
5442</li>
5443</ul></div>
5444<div class="section">
5445<h3><a name="unix_time_from_date_in_days"></a>unix_time_from_date_in_days</h3>
5446<ul>
5447
5448<li>
5449
5450<p>Syntax:</p>
5451
5452<div>
5453<div>
5454<pre class="source">unix_time_from_date_in_days(date_value)
5455</pre></div></div>
5456</li>
5457<li>
5458
5459<p>Gets an integer value representing the number of days since 1970_01_01 for <tt>date_value</tt>.</p>
5460</li>
5461<li>Arguments:
5462<ul>
5463
5464<li><tt>date_value</tt>: a <tt>date</tt> value.</li>
5465</ul>
5466</li>
5467<li>Return Value:
5468<ul>
5469
5470<li>a <tt>bigint</tt> value representing the number of days,</li>
5471<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5472<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5473<li>any other non-date input value will cause a type error.</li>
5474</ul>
5475</li>
5476</ul></div>
5477<div class="section">
5478<h3><a name="unix_time_from_datetime_in_ms"></a>unix_time_from_datetime_in_ms</h3>
5479<ul>
5480
5481<li>
5482
5483<p>Syntax:</p>
5484
5485<div>
5486<div>
5487<pre class="source">unix_time_from_datetime_in_ms(datetime_value)
5488</pre></div></div>
5489</li>
5490<li>
5491
5492<p>Gets an integer value representing the time in milliseconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5493</li>
5494<li>Arguments:
5495<ul>
5496
5497<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5498</ul>
5499</li>
5500<li>Return Value:
5501<ul>
5502
5503<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5504<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5505<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5506<li>any other non-datetime input value will cause a type error.</li>
5507</ul>
5508</li>
5509</ul></div>
5510<div class="section">
5511<h3><a name="unix_time_from_datetime_in_secs"></a>unix_time_from_datetime_in_secs</h3>
5512<ul>
5513
5514<li>
5515
5516<p>Syntax:</p>
5517
5518<div>
5519<div>
5520<pre class="source">unix_time_from_datetime_in_secs(datetime_value)
5521</pre></div></div>
5522</li>
5523<li>
5524
5525<p>Gets an integer value representing the time in seconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5526</li>
5527<li>Arguments:
5528<ul>
5529
5530<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5531</ul>
5532</li>
5533<li>Return Value:
5534<ul>
5535
5536<li>a <tt>bigint</tt> value representing the number of seconds,</li>
5537<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5538<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5539<li>any other non-datetime input value will cause a type error.</li>
5540</ul>
5541</li>
5542</ul></div>
5543<div class="section">
5544<h3><a name="unix_time_from_time_in_ms"></a>unix_time_from_time_in_ms</h3>
5545<ul>
5546
5547<li>
5548
5549<p>Syntax:</p>
5550
5551<div>
5552<div>
5553<pre class="source">unix_time_from_time_in_ms(time_value)
5554</pre></div></div>
5555</li>
5556<li>
5557
5558<p>Gets an integer value representing the time the milliseconds since 00:00:00.000Z for <tt>time_value</tt>.</p>
5559</li>
5560<li>Arguments:
5561<ul>
5562
5563<li><tt>time_value</tt> : a <tt>time</tt> value.</li>
5564</ul>
5565</li>
5566<li>Return Value:
5567<ul>
5568
5569<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5570<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5571<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5572<li>any other non-datetime input value will cause a type error.</li>
5573</ul>
5574</li>
5575<li>
5576
5577<p>Example:</p>
5578
5579<div>
5580<div>
5581<pre class="source">{
5582 &quot;date&quot;: date_from_unix_time_in_days(15800),
5583 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5584 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5585}
5586</pre></div></div>
5587</li>
5588<li>
5589
5590<p>The expected result is:</p>
5591
5592<div>
5593<div>
5594<pre class="source">{ &quot;date&quot;: date(&quot;2013-04-05&quot;), &quot;datetime&quot;: datetime(&quot;2013-04-05T05:28:20.000Z&quot;), &quot;time&quot;: time(&quot;00:00:03.748Z&quot;) }
5595</pre></div></div>
5596</li>
5597</ul></div>
5598<div class="section">
5599<h3><a name="parse_date.2Fparse_time.2Fparse_datetime"></a>parse_date/parse_time/parse_datetime</h3>
5600<ul>
5601
5602<li>Syntax:</li>
5603</ul>
5604<p>parse_date/parse_time/parse_datetime(date,formatting_expression)</p>
5605<ul>
5606
5607<li>Creates a <tt>date/time/date_time</tt> value by treating <tt>date</tt> with formatting <tt>formatting_expression</tt></li>
5608<li>Arguments:
5609<ul>
5610
5611<li><tt>date</tt>: a <tt>string</tt> value representing the <tt>date/time/datetime</tt>.</li>
5612<li><tt>formatting_expression</tt> a <tt>string</tt> value providing the formatting for <tt>date_expression</tt>.Characters used to create date expression:</li>
5613<li><tt>h</tt> hours</li>
5614<li><tt>m</tt> minutes</li>
5615<li><tt>s</tt> seconds</li>
5616<li><tt>n</tt> milliseconds</li>
5617<li><tt>a</tt> am/pm</li>
5618<li><tt>z</tt> timezone</li>
5619<li><tt>Y</tt> year</li>
5620<li><tt>M</tt> month</li>
5621<li><tt>D</tt> day</li>
5622<li><tt>W</tt> weekday</li>
5623<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5624</ul>
5625</li>
5626<li>Return Value:
5627<ul>
5628
5629<li>a <tt>date/time/date_time</tt> value corresponding to <tt>date</tt>,</li>
5630<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5631<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5632<li>a type error will be raised if:</li>
5633<li>the first argument is any other non-date value,</li>
5634<li>the second argument is any other non-string value.</li>
5635</ul>
5636</li>
5637<li>
5638
5639<p>Example:</p>
5640
5641<div>
5642<div>
5643<pre class="source">parse_time(&quot;30:30&quot;,&quot;m:s&quot;);
5644</pre></div></div>
5645</li>
5646<li>
5647
5648<p>The expected result is:</p>
5649
5650<div>
5651<div>
5652<pre class="source">time(&quot;00:30:30.000Z&quot;)
5653</pre></div></div>
5654</li>
5655</ul></div>
5656<div class="section">
5657<h3><a name="print_date.2Fprint_time.2Fprint_datetime"></a>print_date/print_time/print_datetime</h3>
5658<ul>
5659
5660<li>
5661
5662<p>Syntax:</p>
5663
5664<div>
5665<div>
5666<pre class="source">print_date/print_time/print_datetime(date,formatting_expression)
5667</pre></div></div>
5668</li>
5669<li>
5670
5671<p>Creates a <tt>string</tt> representing a <tt>date/time/date_time</tt> value of the <tt>date</tt> using the formatting <tt>formatting_expression</tt></p>
5672</li>
5673<li>Arguments:
5674<ul>
5675
5676<li><tt>date</tt>: a <tt>date/time/datetime</tt> value.</li>
5677<li><tt>formatting_expression</tt> a <tt>string</tt> value providing the formatting for <tt>date_expression</tt>. Characters used to create date expression:</li>
5678<li><tt>h</tt> hours</li>
5679<li><tt>m</tt> minutes</li>
5680<li><tt>s</tt> seconds</li>
5681<li><tt>n</tt> milliseconds</li>
5682<li><tt>a</tt> am/pm</li>
5683<li><tt>z</tt> timezone</li>
5684<li><tt>Y</tt> year</li>
5685<li><tt>M</tt> month</li>
5686<li><tt>D</tt> day</li>
5687<li><tt>W</tt> weekday</li>
5688<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5689</ul>
5690</li>
5691<li>Return Value:
5692<ul>
5693
5694<li>a <tt>string</tt> value corresponding to <tt>date</tt>,</li>
5695<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5696<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5697<li>a type error will be raised if:
5698<ul>
5699
5700<li>the first argument is any other non-date value,</li>
5701<li>the second argument is any other non-string value.</li>
5702</ul>
5703</li>
5704</ul>
5705</li>
5706<li>
5707
5708<p>Example:</p>
5709
5710<div>
5711<div>
5712<pre class="source">print_time(time(&quot;00:30:30.000Z&quot;),&quot;m:s&quot;);
5713</pre></div></div>
5714</li>
5715<li>
5716
5717<p>The expected result is:</p>
5718
5719<div>
5720<div>
5721<pre class="source">&quot;30:30&quot;
5722</pre></div></div>
5723</li>
5724</ul></div>
5725<div class="section">
5726<h3><a name="get_interval_start.2C_get_interval_end"></a>get_interval_start, get_interval_end</h3>
5727<ul>
5728
5729<li>
5730
5731<p>Syntax:</p>
5732
5733<div>
5734<div>
5735<pre class="source">get_interval_start/get_interval_end(interval)
5736</pre></div></div>
5737</li>
5738<li>
5739
5740<p>Gets the start/end of the given interval.</p>
5741</li>
5742<li>Arguments:
5743<ul>
5744
5745<li><tt>interval</tt>: the interval to be accessed.</li>
5746</ul>
5747</li>
5748<li>Return Value:
5749<ul>
5750
5751<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the time instances of the interval) representing the starting or ending time,</li>
5752<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5753<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5754<li>any other non-interval value will cause a type error.</li>
5755</ul>
5756</li>
5757<li>
5758
5759<p>Example:</p>
5760
5761<div>
5762<div>
5763<pre class="source">{
5764 &quot;start&quot;: get_interval_start(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5765 &quot;end&quot;: get_interval_end(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;))
5766};
5767</pre></div></div>
5768</li>
5769<li>
5770
5771<p>The expected result is:</p>
5772
5773<div>
5774<div>
5775<pre class="source">{ &quot;start&quot;: date(&quot;1984_01_01&quot;), &quot;end&quot;: date(&quot;1985_01_01&quot;) }
5776</pre></div></div>
5777</li>
5778</ul></div>
5779<div class="section">
5780<h3><a name="get_interval_start_date.2Fget_interval_start_datetimeget_interval_start_time.2C_get_interval_end_date.2Fget_interval_end_datetime.2Fget_interval_end_time"></a>get_interval_start_date/get_interval_start_datetimeget_interval_start_time, get_interval_end_date/get_interval_end_datetime/get_interval_end_time</h3>
5781<ul>
5782
5783<li>
5784
5785<p>Syntax:</p>
5786
5787<div>
5788<div>
5789<pre class="source">get_interval_start_date/get_interval_start_datetime/get_interval_start_time/get_interval_end_date/get_interval_end_datetime/get_interval_end_time(interval)
5790</pre></div></div>
5791</li>
5792<li>
5793
5794<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5795</li>
5796<li>Arguments:
5797<ul>
5798
5799<li><tt>interval</tt>: the interval to be accessed.</li>
5800</ul>
5801</li>
5802<li>Return Value:
5803<ul>
5804
5805<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the function) representing the starting or ending time,</li>
5806<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5807<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5808<li>any other non-interval value will cause a type error.</li>
5809</ul>
5810</li>
5811<li>
5812
5813<p>Example:</p>
5814
5815<div>
5816<div>
5817<pre class="source">{
5818 &quot;start1&quot;: get_interval_start_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5819 &quot;end1&quot;: get_interval_end_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5820 &quot;start2&quot;: get_interval_start_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5821 &quot;end2&quot;: get_interval_end_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5822 &quot;start3&quot;: get_interval_start_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;)),
5823 &quot;end3&quot;: get_interval_end_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;))
5824};
5825</pre></div></div>
5826</li>
5827<li>
5828
5829<p>The expected result is:</p>
5830
5831<div>
5832<div>
5833<pre class="source">{
5834 &quot;start1&quot;: date(&quot;1984-01-01&quot;),
5835 &quot;end1&quot;: date(&quot;1985-01-01&quot;),
5836 &quot;start2&quot;: datetime(&quot;1984-01-01T08:30:00.000Z&quot;),
5837 &quot;end2&quot;: datetime(&quot;1985-01-01T09:30:00.000Z&quot;),
5838 &quot;start3&quot;: time(&quot;08:30:00.000Z&quot;),
5839 &quot;end3&quot;: time(&quot;09:30:00.000Z&quot;)
5840}
5841</pre></div></div>
5842</li>
5843</ul></div>
5844<div class="section">
5845<h3><a name="get_overlapping_interval"></a>get_overlapping_interval</h3>
5846<ul>
5847
5848<li>
5849
5850<p>Syntax:</p>
5851
5852<div>
5853<div>
5854<pre class="source">get_overlapping_interval(interval1, interval2)
5855</pre></div></div>
5856</li>
5857<li>
5858
5859<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5860</li>
5861<li>Arguments:
5862<ul>
5863
5864<li><tt>interval1</tt>: an <tt>interval</tt> value</li>
5865<li><tt>interval2</tt>: an <tt>interval</tt> value</li>
5866</ul>
5867</li>
5868<li>Return Value:
5869<ul>
5870
5871<li>an <tt>interval</tt> that is overlapping <tt>interval1</tt> and <tt>interval2</tt>. If <tt>interval1</tt> and <tt>interval2</tt> do not overlap <tt>null</tt> is returned. Note each interval must be of the same type.</li>
5872<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5873<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5874<li>any other non-interval input value will cause a type error.</li>
5875</ul>
5876</li>
5877<li>
5878
5879<p>Example:</p>
5880
5881<div>
5882<div>
5883<pre class="source">{ &quot;overlap1&quot;: get_overlapping_interval(interval(time(&quot;11:23:39&quot;), time(&quot;18:27:19&quot;)), interval(time(&quot;12:23:39&quot;), time(&quot;23:18:00&quot;))),
5884 &quot;overlap2&quot;: get_overlapping_interval(interval(time(&quot;12:23:39&quot;), time(&quot;18:27:19&quot;)), interval(time(&quot;07:19:39&quot;), time(&quot;09:18:00&quot;))),
5885 &quot;overlap3&quot;: get_overlapping_interval(interval(date(&quot;1980-11-30&quot;), date(&quot;1999-09-09&quot;)), interval(date(&quot;2013-01-01&quot;), date(&quot;2014-01-01&quot;))),
5886 &quot;overlap4&quot;: get_overlapping_interval(interval(date(&quot;1980-11-30&quot;), date(&quot;2099-09-09&quot;)), interval(date(&quot;2013-01-01&quot;), date(&quot;2014-01-01&quot;))),
5887 &quot;overlap5&quot;: get_overlapping_interval(interval(datetime(&quot;1844-03-03T11:19:39&quot;), datetime(&quot;2000-10-30T18:27:19&quot;)), interval(datetime(&quot;1989-03-04T12:23:39&quot;), datetime(&quot;2009-10-10T23:18:00&quot;))),
5888 &quot;overlap6&quot;: get_overlapping_interval(interval(datetime(&quot;1989-03-04T12:23:39&quot;), datetime(&quot;2000-10-30T18:27:19&quot;)), interval(datetime(&quot;1844-03-03T11:19:39&quot;), datetime(&quot;1888-10-10T23:18:00&quot;)))
5889};
5890</pre></div></div>
5891</li>
5892<li>
5893
5894<p>The expected result is:</p>
5895
5896<div>
5897<div>
5898<pre class="source">{ &quot;overlap1&quot;: interval(time(&quot;12:23:39.000Z&quot;), time(&quot;18:27:19.000Z&quot;)),
5899 &quot;overlap2&quot;: null,
5900 &quot;overlap3&quot;: null,
5901 &quot;overlap4&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2014_01_01&quot;)),
5902 &quot;overlap5&quot;: interval(datetime(&quot;1989-03-04T12:23:39.000Z&quot;), datetime(&quot;2000-10-30T18:27:19.000Z&quot;)),
5903 &quot;overlap6&quot;: null
5904}
5905</pre></div></div>
5906</li>
5907</ul></div>
5908<div class="section">
5909<h3><a name="interval_bin"></a>interval_bin</h3>
5910<ul>
5911
5912<li>
5913
5914<p>Syntax:</p>
5915
5916<div>
5917<div>
5918<pre class="source">interval_bin(time_to_bin, time_bin_anchor, duration_bin_size)
5919</pre></div></div>
5920</li>
5921<li>
5922
5923<p>Returns the <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value.</p>
5924</li>
5925<li>Arguments:
5926<ul>
5927
5928<li><tt>time_to_bin</tt>: a date/time/datetime value representing the time to be binned.</li>
5929<li><tt>time_bin_anchor</tt>: a date/time/datetime value representing an anchor of a bin starts. The type of this argument should be the same as the first <tt>time_to_bin</tt> argument.</li>
5930<li><tt>duration_bin_size</tt>: the duration value representing the size of the bin, in the type of year_month_duration or day_time_duration. The type of this duration should be compatible with the type of <tt>time_to_bin</tt>, so that the arithmetic operation between <tt>time_to_bin</tt> and <tt>duration_bin_size</tt> is well_defined. Currently AsterixDB supports the following arithmetic operations:
5931<ul>
5932
5933<li>datetime +|_ year_month_duration</li>
5934<li>datetime +|_ day_time_duration</li>
5935<li>date +|_ year_month_duration</li>
5936<li>date +|_ day_time_duration</li>
5937<li>time +|_ day_time_duration</li>
5938</ul>
5939</li>
5940</ul>
5941</li>
5942<li>Return Value:
5943<ul>
5944
5945<li>a <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value. Note that the internal type of this interval value should be the same as the <tt>time_to_bin</tt> type,</li>
5946<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5947<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5948<li>a type error will be raised if:
5949<ul>
5950
5951<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5952<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5953</ul>
5954</li>
5955</ul>
5956</li>
5957<li>
5958
5959<p>Example:</p>
5960
5961<div>
5962<div>
5963<pre class="source">{
5964 &quot;bin1&quot;: interval_bin(date(&quot;2010-10-30&quot;), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P1Y&quot;)),
5965 &quot;bin2&quot;: interval_bin(datetime(&quot;1987-11-19T23:49:23.938&quot;), datetime(&quot;1990-01-01T00:00:00.000Z&quot;), year_month_duration(&quot;P6M&quot;)),
5966 &quot;bin3&quot;: interval_bin(time(&quot;12:23:34.930+07:00&quot;), time(&quot;00:00:00&quot;), day_time_duration(&quot;PT1M&quot;)),
5967 &quot;bin4&quot;: interval_bin(datetime(&quot;1987-11-19T23:49:23.938&quot;), datetime(&quot;2013-01-01T00:00:00.000&quot;), day_time_duration(&quot;PT24H&quot;))
5968};
5969</pre></div></div>
5970</li>
5971<li>
5972
5973<p>The expected result is:</p>
5974
5975<div>
5976<div>
5977<pre class="source">{
5978 &quot;bin1&quot;: interval(date(&quot;2010-01-01&quot;),date(&quot;2011-01-01&quot;)),
5979 &quot;bin2&quot;: interval(datetime(&quot;1987-07-01T00:00:00.000Z&quot;), datetime(&quot;1988-01-01T00:00:00.000Z&quot;)),
5980 &quot;bin3&quot;: interval(time(&quot;05:23:00.000Z&quot;), time(&quot;05:24:00.000Z&quot;)),
5981 &quot;bin4&quot;: interval(datetime(&quot;1987-11-19T00:00:00.000Z&quot;), datetime(&quot;1987-11-20T00:00:00.000Z&quot;))
5982}
5983</pre></div></div>
5984</li>
5985</ul></div>
5986<div class="section">
5987<h3><a name="interval_start_from_date.2Ftime.2Fdatetime"></a>interval_start_from_date/time/datetime</h3>
5988<ul>
5989
5990<li>
5991
5992<p>Syntax:</p>
5993
5994<div>
5995<div>
5996<pre class="source">interval_start_from_date/time/datetime(date/time/datetime, duration)
5997</pre></div></div>
5998</li>
5999<li>
6000
6001<p>Construct an <tt>interval</tt> value by the given starting <tt>date</tt>/<tt>time</tt>/<tt>datetime</tt> and the <tt>duration</tt> that the interval lasts.</p>
6002</li>
6003<li>Arguments:
6004<ul>
6005
6006<li><tt>date/time/datetime</tt>: a <tt>string</tt> representing a <tt>date</tt>, <tt>time</tt> or <tt>datetime</tt>, or a <tt>date</tt>/<tt>time</tt>/<tt>datetime</tt> value, representing the starting time point.</li>
6007<li><tt>duration</tt>: a <tt>string</tt> or <tt>duration</tt> value representing the duration of the interval. Note that duration cannot be negative value.</li>
6008</ul>
6009</li>
6010<li>Return Value:
6011<ul>
6012
6013<li>an <tt>interval</tt> value representing the interval starting from the given time point with the length of duration,</li>
6014<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6015<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6016<li>a type error will be raised if:
6017<ul>
6018
6019<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
6020<li>or, the second argument is any other non-duration value.</li>
6021</ul>
6022</li>
6023</ul>
6024</li>
6025<li>
6026
6027<p>Example:</p>
6028
6029<div>
6030<div>
6031<pre class="source">{
6032 &quot;interval1&quot;: interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;),
6033 &quot;interval2&quot;: interval_start_from_time(time(&quot;02:23:28.394&quot;), &quot;PT3H24M&quot;),
6034 &quot;interval3&quot;: interval_start_from_datetime(&quot;1999-09-09T09:09:09.999&quot;, duration(&quot;P2M30D&quot;))
6035};
6036</pre></div></div>
6037</li>
6038<li>
6039
6040<p>The expectecd result is:</p>
6041
6042<div>
6043<div>
6044<pre class="source">{
6045 &quot;interval1&quot;: interval(date(&quot;1984-01-01&quot;), date(&quot;1985-01-01&quot;)),
6046 &quot;interval2&quot;: interval(time(&quot;02:23:28.394Z&quot;), time(&quot;05:47:28.394Z&quot;)),
6047 &quot;interval3&quot;: interval(datetime(&quot;1999-09-09T09:09:09.999Z&quot;), datetime(&quot;1999-12-09T09:09:09.999Z&quot;))
6048}
6049</pre></div></div>
6050</li>
6051</ul></div>
6052<div class="section">
6053<h3><a name="overlap_bins"></a>overlap_bins</h3>
6054<ul>
6055
6056<li>
6057
6058<p>Return Value:</p>
6059<ul>
6060
6061<li>a <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value. Note that the internal type of this interval value should be the same as the <tt>time_to_bin</tt> type.</li>
6062</ul>
6063</li>
6064<li>
6065
6066<p>Syntax:</p>
6067
6068<div>
6069<div>
6070<pre class="source">overlap_bins(interval, time_bin_anchor, duration_bin_size)
6071</pre></div></div>
6072</li>
6073<li>
6074
6075<p>Returns an ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>.</p>
6076</li>
6077<li>Arguments:
6078<ul>
6079
6080<li><tt>interval</tt>: an <tt>interval</tt> value</li>
6081<li><tt>time_bin_anchor</tt>: a date/time/datetime value representing an anchor of a bin starts. The type of this argument should be the same as the first <tt>time_to_bin</tt> argument.</li>
6082<li><tt>duration_bin_size</tt>: the duration value representing the size of the bin, in the type of year_month_duration or day_time_duration. The type of this duration should be compatible with the type of <tt>time_to_bin</tt>, so that the arithmetic operation between <tt>time_to_bin</tt> and <tt>duration_bin_size</tt> is well_defined. Currently AsterixDB supports the following arithmetic operations:
6083<ul>
6084
6085<li>datetime +|_ year_month_duration</li>
6086<li>datetime +|_ day_time_duration</li>
6087<li>date +|_ year_month_duration</li>
6088<li>date +|_ day_time_duration</li>
6089<li>time +|_ day_time_duration</li>
6090</ul>
6091</li>
6092</ul>
6093</li>
6094<li>Return Value:
6095<ul>
6096
6097<li>a ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>. Note that the internal type as <tt>time_to_bin</tt> and <tt>duration_bin_size</tt>.</li>
6098<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6099<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6100<li>a type error will be raised if:
6101<ul>
6102
6103<li>the first arugment is any other non-interval value,</li>
6104<li>or, the second argument is any other non-date/non-time/non-datetime value,</li>
6105<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
6106</ul>
6107</li>
6108</ul>
6109</li>
6110<li>
6111
6112<p>Example:</p>
6113
6114<div>
6115<div>
6116<pre class="source">{
6117 &quot;timebins&quot;: overlap_bins(interval(time(&quot;17:23:37&quot;), time(&quot;18:30:21&quot;)), time(&quot;00:00:00&quot;), day_time_duration(&quot;PT30M&quot;)),
6118 &quot;datebins&quot;: overlap_bins(interval(date(&quot;1984-03-17&quot;), date(&quot;2013-08-22&quot;)), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P10Y&quot;)),
6119 &quot;datetimebins&quot;: overlap_bins(interval(datetime(&quot;1800-01-01T23:59:48.938&quot;), datetime(&quot;2015-07-26T13:28:30.218&quot;)),
6120 datetime(&quot;1900-01-01T00:00:00.000&quot;), year_month_duration(&quot;P100Y&quot;))
6121};
6122</pre></div></div>
6123</li>
6124<li>
6125
6126<p>The expected result is:</p>
6127
6128<div>
6129<div>
6130<pre class="source">{
6131 &quot;timebins&quot;: [
6132 interval(time(&quot;17:00:00.000Z&quot;), time(&quot;17:30:00.000Z&quot;)),
6133 interval(time(&quot;17:30:00.000Z&quot;), time(&quot;18:00:00.000Z&quot;)),
6134 interval(time(&quot;18:00:00.000Z&quot;), time(&quot;18:30:00.000Z&quot;)),
6135 interval(time(&quot;18:30:00.000Z&quot;), time(&quot;19:00:00.000Z&quot;))
6136 ],
6137 &quot;datebins&quot;: [
6138 interval(date(&quot;1980-01-01&quot;), date(&quot;1990-01-01&quot;)),
6139 interval(date(&quot;1990-01-01&quot;), date(&quot;2000-01-01&quot;)),
6140 interval(date(&quot;2000-01-01&quot;), date(&quot;2010-01-01&quot;)),
6141 interval(date(&quot;2010-01-01&quot;), date(&quot;2020-01-01&quot;))
6142 ],
6143 &quot;datetimebins&quot;: [
6144 interval(datetime(&quot;1800-01-01T00:00:00.000Z&quot;), datetime(&quot;1900-01-01T00:00:00.000Z&quot;)),
6145 interval(datetime(&quot;1900-01-01T00:00:00.000Z&quot;), datetime(&quot;2000-01-01T00:00:00.000Z&quot;)),
6146 interval(datetime(&quot;2000-01-01T00:00:00.000Z&quot;), datetime(&quot;2100-01-01T00:00:00.000Z&quot;))
6147 ]
6148};
6149</pre></div></div>
6150</li>
6151</ul><!--
6152 ! Licensed to the Apache Software Foundation (ASF) under one
6153 ! or more contributor license agreements. See the NOTICE file
6154 ! distributed with this work for additional information
6155 ! regarding copyright ownership. The ASF licenses this file
6156 ! to you under the Apache License, Version 2.0 (the
6157 ! "License"); you may not use this file except in compliance
6158 ! with the License. You may obtain a copy of the License at
6159 !
6160 ! http://www.apache.org/licenses/LICENSE-2.0
6161 !
6162 ! Unless required by applicable law or agreed to in writing,
6163 ! software distributed under the License is distributed on an
6164 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6165 ! KIND, either express or implied. See the License for the
6166 ! specific language governing permissions and limitations
6167 ! under the License.
6168 !-->
6169</div>
6170<div class="section">
6171<h3><a name="interval_before.2C_interval_after"></a>interval_before, interval_after</h3>
6172<ul>
6173
6174<li>
6175
6176<p>Syntax:</p>
6177
6178<div>
6179<div>
6180<pre class="source">interval_before(interval1, interval2)
6181interval_after(interval1, interval2)
6182</pre></div></div>
6183</li>
6184<li>
6185
6186<p>These two functions check whether an interval happens before/after another interval.</p>
6187</li>
6188<li>Arguments:
6189<ul>
6190
6191<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6192</ul>
6193</li>
6194<li>Return Value:
6195<ul>
6196
6197<li>a <tt>boolean</tt> value. Specifically, <tt>interval_before(interval1, interval2)</tt> is true if and only if <tt>interval1.end &lt; interval2.start</tt>, and <tt>interval_after(interval1, interval2)</tt> is true if and only if <tt>interval1.start &gt; interval2.end</tt>.</li>
6198<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6199<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6200<li>any other non-interval input value will cause a type error.</li>
6201</ul>
6202</li>
6203<li>
6204
6205<p>Examples:</p>
6206
6207<div>
6208<div>
6209<pre class="source">{
6210 &quot;interval_before&quot;: interval_before(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6211 interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;))),
6212 &quot;interval_after&quot;: interval_after(interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;)),
6213 interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)))
6214};
6215</pre></div></div>
6216</li>
6217<li>
6218
6219<p>The expected result is:</p>
6220
6221<div>
6222<div>
6223<pre class="source">{ &quot;interval_before&quot;: true, &quot;interval_after&quot;: true }
6224</pre></div></div>
6225</li>
6226</ul></div>
6227<div class="section">
6228<h3><a name="interval_covers.2C_interval_covered_by"></a>interval_covers, interval_covered_by</h3>
6229<ul>
6230
6231<li>
6232
6233<p>Syntax:</p>
6234
6235<div>
6236<div>
6237<pre class="source">interval_covers(interval1, interval2)
6238interval_covered_by(interval1, interval2)
6239</pre></div></div>
6240</li>
6241<li>
6242
6243<p>These two functions check whether one interval covers the other interval.</p>
6244</li>
6245<li>Arguments:
6246<ul>
6247
6248<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6249</ul>
6250</li>
6251<li>Return Value:
6252<ul>
6253
6254<li>
6255
6256<p>a <tt>boolean</tt> value. Specifically, <tt>interval_covers(interval1, interval2)</tt> is true if and only if</p>
6257<p>interval1.start &lt;= interval2.start AND interval1.end &gt;= interval2.end</p>
6258<p><tt>interval_covered_by(interval1, interval2)</tt> is true if and only if</p>
6259<p>interval2.start &lt;= interval1.start AND interval2.end &gt;= interval1.end</p>
6260</li>
6261<li>
6262
6263<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6264</li>
6265<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6266<li>any other non-interval input value will cause a type error.</li>
6267</ul>
6268</li>
6269<li>
6270
6271<p>Examples:</p>
6272
6273<div>
6274<div>
6275<pre class="source">{
6276 &quot;interval_covers&quot;: interval_covers(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6277 interval(date(&quot;2000-03-01&quot;), date(&quot;2004-09-09&quot;))),
6278 &quot;interval_covered_by&quot;: interval_covered_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6279 interval(date(&quot;2004-09-10&quot;), date(&quot;2012-08-01&quot;)))
6280};
6281</pre></div></div>
6282</li>
6283<li>
6284
6285<p>The expected result is:</p>
6286
6287<div>
6288<div>
6289<pre class="source">{ &quot;interval_covers&quot;: true, &quot;interval_covered_by&quot;: true }
6290</pre></div></div>
6291</li>
6292</ul></div>
6293<div class="section">
6294<h3><a name="interval_overlaps.2C_interval_overlapped_by"></a>interval_overlaps, interval_overlapped_by</h3>
6295<ul>
6296
6297<li>
6298
6299<p>Syntax:</p>
6300
6301<div>
6302<div>
6303<pre class="source">interval_overlaps(interval1, interval2)
6304interval_overlapped_by(interval1, interval2)
6305</pre></div></div>
6306</li>
6307<li>
6308
6309<p>These functions check whether two intervals overlap with each other.</p>
6310</li>
6311<li>Arguments:
6312<ul>
6313
6314<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6315</ul>
6316</li>
6317<li>Return Value:
6318<ul>
6319
6320<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlaps(interval1, interval2)</tt> is true if and only if
6321<p>interval1.start &lt; interval2.start AND interval2.end &gt; interval1.end AND interval1.end &gt; interval2.start</p></li>
6322</ul>
6323<p><tt>interval_overlapped_by(interval1, interval2)</tt> is true if and only if</p>
6324
6325<div>
6326<div>
6327<pre class="source">interval2.start &lt; interval1.start
6328AND interval1.end &gt; interval2.end
6329AND interval2.end &gt; interval1.start
6330</pre></div></div>
6331
6332<ul>
6333
6334<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6335<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6336<li>any other non-interval input value will cause a type error.</li>
6337</ul>
6338<p>Note that <tt>interval_overlaps</tt> and <tt>interval_overlapped_by</tt> are following the Allen&#x2019;s relations on the definition of overlap.</p>
6339</li>
6340<li>
6341
6342<p>Examples:</p>
6343
6344<div>
6345<div>
6346<pre class="source">{
6347 &quot;overlaps&quot;: interval_overlaps(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6348 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6349 &quot;overlapped_by&quot;: interval_overlapped_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6350 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))))
6351};
6352</pre></div></div>
6353</li>
6354<li>
6355
6356<p>The expected result is:</p>
6357
6358<div>
6359<div>
6360<pre class="source">{ &quot;overlaps&quot;: true, &quot;overlapped_by&quot;: true }
6361</pre></div></div>
6362</li>
6363</ul></div>
6364<div class="section">
6365<h3><a name="interval_overlapping"></a>interval_overlapping</h3>
6366<p>Note that <tt>interval_overlapping</tt> is not an Allen&#x2019;s Relation, but syntactic sugar we added for the case that the intersect of two intervals is not empty. Basically this function returns true if any of these functions return true: <tt>interval_overlaps</tt>, <tt>interval_overlapped_by</tt>, <tt>interval_covers</tt>, or <tt>interval_covered_by</tt>.</p>
6367<ul>
6368
6369<li>
6370
6371<p>Syntax:</p>
6372
6373<div>
6374<div>
6375<pre class="source">interval_overlapping(interval1, interval2)
6376</pre></div></div>
6377</li>
6378<li>
6379
6380<p>This functions check whether two intervals share any points with each other.</p>
6381</li>
6382<li>Arguments:
6383<ul>
6384
6385<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6386</ul>
6387</li>
6388<li>Return Value:
6389<ul>
6390
6391<li>
6392
6393<p>a <tt>boolean</tt> value. Specifically, <tt>interval_overlapping(interval1, interval2)</tt> is true if</p>
6394<p>interval1.start &lt; interval2.end AND interval1.end &gt; interval2.start</p>
6395</li>
6396<li>
6397
6398<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6399</li>
6400<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6401<li>any other non-interval input value will cause a type error.</li>
6402</ul>
6403</li>
6404<li>
6405
6406<p>Examples:</p>
6407
6408<div>
6409<div>
6410<pre class="source">{
6411 &quot;overlapping1&quot;: interval_overlapping(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6412 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6413 &quot;overlapping2&quot;: interval_overlapping(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6414 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-12-31&quot;)))
6415};
6416</pre></div></div>
6417</li>
6418<li>
6419
6420<p>The expected result is:</p>
6421
6422<div>
6423<div>
6424<pre class="source">{ &quot;overlapping1&quot;: true, &quot;overlapping2&quot;: true }
6425</pre></div></div>
6426</li>
6427</ul></div>
6428<div class="section">
6429<h3><a name="interval_meets.2C_interval_met_by"></a>interval_meets, interval_met_by</h3>
6430<ul>
6431
6432<li>
6433
6434<p>Syntax:</p>
6435
6436<div>
6437<div>
6438<pre class="source">interval_meets(interval1, interval2)
6439interval_met_by(interval1, interval2)
6440</pre></div></div>
6441</li>
6442<li>
6443
6444<p>These two functions check whether an interval meets with another interval.</p>
6445</li>
6446<li>Arguments:
6447<ul>
6448
6449<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6450</ul>
6451</li>
6452<li>Return Value:
6453<ul>
6454
6455<li>a <tt>boolean</tt> value. Specifically, <tt>interval_meets(interval1, interval2)</tt> is true if and only if <tt>interval1.end = interval2.start</tt>, and <tt>interval_met_by(interval1, interval2)</tt> is true if and only if <tt>interval1.start = interval2.end</tt>. If any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</li>
6456<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6457<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6458<li>any other non-interval input value will cause a type error.</li>
6459</ul>
6460</li>
6461<li>
6462
6463<p>Examples:</p>
6464
6465<div>
6466<div>
6467<pre class="source">{
6468 &quot;meets&quot;: interval_meets(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6469 interval(date(&quot;2005-01-01&quot;), date(&quot;2012-09-09&quot;))),
6470 &quot;metby&quot;: interval_met_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6471 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-08-01&quot;)))
6472};
6473</pre></div></div>
6474</li>
6475<li>
6476
6477<p>The expected result is:</p>
6478
6479<div>
6480<div>
6481<pre class="source">{ &quot;meets&quot;: true, &quot;metby&quot;: true }
6482</pre></div></div>
6483</li>
6484</ul></div>
6485<div class="section">
6486<h3><a name="interval_starts.2C_interval_started_by"></a>interval_starts, interval_started_by</h3>
6487<ul>
6488
6489<li>
6490
6491<p>Syntax:</p>
6492
6493<div>
6494<div>
6495<pre class="source">interval_starts(interval1, interval2)
6496interval_started_by(interval1, interval2)
6497</pre></div></div>
6498</li>
6499<li>
6500
6501<p>These two functions check whether one interval starts with the other interval.</p>
6502</li>
6503<li>Arguments:
6504<ul>
6505
6506<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6507</ul>
6508</li>
6509<li>Return Value:
6510<ul>
6511
6512<li>a <tt>boolean</tt> value. Specifically, <tt>interval_starts(interval1, interval2)</tt> returns true if and only if
6513<p>interval1.start = interval2.start AND interval1.end &lt;= interval2.end</p></li>
6514</ul>
6515<p><tt>interval_started_by(interval1, interval2)</tt> returns true if and only if</p>
6516
6517<div>
6518<div>
6519<pre class="source">interval1.start = interval2.start
6520AND interval2.end &lt;= interval1.end
6521</pre></div></div>
6522
6523<ul>
6524
6525<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6526<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6527<li>any other non-interval input value will cause a type error.</li>
6528</ul>
6529</li>
6530<li>
6531
6532<p>Examples:</p>
6533
6534<div>
6535<div>
6536<pre class="source">{
6537 &quot;interval_starts&quot;: interval_starts(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6538 interval(date(&quot;2000-01-01&quot;), date(&quot;2012-09-09&quot;))),
6539 &quot;interval_started_by&quot;: interval_started_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6540 interval(date(&quot;2006-08-01&quot;), date(&quot;2006-08-02&quot;)))
6541};
6542</pre></div></div>
6543</li>
6544<li>
6545
6546<p>The expected result is:</p>
6547
6548<div>
6549<div>
6550<pre class="source">{ &quot;interval_starts&quot;: true, &quot;interval_started_by&quot;: true }
6551</pre></div></div>
6552</li>
6553</ul></div>
6554<div class="section">
6555<h3><a name="interval_ends.2C_interval_ended_by"></a>interval_ends, interval_ended_by</h3>
6556<ul>
6557
6558<li>
6559
6560<p>Syntax:</p>
6561
6562<div>
6563<div>
6564<pre class="source">interval_ends(interval1, interval2)
6565interval_ended_by(interval1, interval2)
6566</pre></div></div>
6567</li>
6568<li>
6569
6570<p>These two functions check whether one interval ends with the other interval.</p>
6571</li>
6572<li>Arguments:
6573<ul>
6574
6575<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6576</ul>
6577</li>
6578<li>Return Value:
6579<ul>
6580
6581<li>
6582
6583<p>a <tt>boolean</tt> value. Specifically, <tt>interval_ends(interval1, interval2)</tt> returns true if and only if</p>
6584<p>interval1.end = interval2.end AND interval1.start &gt;= interval2.start</p>
6585<p><tt>interval_ended_by(interval1, interval2)</tt> returns true if and only if</p>
6586<p>interval2.end = interval1.end AND interval2.start &gt;= interval1.start</p>
6587</li>
6588<li>
6589
6590<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6591</li>
6592<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6593<li>any other non-interval input value will cause a type error.</li>
6594</ul>
6595</li>
6596<li>
6597
6598<p>Examples:</p>
6599
6600<div>
6601<div>
6602<pre class="source">{
6603 &quot;interval_ends&quot;: interval_ends(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6604 interval(date(&quot;1998-01-01&quot;), date(&quot;2005-01-01&quot;))),
6605 &quot;interval_ended_by&quot;: interval_ended_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6606 interval(date(&quot;2006-09-10&quot;), date(&quot;2007-03-01&quot;)))
6607};
6608</pre></div></div>
6609</li>
6610<li>
6611
6612<p>The expected result is:</p>
6613
6614<div>
6615<div>
6616<pre class="source">{ &quot;interval_ends&quot;: true, &quot;interval_ended_by&quot;: true }
6617</pre></div></div>
6618</li>
6619</ul><!--
6620 ! Licensed to the Apache Software Foundation (ASF) under one
6621 ! or more contributor license agreements. See the NOTICE file
6622 ! distributed with this work for additional information
6623 ! regarding copyright ownership. The ASF licenses this file
6624 ! to you under the Apache License, Version 2.0 (the
6625 ! "License"); you may not use this file except in compliance
6626 ! with the License. You may obtain a copy of the License at
6627 !
6628 ! http://www.apache.org/licenses/LICENSE-2.0
6629 !
6630 ! Unless required by applicable law or agreed to in writing,
6631 ! software distributed under the License is distributed on an
6632 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6633 ! KIND, either express or implied. See the License for the
6634 ! specific language governing permissions and limitations
6635 ! under the License.
6636 !-->
6637</div></div>
6638<div class="section">
6639<h2><a name="Object_Functions"></a><a name="ObjectFunctions" id="ObjectFunctions">Object Functions</a></h2>
6640<div class="section">
6641<h3><a name="get_object_fields"></a>get_object_fields</h3>
6642<ul>
6643
6644<li>
6645
6646<p>Syntax:</p>
6647
6648<div>
6649<div>
6650<pre class="source">get_object_fields(input_object)
6651</pre></div></div>
6652</li>
6653<li>
6654
6655<p>Access the object field names, type and open status for a given object.</p>
6656</li>
6657<li>Arguments:
6658<ul>
6659
6660<li><tt>input_object</tt> : a object value.</li>
6661</ul>
6662</li>
6663<li>Return Value:
6664<ul>
6665
6666<li>an array of <tt>object</tt> values that include the field_name <tt>string</tt>, field_type <tt>string</tt>, is_open <tt>boolean</tt> (used for debug purposes only: <tt>true</tt> if field is open and <tt>false</tt> otherwise), and optional nested <tt>orderedList</tt> for the values of a nested object,</li>
6667<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6668<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
6669<li>any other non-object input value will cause a type error.</li>
6670</ul>
6671</li>
6672<li>
6673
6674<p>Example:</p>
6675
6676<div>
6677<div>
6678<pre class="source">get_object_fields(
6679 {
6680 &quot;id&quot;: 1,
6681 &quot;project&quot;: &quot;AsterixDB&quot;,
6682 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6683 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6684 }
6685 );
6686</pre></div></div>
6687</li>
6688<li>
6689
6690<p>The expected result is:</p>
6691
6692<div>
6693<div>
6694<pre class="source">[
6695 { &quot;field-name&quot;: &quot;id&quot;, &quot;field-type&quot;: &quot;INT64&quot;, &quot;is-open&quot;: false },
6696 { &quot;field-name&quot;: &quot;project&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6697 { &quot;field-name&quot;: &quot;address&quot;, &quot;field-type&quot;: &quot;RECORD&quot;, &quot;is-open&quot;: false,
6698 &quot;nested&quot;: [
6699 { &quot;field-name&quot;: &quot;city&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6700 { &quot;field-name&quot;: &quot;state&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false }
6701 ]
6702 },
6703 { &quot;field-name&quot;:
6704 &quot;related&quot;,
6705 &quot;field-type&quot;: &quot;ORDEREDLIST&quot;,
6706 &quot;is-open&quot;: false,
6707 &quot;list&quot;: [
6708 { &quot;field-type&quot;: &quot;STRING&quot; },
6709 { &quot;field-type&quot;: &quot;STRING&quot; },
6710 { &quot;field-type&quot;: &quot;STRING&quot; }
6711 ]
6712 }
6713]
6714</pre></div></div>
6715</li>
6716</ul>
6717<p>]</p></div>
6718<div class="section">
6719<h3><a name="get_object_field_value"></a>get_object_field_value</h3>
6720<ul>
6721
6722<li>
6723
6724<p>Syntax:</p>
6725
6726<div>
6727<div>
6728<pre class="source">get_object_field_value(input_object, string)
6729</pre></div></div>
6730</li>
6731<li>
6732
6733<p>Access the field name given in the <tt>string_expression</tt> from the <tt>object_expression</tt>.</p>
6734</li>
6735<li>Arguments:
6736<ul>
6737
6738<li><tt>input_object</tt> : a <tt>object</tt> value.</li>
6739<li><tt>string</tt> : a <tt>string</tt> representing the top level field name.</li>
6740</ul>
6741</li>
6742<li>Return Value:
6743<ul>
6744
6745<li>an <tt>any</tt> value saved in the designated field of the object,</li>
6746<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6747<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6748<li>a type error will be raised if:
6749<ul>
6750
6751<li>the first argument is any other non-object value,</li>
6752<li>or, the second argument is any other non-string value.</li>
6753</ul>
6754</li>
6755</ul>
6756</li>
6757<li>
6758
6759<p>Example:</p>
6760
6761<div>
6762<div>
6763<pre class="source">get_object_field_value({
6764 &quot;id&quot;: 1,
6765 &quot;project&quot;: &quot;AsterixDB&quot;,
6766 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6767 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6768 },
6769 &quot;project&quot;
6770 );
6771</pre></div></div>
6772</li>
6773<li>
6774
6775<p>The expected result is:</p>
6776
6777<div>
6778<div>
6779<pre class="source">&quot;AsterixDB&quot;
6780</pre></div></div>
6781</li>
6782</ul></div>
6783<div class="section">
6784<h3><a name="object_remove_fields"></a>object_remove_fields</h3>
6785<ul>
6786
6787<li>
6788
6789<p>Syntax:</p>
6790
6791<div>
6792<div>
6793<pre class="source">object_remove_fields(input_object, field_names)
6794</pre></div></div>
6795</li>
6796<li>
6797
6798<p>Remove indicated fields from a object given a list of field names.</p>
6799</li>
6800<li>Arguments:
6801<ul>
6802
6803<li><tt>input_object</tt>: a object value.</li>
6804<li><tt>field_names</tt>: an array of strings and/or array of array of strings.</li>
6805</ul>
6806</li>
6807<li>
6808
6809<p>Return Value:</p>
6810<ul>
6811
6812<li>a new object value without the fields listed in the second argument,</li>
6813<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6814<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6815<li>a type error will be raised if:
6816<ul>
6817
6818<li>the first argument is any other non-object value,</li>
6819<li>or, the second argument is any other non-array value or recursively contains non-string items.</li>
6820</ul>
6821</li>
6822</ul>
6823</li>
6824<li>
6825
6826<p>Example:</p>
6827
6828<div>
6829<div>
6830<pre class="source">object_remove_fields(
6831 {
6832 &quot;id&quot;:1,
6833 &quot;project&quot;:&quot;AsterixDB&quot;,
6834 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6835 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6836 },
6837 [[&quot;address&quot;, &quot;city&quot;], &quot;related&quot;]
6838 );
6839</pre></div></div>
6840</li>
6841<li>
6842
6843<p>The expected result is:</p>
6844
6845<div>
6846<div>
6847<pre class="source">{
6848 &quot;id&quot;:1,
6849 &quot;project&quot;:&quot;AsterixDB&quot;,
6850 &quot;address&quot;:{ &quot;state&quot;: &quot;CA&quot; }
6851}
6852</pre></div></div>
6853</li>
6854</ul></div>
6855<div class="section">
6856<h3><a name="object_add_fields"></a>object_add_fields</h3>
6857<ul>
6858
6859<li>
6860
6861<p>Syntax:</p>
6862
6863<div>
6864<div>
6865<pre class="source">object_add_fields(input_object, fields)
6866</pre></div></div>
6867</li>
6868<li>
6869
6870<p>Add fields to a object given a list of field names.</p>
6871</li>
6872<li>Arguments:
6873<ul>
6874
6875<li><tt>input_object</tt> : a object value.</li>
6876<li><tt>fields</tt>: an array of field descriptor objects where each object has field_name and field_value.</li>
6877</ul>
6878</li>
6879<li>Return Value:
6880<ul>
6881
6882<li>a new object value with the new fields included,</li>
6883<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6884<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6885<li>a type error will be raised if:
6886<ul>
6887
6888<li>the first argument is any other non-object value,</li>
6889<li>the second argument is any other non-array value, or contains non-object items.</li>
6890</ul>
6891</li>
6892</ul>
6893</li>
6894<li>
6895
6896<p>Example:</p>
6897
6898<div>
6899<div>
6900<pre class="source">object_add_fields(
6901 {
6902 &quot;id&quot;:1,
6903 &quot;project&quot;:&quot;AsterixDB&quot;,
6904 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6905 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6906 },
6907 [{&quot;field-name&quot;:&quot;employment_location&quot;, &quot;field-value&quot;:create_point(30.0,70.0)}]
6908 );
6909</pre></div></div>
6910</li>
6911<li>
6912
6913<p>The expected result is:</p>
6914
6915<div>
6916<div>
6917<pre class="source">{
6918 &quot;id&quot;:1,
6919 &quot;project&quot;:&quot;AsterixDB&quot;,
6920 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6921 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6922 &quot;employment_location&quot;: point(&quot;30.0,70.0&quot;)
6923 }
6924</pre></div></div>
6925</li>
6926</ul></div>
6927<div class="section">
6928<h3><a name="object_merge"></a>object_merge</h3>
6929<ul>
6930
6931<li>
6932
6933<p>Syntax:</p>
6934
6935<div>
6936<div>
6937<pre class="source">object_merge(object1, object2)
6938</pre></div></div>
6939</li>
6940<li>
6941
6942<p>Merge two different objects into a new object.</p>
6943</li>
6944<li>Arguments:
6945<ul>
6946
6947<li><tt>object1</tt> : a object value.</li>
6948<li><tt>object2</tt> : a object value.</li>
6949</ul>
6950</li>
6951<li>Return Value:
6952<ul>
6953
6954<li>a new object value with fields from both input objects. If a field&#x2019;s names in both objects are the same, an exception is issued,</li>
6955<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6956<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6957<li>any other non-object input value will cause a type error.</li>
6958</ul>
6959</li>
6960<li>
6961
6962<p>Example:</p>
6963
6964<div>
6965<div>
6966<pre class="source">object_merge(
6967 {
6968 &quot;id&quot;:1,
6969 &quot;project&quot;:&quot;AsterixDB&quot;,
6970 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6971 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6972 },
6973 {
6974 &quot;user_id&quot;: 22,
6975 &quot;employer&quot;: &quot;UC Irvine&quot;,
6976 &quot;employment_type&quot;: &quot;visitor&quot;
6977 }
6978 );
6979</pre></div></div>
6980</li>
6981<li>
6982
6983<p>The expected result is:</p>
6984
6985<div>
6986<div>
6987<pre class="source">{
6988 &quot;employment_type&quot;: &quot;visitor&quot;,
6989 &quot;address&quot;: {
6990 &quot;city&quot;: &quot;Irvine&quot;,
6991 &quot;state&quot;: &quot;CA&quot;
6992 },
6993 &quot;related&quot;: [
6994 &quot;Hivestrix&quot;,
6995 &quot;Preglix&quot;,
6996 &quot;Apache VXQuery&quot;
6997 ],
6998 &quot;user_id&quot;: 22,
6999 &quot;project&quot;: &quot;AsterixDB&quot;,
7000 &quot;employer&quot;: &quot;UC Irvine&quot;,
7001 &quot;id&quot;: 1
7002}
7003</pre></div></div>
7004</li>
7005</ul></div>
7006<div class="section">
7007<h3><a name="object_length"></a>object_length</h3>
7008<ul>
7009
7010<li>
7011
7012<p>Syntax:</p>
7013
7014<div>
7015<div>
7016<pre class="source">object_length(input_object)
7017</pre></div></div>
7018</li>
7019<li>
7020
7021<p>Returns number of top-level fields in the given object</p>
7022</li>
7023<li>Arguments:
7024<ul>
7025
7026<li><tt>input_object</tt> : an object value.</li>
7027</ul>
7028</li>
7029<li>Return Value:
7030<ul>
7031
7032<li>an integer that represents the number of top-level fields in the given object,</li>
7033<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7034<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
7035</ul>
7036</li>
7037<li>
7038
7039<p>Example:</p>
7040
7041<div>
7042<div>
7043<pre class="source">object_length(
7044 {
7045 &quot;id&quot;: 1,
7046 &quot;project&quot;: &quot;AsterixDB&quot;,
7047 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7048 }
7049 );
7050</pre></div></div>
7051</li>
7052<li>
7053
7054<p>The expected result is:</p>
7055
7056<div>
7057<div>
7058<pre class="source">3
7059</pre></div></div>
7060</li>
7061</ul></div>
7062<div class="section">
7063<h3><a name="object_names"></a>object_names</h3>
7064<ul>
7065
7066<li>
7067
7068<p>Syntax:</p>
7069
7070<div>
7071<div>
7072<pre class="source">object_names(input_object)
7073</pre></div></div>
7074</li>
7075<li>
7076
7077<p>Returns names of top-level fields in the given object</p>
7078</li>
7079<li>Arguments:
7080<ul>
7081
7082<li><tt>input_object</tt> : an object value.</li>
7083</ul>
7084</li>
7085<li>Return Value:
7086<ul>
7087
7088<li>an array with top-level field names of the given object,</li>
7089<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7090<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
7091</ul>
7092</li>
7093<li>
7094
7095<p>Example:</p>
7096
7097<div>
7098<div>
7099<pre class="source">object_names(
7100 {
7101 &quot;id&quot;: 1,
7102 &quot;project&quot;: &quot;AsterixDB&quot;,
7103 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7104 }
7105 );
7106</pre></div></div>
7107</li>
7108<li>
7109
7110<p>The expected result is:</p>
7111
7112<div>
7113<div>
7114<pre class="source">[ &quot;id&quot;, &quot;project&quot;, &quot;address&quot; ]
7115</pre></div></div>
7116</li>
7117</ul></div>
7118<div class="section">
7119<h3><a name="object_remove"></a>object_remove</h3>
7120<ul>
7121
7122<li>
7123
7124<p>Syntax:</p>
7125
7126<div>
7127<div>
7128<pre class="source">object_remove(input_object, field_name)
7129</pre></div></div>
7130</li>
7131<li>
7132
7133<p>Returns a new object that has the same fields as the input object except the field to be removed</p>
7134</li>
7135<li>Arguments:
7136<ul>
7137
7138<li><tt>input_object</tt> : an object value.</li>
7139<li><tt>field_name</tt> : a string field name.</li>
7140</ul>
7141</li>
7142<li>Return Value:
7143<ul>
7144
7145<li>A new object that has the same fields as <tt>input_object</tt> except the field <tt>field_name</tt>,</li>
7146<li><tt>missing</tt> if the argument <tt>input_object</tt> or <tt>field_name</tt> is missing,</li>
7147<li><tt>null</tt> if the argument <tt>input_object</tt> is <tt>null</tt> or any other non-object value, or the argument <tt>field_name</tt> is <tt>null</tt> or any other non-string value.</li>
7148</ul>
7149</li>
7150<li>
7151
7152<p>Example:</p>
7153
7154<div>
7155<div>
7156<pre class="source">object_remove(
7157 {
7158 &quot;id&quot;: 1,
7159 &quot;project&quot;: &quot;AsterixDB&quot;,
7160 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7161 }
7162 , &quot;address&quot;
7163 );
7164</pre></div></div>
7165</li>
7166<li>
7167
7168<p>The expected result is:</p>
7169
7170<div>
7171<div>
7172<pre class="source">{
7173 &quot;id&quot;: 1,
7174 &quot;project&quot;: &quot;AsterixDB&quot;,
7175}
7176</pre></div></div>
7177</li>
7178</ul></div>
7179<div class="section">
7180<h3><a name="object_rename"></a>object_rename</h3>
7181<ul>
7182
7183<li>
7184
7185<p>Syntax:</p>
7186
7187<div>
7188<div>
7189<pre class="source">object_rename(input_object, old_field, new_field)
7190</pre></div></div>
7191</li>
7192<li>
7193
7194<p>Returns a new object that has the same fields as <tt>input_object</tt> with field <tt>old_field</tt> replaced by <tt>new_field</tt></p>
7195</li>
7196<li>Arguments:
7197<ul>
7198
7199<li><tt>input_object</tt> : an object value.</li>
7200<li><tt>old_field</tt> : a string representing the old (original) field name inside the object <tt>input_object</tt>.</li>
7201<li><tt>new_field</tt> : a string representing the new field name to replace <tt>old_field</tt> inside the object <tt>input_object</tt>.</li>
7202</ul>
7203</li>
7204<li>Return Value:
7205<ul>
7206
7207<li>A new object that has the same fields as <tt>input_object</tt> with field <tt>old_field</tt> replaced by <tt>new_field</tt>,</li>
7208<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7209<li><tt>null</tt> if any argument is <tt>null</tt> or <tt>input_object</tt> is non-object value, or <tt>old_field</tt> is non-string value, or <tt>new_field</tt> is any non-string value.</li>
7210</ul>
7211</li>
7212<li>
7213
7214<p>Example:</p>
7215
7216<div>
7217<div>
7218<pre class="source">object_rename(
7219 {
7220 &quot;id&quot;: 1,
7221 &quot;project&quot;: &quot;AsterixDB&quot;,
7222 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7223 }
7224 , &quot;address&quot;
7225 , &quot;location&quot;
7226 );
7227</pre></div></div>
7228</li>
7229<li>
7230
7231<p>The expected result is:</p>
7232
7233<div>
7234<div>
7235<pre class="source">{
7236 &quot;id&quot;: 1,
7237 &quot;project&quot;: &quot;AsterixDB&quot;,
7238 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7239}
7240</pre></div></div>
7241</li>
7242</ul></div>
7243<div class="section">
7244<h3><a name="object_unwrap"></a>object_unwrap</h3>
7245<ul>
7246
7247<li>
7248
7249<p>Syntax:</p>
7250
7251<div>
7252<div>
7253<pre class="source">object_unwrap(input_object)
7254</pre></div></div>
7255</li>
7256<li>
7257
7258<p>Returns the value of the single name-value pair that appears in <tt>input_object</tt>.</p>
7259</li>
7260<li>Arguments:
7261<ul>
7262
7263<li><tt>input_object</tt> : an object value that consists of exactly one name-value pair.</li>
7264</ul>
7265</li>
7266<li>Return Value:
7267<ul>
7268
7269<li>The value of the single name-value pair that appears in <tt>input_object</tt>,</li>
7270<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7271<li><tt>null</tt> if <tt>input_object</tt> is null, or an empty object, or there is more than one name-value pair in <tt>input_object</tt>, or any non-object value.</li>
7272</ul>
7273</li>
7274<li>
7275
7276<p>Example:</p>
7277
7278<div>
7279<div>
7280<pre class="source">object_unwrap(
7281 {
7282 &quot;id&quot;: 1
7283 }
7284 );
7285</pre></div></div>
7286</li>
7287<li>
7288
7289<p>The expected result is:</p>
7290
7291<div>
7292<div>
7293<pre class="source">{
7294 1
7295}
7296</pre></div></div>
7297</li>
7298</ul></div>
7299<div class="section">
7300<h3><a name="object_replace"></a>object_replace</h3>
7301<ul>
7302
7303<li>
7304
7305<p>Syntax:</p>
7306
7307<div>
7308<div>
7309<pre class="source">object_replace(input_object, old_value, new_value)
7310</pre></div></div>
7311</li>
7312<li>
7313
7314<p>Returns a new object that has the same fields as <tt>input_object</tt> with all occurrences of value <tt>old_value</tt> replaced by <tt>new_value</tt></p>
7315</li>
7316<li>Arguments:
7317<ul>
7318
7319<li><tt>input_object</tt> : an object value.</li>
7320<li><tt>old_value</tt> : a primitive type value to be replaced by <tt>new_value</tt>.</li>
7321<li><tt>new_value</tt> : a value to replace <tt>old_value</tt>.</li>
7322</ul>
7323</li>
7324<li>Return Value:
7325<ul>
7326
7327<li>A new object that has the same fields as <tt>input_object</tt> with all occurrences of value <tt>old_value</tt> replaced by <tt>new_value</tt>,</li>
7328<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7329<li><tt>null</tt> if <tt>input_object</tt> or <tt>old_value</tt> is null,</li>
7330<li>a type error will be raised if:
7331<ul>
7332
7333<li><tt>old_value</tt> is not a primitive type value.</li>
7334</ul>
7335</li>
7336</ul>
7337</li>
7338<li>
7339
7340<p>Example:</p>
7341
7342<div>
7343<div>
7344<pre class="source">object_replace(
7345 {
7346 &quot;id&quot;: 1,
7347 &quot;project&quot;: &quot;AsterixDB&quot;,
7348 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7349 }
7350 , &quot;AsterixDB&quot;
7351 , &quot;Apache AsterixDB&quot;
7352 );
7353</pre></div></div>
7354</li>
7355<li>
7356
7357<p>The expected result is:</p>
7358
7359<div>
7360<div>
7361<pre class="source">{
7362 &quot;id&quot;: 1,
7363 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7364 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7365}
7366</pre></div></div>
7367</li>
7368</ul></div>
7369<div class="section">
7370<h3><a name="object_add"></a>object_add</h3>
7371<ul>
7372
7373<li>
7374
7375<p>Syntax:</p>
7376
7377<div>
7378<div>
7379<pre class="source">object_add(input_object, field_name, field_value)
7380</pre></div></div>
7381</li>
7382<li>
7383
7384<p>Returns a new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>.</p>
7385</li>
7386<li>Arguments:
7387<ul>
7388
7389<li><tt>input_object</tt> : an object value.</li>
7390<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7391<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7392</ul>
7393</li>
7394<li>Return Value:
7395<ul>
7396
7397<li>A new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>,</li>
7398<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7399<li><tt>null</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>null</tt>, or <tt>input_object</tt> is not an object, or <tt>field_name</tt> is not a string,</li>
7400<li><tt>input_object</tt> if <tt>field_name</tt>already exists in <tt>input_object</tt> or <tt>field_value</tt> is missing.</li>
7401</ul>
7402</li>
7403<li>
7404
7405<p>Example:</p>
7406
7407<div>
7408<div>
7409<pre class="source">object_add(
7410 {
7411 &quot;id&quot;: 1,
7412 &quot;project&quot;: &quot;AsterixDB&quot;,
7413 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7414 }
7415 , &quot;company&quot;
7416 , &quot;Apache&quot;
7417 );
7418</pre></div></div>
7419</li>
7420<li>
7421
7422<p>The expected result is:</p>
7423
7424<div>
7425<div>
7426<pre class="source">{
7427 &quot;id&quot;: 1,
7428 &quot;project&quot;: &quot;AsterixDB&quot;,
7429 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7430 &quot;company&quot;: &quot;Apache&quot;
7431}
7432</pre></div></div>
7433</li>
7434</ul></div>
7435<div class="section">
7436<h3><a name="object_put"></a>object_put</h3>
7437<ul>
7438
7439<li>
7440
7441<p>Syntax:</p>
7442
7443<div>
7444<div>
7445<pre class="source">object_put(input_object, field_name, field_value)
7446</pre></div></div>
7447</li>
7448<li>
7449
7450<p>Adds, modifies, or removes a field of an object.</p>
7451</li>
7452<li>Arguments:
7453<ul>
7454
7455<li><tt>input_object</tt> : an object value.</li>
7456<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7457<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7458</ul>
7459</li>
7460<li>Return Value:
7461<ul>
7462
7463<li>a new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>, or with updated <tt>field_name</tt> value to <tt>field_value</tt> if <tt>field_name</tt> already exists in <tt>input_object</tt>, or with <tt>field_name</tt>removed if <tt>field_name</tt> already exists in <tt>input_object</tt> and <tt>field_value</tt> is <tt>missing</tt>,</li>
7464<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7465<li><tt>null</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>null</tt>, or <tt>input_object</tt> is not an object, or <tt>field_name</tt> is not not a string.</li>
7466</ul>
7467</li>
7468<li>
7469
7470<p>Example:</p>
7471
7472<div>
7473<div>
7474<pre class="source">object_put(
7475 {
7476 &quot;id&quot;: 1,
7477 &quot;project&quot;: &quot;AsterixDB&quot;,
7478 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7479 }
7480 , &quot;project&quot;
7481 , &quot;Apache AsterixDB&quot;
7482 );
7483</pre></div></div>
7484</li>
7485<li>
7486
7487<p>The expected result is:</p>
7488
7489<div>
7490<div>
7491<pre class="source">{
7492 &quot;id&quot;: 1,
7493 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7494 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7495}
7496</pre></div></div>
7497</li>
7498</ul></div>
7499<div class="section">
7500<h3><a name="object_values"></a>object_values</h3>
7501<ul>
7502
7503<li>
7504
7505<p>Syntax:</p>
7506
7507<div>
7508<div>
7509<pre class="source">object_values(input_object)
7510</pre></div></div>
7511</li>
7512<li>
7513
7514<p>Returns an array of the values of the fields in <tt>input_object</tt>.</p>
7515</li>
7516<li>Arguments:
7517<ul>
7518
7519<li><tt>input_object</tt> : an object value.</li>
7520</ul>
7521</li>
7522<li>Return Value:
7523<ul>
7524
7525<li>An array of the values of the fields in <tt>input_object</tt>,</li>
7526<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7527<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7528</ul>
7529</li>
7530<li>
7531
7532<p>Example:</p>
7533
7534<div>
7535<div>
7536<pre class="source">object_values(
7537 {
7538 &quot;id&quot;: 1,
7539 &quot;project&quot;: &quot;AsterixDB&quot;,
7540 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7541 }
7542 );
7543</pre></div></div>
7544</li>
7545<li>
7546
7547<p>The expected result is:</p>
7548
7549<div>
7550<div>
7551<pre class="source">[
7552 1,
7553 &quot;AsterixDB&quot;,
7554 {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7555]
7556</pre></div></div>
7557</li>
7558</ul></div>
7559<div class="section">
7560<h3><a name="object_pairs"></a>object_pairs</h3>
7561<ul>
7562
7563<li>
7564
7565<p>Syntax:</p>
7566
7567<div>
7568<div>
7569<pre class="source">object_pairs(input_object)
7570</pre></div></div>
7571</li>
7572<li>
7573
7574<p>Returns an array of objects describing fields of <tt>input_object</tt>. For each field of the <tt>input_object</tt> the returned array contains an object with two fields <tt>name</tt> and <tt>value</tt> which are set to the <tt>input_object</tt>&#x2019;s field name and value.</p>
7575</li>
7576<li>
7577
7578<p>Arguments:</p>
7579<ul>
7580
7581<li><tt>input_object</tt> : an object value.</li>
7582</ul>
7583</li>
7584<li>Return Value:
7585<ul>
7586
7587<li>An array of the <tt>name</tt>/<tt>value</tt> pairs of the fields in <tt>input_object</tt>,</li>
7588<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7589<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7590</ul>
7591</li>
7592<li>
7593
7594<p>Example:</p>
7595
7596<div>
7597<div>
7598<pre class="source">object_pairs(
7599 {
7600 &quot;id&quot;: 1,
7601 &quot;project&quot;: &quot;AsterixDB&quot;,
7602 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7603 }
7604 );
7605</pre></div></div>
7606</li>
7607<li>
7608
7609<p>The expected result is:</p>
7610
7611<div>
7612<div>
7613<pre class="source">[
7614 { &quot;name&quot;: &quot;id&quot;, &quot;value&quot;: 1 },
7615 { &quot;name&quot;: &quot;project&quot;, &quot;value&quot;: &quot;AsterixDB&quot; },
7616 { &quot;name&quot;: &quot;address&quot;, &quot;value&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;} }
7617]
7618</pre></div></div>
7619</li>
7620</ul></div>
7621<div class="section">
7622<h3><a name="pairs"></a>pairs</h3>
7623<ul>
7624
7625<li>
7626
7627<p>Syntax:</p>
7628
7629<div>
7630<div>
7631<pre class="source">pairs(input_object)
7632</pre></div></div>
7633</li>
7634<li>
7635
7636<p>Returns an array of arrays describing fields of <tt>input_object</tt>, including nested fields. For each field of the <tt>input_object</tt> the returned array contains an array with two elements. The first element is the name and the second one is the value of the <tt>input_object</tt>&#x2019;s field. The input object is introspected recursively, so all fields of its nested objects are returned. Nested objects contained in arrays and multisets are also processed by this function.</p>
7637</li>
7638<li>
7639
7640<p>Arguments:</p>
7641<ul>
7642
7643<li><tt>input_object</tt> : an object value (or an array or a multiset)</li>
7644</ul>
7645</li>
7646<li>Return Value:
7647<ul>
7648
7649<li>An array of arrays with name, value pairs of the fields in <tt>input_object</tt>, including nested fields. Each inner array has exactly two items: name and value of the <tt>input_object</tt>&#x2019;s field.</li>
7650<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7651<li><tt>null</tt> if <tt>input_object</tt> is null or a value of a primitive data type.</li>
7652</ul>
7653</li>
7654<li>
7655
7656<p>Example:</p>
7657
7658<div>
7659<div>
7660<pre class="source">pairs(
7661 {
7662 &quot;id&quot;: 1,
7663 &quot;project&quot;: &quot;AsterixDB&quot;,
7664 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7665 }
7666 );
7667</pre></div></div>
7668</li>
7669<li>
7670
7671<p>The expected result is:</p>
7672
7673<div>
7674<div>
7675<pre class="source">[
7676 [ &quot;id&quot;, 1 ],
7677 [ &quot;project&quot;, &quot;AsterixDB&quot; ],
7678 [ &quot;address&quot;, { &quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot; } ],
7679 [ &quot;city&quot;, &quot;Irvine&quot; ],
7680 [ &quot;state&quot;, &quot;CA&quot; ]
7681]
7682</pre></div></div>
7683</li>
7684</ul><!--
7685 ! Licensed to the Apache Software Foundation (ASF) under one
7686 ! or more contributor license agreements. See the NOTICE file
7687 ! distributed with this work for additional information
7688 ! regarding copyright ownership. The ASF licenses this file
7689 ! to you under the Apache License, Version 2.0 (the
7690 ! "License"); you may not use this file except in compliance
7691 ! with the License. You may obtain a copy of the License at
7692 !
7693 ! http://www.apache.org/licenses/LICENSE-2.0
7694 !
7695 ! Unless required by applicable law or agreed to in writing,
7696 ! software distributed under the License is distributed on an
7697 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7698 ! KIND, either express or implied. See the License for the
7699 ! specific language governing permissions and limitations
7700 ! under the License.
7701 !-->
7702</div></div>
7703<div class="section">
7704<h2><a name="Aggregate_Functions_.28Array_Functions.29"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions (Array Functions) </a></h2>
7705<p>This section contains detailed descriptions of the built-in aggregate functions in the query language.</p>
7706<p>The query language also supports standard SQL aggregate functions (e.g., <tt>MIN</tt>, <tt>MAX</tt>, <tt>SUM</tt>, <tt>COUNT</tt>, and <tt>AVG</tt>). Note that these are not real functions in the query language, but just syntactic sugars over corresponding builtin aggregate functions (e.g., <tt>ARRAY_MIN</tt>, <tt>ARRAY_MAX</tt>, <tt>ARRAY_SUM</tt>, <tt>ARRAY_COUNT</tt>, and <tt>ARRAY_AVG</tt>). Refer to <a href="manual.html#Aggregation_PseudoFunctions">Aggregation Pseudo-Functions</a> for details.</p>
7707<p>The <tt>DISTINCT</tt> keyword may be used with built-in aggregate functions and standard SQL aggregate functions. It may also be used with aggregate functions used as window functions. It determines whether the function aggregates all values in the group, or distinct values only. Refer to <a href="manual.html#Function_call_expressions">Function Calls</a> for details.</p>
7708<p>Aggregate functions may be used as window functions when they are used with an OVER clause. Refer to <a href="manual.html#Over_clauses">OVER Clauses</a> for details.</p>
7709<div class="section">
7710<h3><a name="array_count"></a>array_count</h3>
7711<ul>
7712
7713<li>
7714
7715<p>Syntax:</p>
7716
7717<div>
7718<div>
7719<pre class="source">array_count(collection)
7720</pre></div></div>
7721</li>
7722<li>
7723
7724<p>Gets the number of non-null and non-missing items in the given collection.</p>
7725</li>
7726<li>Arguments:
7727<ul>
7728
7729<li><tt>collection</tt> could be:
7730<ul>
7731
7732<li>an <tt>array</tt> or <tt>multiset</tt> to be counted,</li>
7733<li>or, a <tt>null</tt> value,</li>
7734<li>or, a <tt>missing</tt> value.</li>
7735</ul>
7736</li>
7737</ul>
7738</li>
7739<li>Return Value:
7740<ul>
7741
7742<li>a <tt>bigint</tt> value representing the number of non-null and non-missing items in the given collection,</li>
7743<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7744<li>any other non-array and non-multiset input value will cause an error.</li>
7745</ul>
7746</li>
7747<li>
7748
7749<p>Example:</p>
7750
7751<div>
7752<div>
7753<pre class="source">array_count( ['hello', 'world', 1, 2, 3, null, missing] );
7754</pre></div></div>
7755</li>
7756<li>
7757
7758<p>The expected result is:</p>
7759
7760<div>
7761<div>
7762<pre class="source">5
7763</pre></div></div>
7764</li>
7765</ul></div>
7766<div class="section">
7767<h3><a name="array_avg"></a>array_avg</h3>
7768<ul>
7769
7770<li>
7771
7772<p>Syntax:</p>
7773
7774<div>
7775<div>
7776<pre class="source">array_avg(num_collection)
7777</pre></div></div>
7778</li>
7779<li>
7780
7781<p>Gets the average value of the non-null and non-missing numeric items in the given collection.</p>
7782</li>
7783<li>Arguments:
7784<ul>
7785
7786<li><tt>num_collection</tt> could be:
7787<ul>
7788
7789<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7790<li>or, a <tt>null</tt> value,</li>
7791<li>or, a <tt>missing</tt> value.</li>
7792</ul>
7793</li>
7794</ul>
7795</li>
7796<li>Return Value:
7797<ul>
7798
7799<li>a <tt>double</tt> value representing the average of the non-null and non-missing numbers in the given collection,</li>
7800<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7801<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7802<li>any other non-array and non-multiset input value will cause a type error,</li>
7803<li>any other non-numeric value in the input collection will cause a type error.</li>
7804</ul>
7805</li>
7806<li>
7807
7808<p>Example:</p>
7809
7810<div>
7811<div>
7812<pre class="source">array_avg( [1.2, 2.3, 3.4, 0, null] );
7813</pre></div></div>
7814</li>
7815<li>
7816
7817<p>The expected result is:</p>
7818
7819<div>
7820<div>
7821<pre class="source">1.725
7822</pre></div></div>
7823</li>
7824</ul></div>
7825<div class="section">
7826<h3><a name="array_sum"></a>array_sum</h3>
7827<ul>
7828
7829<li>
7830
7831<p>Syntax:</p>
7832
7833<div>
7834<div>
7835<pre class="source">array_sum(num_collection)
7836</pre></div></div>
7837</li>
7838<li>
7839
7840<p>Gets the sum of non-null and non-missing items in the given collection.</p>
7841</li>
7842<li>Arguments:
7843<ul>
7844
7845<li><tt>num_collection</tt> could be:
7846<ul>
7847
7848<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7849<li>or, a <tt>null</tt> value,</li>
7850<li>or, a <tt>missing</tt> value.</li>
7851</ul>
7852</li>
7853</ul>
7854</li>
7855<li>Return Value:
7856<ul>
7857
7858<li>the sum of the non-null and non-missing numbers in the given collection. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items.</li>
7859<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7860<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7861<li>any other non-array and non-multiset input value will cause a type error,</li>
7862<li>any other non-numeric value in the input collection will cause a type error.</li>
7863</ul>
7864</li>
7865<li>
7866
7867<p>Example:</p>
7868
7869<div>
7870<div>
7871<pre class="source">array_sum( [1.2, 2.3, 3.4, 0, null, missing] );
7872</pre></div></div>
7873</li>
7874<li>
7875
7876<p>The expected result is:</p>
7877
7878<div>
7879<div>
7880<pre class="source">6.9
7881</pre></div></div>
7882</li>
7883</ul></div>
7884<div class="section">
7885<h3><a name="array_min"></a>array_min</h3>
7886<ul>
7887
7888<li>
7889
7890<p>Syntax:</p>
7891
7892<div>
7893<div>
7894<pre class="source">array_min(num_collection)
7895</pre></div></div>
7896</li>
7897<li>
7898
7899<p>Gets the min value of non-null and non-missing comparable items in the given collection.</p>
7900</li>
7901<li>Arguments:
7902<ul>
7903
7904<li><tt>num_collection</tt> could be:
7905<ul>
7906
7907<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7908<li>or, a <tt>null</tt> value,</li>
7909<li>or, a <tt>missing</tt> value.</li>
7910</ul>
7911</li>
7912</ul>
7913</li>
7914<li>Return Value:
7915<ul>
7916
7917<li>the min value of non-null and non-missing values in the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among numeric items.</li>
7918<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7919<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7920<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7921<li>any other non-array and non-multiset input value will cause a type error.</li>
7922</ul>
7923</li>
7924<li>
7925
7926<p>Example:</p>
7927
7928<div>
7929<div>
7930<pre class="source">array_min( [1.2, 2.3, 3.4, 0, null, missing] );
7931</pre></div></div>
7932</li>
7933<li>
7934
7935<p>The expected result is:</p>
7936
7937<div>
7938<div>
7939<pre class="source">0.0
7940</pre></div></div>
7941</li>
7942</ul></div>
7943<div class="section">
7944<h3><a name="array_max"></a>array_max</h3>
7945<ul>
7946
7947<li>
7948
7949<p>Syntax:</p>
7950
7951<div>
7952<div>
7953<pre class="source">array_max(num_collection)
7954</pre></div></div>
7955</li>
7956<li>
7957
7958<p>Gets the max value of the non-null and non-missing comparable items in the given collection.</p>
7959</li>
7960<li>Arguments:
7961<ul>
7962
7963<li><tt>num_collection</tt> could be:
7964<ul>
7965
7966<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7967<li>or, a <tt>null</tt> value,</li>
7968<li>or, a <tt>missing</tt> value.</li>
7969</ul>
7970</li>
7971</ul>
7972</li>
7973<li>Return Value:
7974<ul>
7975
7976<li>the max value of non-null and non-missing numbers in the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among numeric items.</li>
7977<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7978<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7979<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7980<li>any other non-array and non-multiset input value will cause a type error.</li>
7981</ul>
7982</li>
7983<li>
7984
7985<p>Example:</p>
7986
7987<div>
7988<div>
7989<pre class="source">array_max( [1.2, 2.3, 3.4, 0, null, missing] );
7990</pre></div></div>
7991</li>
7992<li>
7993
7994<p>The expected result is:</p>
7995
7996<div>
7997<div>
7998<pre class="source">3.4
7999</pre></div></div>
8000</li>
8001</ul></div>
8002<div class="section">
8003<h3><a name="array_stddev_samp"></a>array_stddev_samp</h3>
8004<ul>
8005
8006<li>
8007
8008<p>Syntax:</p>
8009
8010<div>
8011<div>
8012<pre class="source">array_stddev_samp(num_collection)
8013</pre></div></div>
8014</li>
8015<li>
8016
8017<p>Gets the sample standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
8018</li>
8019<li>Arguments:
8020<ul>
8021
8022<li><tt>num_collection</tt> could be:
8023<ul>
8024
8025<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8026<li>or, a <tt>null</tt> value,</li>
8027<li>or, a <tt>missing</tt> value.</li>
8028</ul>
8029</li>
8030</ul>
8031</li>
8032<li>Return Value:
8033<ul>
8034
8035<li>a <tt>double</tt> value representing the sample standard deviation of the non-null and non-missing numbers in the given collection,</li>
8036<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8037<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8038<li>any other non-array and non-multiset input value will cause a type error,</li>
8039<li>any other non-numeric value in the input collection will cause a type error.</li>
8040</ul>
8041</li>
8042<li>
8043
8044<p>Example:</p>
8045
8046<div>
8047<div>
8048<pre class="source">array_stddev_samp( [1.2, 2.3, 3.4, 0, null] );
8049</pre></div></div>
8050</li>
8051<li>
8052
8053<p>The expected result is:</p>
8054
8055<div>
8056<div>
8057<pre class="source">1.4591664287073858
8058</pre></div></div>
8059</li>
8060</ul></div>
8061<div class="section">
8062<h3><a name="array_stddev_pop"></a>array_stddev_pop</h3>
8063<ul>
8064
8065<li>
8066
8067<p>Syntax:</p>
8068
8069<div>
8070<div>
8071<pre class="source">array_stddev_pop(num_collection)
8072</pre></div></div>
8073</li>
8074<li>
8075
8076<p>Gets the population standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
8077</li>
8078<li>Arguments:
8079<ul>
8080
8081<li><tt>num_collection</tt> could be:
8082<ul>
8083
8084<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8085<li>or, a <tt>null</tt> value,</li>
8086<li>or, a <tt>missing</tt> value.</li>
8087</ul>
8088</li>
8089</ul>
8090</li>
8091<li>Return Value:
8092<ul>
8093
8094<li>a <tt>double</tt> value representing the population standard deviation of the non-null and non-missing numbers in the given collection,</li>
8095<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8096<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8097<li>any other non-array and non-multiset input value will cause a type error,</li>
8098<li>any other non-numeric value in the input collection will cause a type error.</li>
8099</ul>
8100</li>
8101<li>
8102
8103<p>Example:</p>
8104
8105<div>
8106<div>
8107<pre class="source">array_stddev_pop( [1.2, 2.3, 3.4, 0, null] );
8108</pre></div></div>
8109</li>
8110<li>
8111
8112<p>The expected result is:</p>
8113
8114<div>
8115<div>
8116<pre class="source">1.2636751956100112
8117</pre></div></div>
8118</li>
8119</ul></div>
8120<div class="section">
8121<h3><a name="array_var_samp"></a>array_var_samp</h3>
8122<ul>
8123
8124<li>
8125
8126<p>Syntax:</p>
8127
8128<div>
8129<div>
8130<pre class="source">array_var_samp(num_collection)
8131</pre></div></div>
8132</li>
8133<li>
8134
8135<p>Gets the sample variance value of the non-null and non-missing numeric items in the given collection.</p>
8136</li>
8137<li>Arguments:
8138<ul>
8139
8140<li><tt>num_collection</tt> could be:
8141<ul>
8142
8143<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8144<li>or, a <tt>null</tt> value,</li>
8145<li>or, a <tt>missing</tt> value.</li>
8146</ul>
8147</li>
8148</ul>
8149</li>
8150<li>Return Value:
8151<ul>
8152
8153<li>a <tt>double</tt> value representing the sample variance of the non-null and non-missing numbers in the given collection,</li>
8154<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8155<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8156<li>any other non-array and non-multiset input value will cause a type error,</li>
8157<li>any other non-numeric value in the input collection will cause a type error.</li>
8158</ul>
8159</li>
8160<li>
8161
8162<p>Example:</p>
8163
8164<div>
8165<div>
8166<pre class="source">array_var_samp( [1.2, 2.3, 3.4, 0, null] );
8167</pre></div></div>
8168</li>
8169<li>
8170
8171<p>The expected result is:</p>
8172
8173<div>
8174<div>
8175<pre class="source">2.1291666666666664
8176</pre></div></div>
8177</li>
8178</ul></div>
8179<div class="section">
8180<h3><a name="array_var_pop"></a>array_var_pop</h3>
8181<ul>
8182
8183<li>
8184
8185<p>Syntax:</p>
8186
8187<div>
8188<div>
8189<pre class="source">array_var_pop(num_collection)
8190</pre></div></div>
8191</li>
8192<li>
8193
8194<p>Gets the population variance value of the non-null and non-missing numeric items in the given collection.</p>
8195</li>
8196<li>Arguments:
8197<ul>
8198
8199<li><tt>num_collection</tt> could be:
8200<ul>
8201
8202<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8203<li>or, a <tt>null</tt> value,</li>
8204<li>or, a <tt>missing</tt> value.</li>
8205</ul>
8206</li>
8207</ul>
8208</li>
8209<li>Return Value:
8210<ul>
8211
8212<li>a <tt>double</tt> value representing the population variance of the non-null and non-missing numbers in the given collection,</li>
8213<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8214<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8215<li>any other non-array and non-multiset input value will cause a type error,</li>
8216<li>any other non-numeric value in the input collection will cause a type error.</li>
8217</ul>
8218</li>
8219<li>
8220
8221<p>Example:</p>
8222
8223<div>
8224<div>
8225<pre class="source">array_var_pop( [1.2, 2.3, 3.4, 0, null] );
8226</pre></div></div>
8227</li>
8228<li>
8229
8230<p>The expected result is:</p>
8231
8232<div>
8233<div>
8234<pre class="source">1.5968749999999998
8235</pre></div></div>
8236</li>
8237</ul></div>
8238<div class="section">
8239<h3><a name="array_skewness"></a>array_skewness</h3>
8240<ul>
8241
8242<li>
8243
8244<p>Syntax:</p>
8245
8246<div>
8247<div>
8248<pre class="source">array_skewness(num_collection)
8249</pre></div></div>
8250</li>
8251<li>
8252
8253<p>Gets the skewness value of the non-null and non-missing numeric items in the given collection.</p>
8254</li>
8255<li>Arguments:
8256<ul>
8257
8258<li><tt>num_collection</tt> could be:
8259<ul>
8260
8261<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8262<li>or, a <tt>null</tt> value,</li>
8263<li>or, a <tt>missing</tt> value.</li>
8264</ul>
8265</li>
8266</ul>
8267</li>
8268<li>Return Value:
8269<ul>
8270
8271<li>a <tt>double</tt> value representing the skewness of the non-null and non-missing numbers in the given collection,</li>
8272<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8273<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8274<li>any other non-array and non-multiset input value will cause a type error,</li>
8275<li>any other non-numeric value in the input collection will cause a type error.</li>
8276</ul>
8277</li>
8278<li>
8279
8280<p>Example:</p>
8281
8282<div>
8283<div>
8284<pre class="source">array_skewness( [1.2, 2.3, 3.4, 0, null] );
8285</pre></div></div>
8286</li>
8287<li>
8288
8289<p>The expected result is:</p>
8290
8291<div>
8292<div>
8293<pre class="source">-0.04808451539164242
8294</pre></div></div>
8295</li>
8296</ul></div>
8297<div class="section">
8298<h3><a name="array_kurtosis"></a>array_kurtosis</h3>
8299<ul>
8300
8301<li>
8302
8303<p>Syntax:</p>
8304
8305<div>
8306<div>
8307<pre class="source">array_kurtosis(num_collection)
8308</pre></div></div>
8309</li>
8310<li>
8311
8312<p>Gets the kurtosis value from the normal distribution of the non-null and non-missing numeric items in the given collection.</p>
8313</li>
8314<li>Arguments:
8315<ul>
8316
8317<li><tt>num_collection</tt> could be:
8318<ul>
8319
8320<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8321<li>or, a <tt>null</tt> value,</li>
8322<li>or, a <tt>missing</tt> value.</li>
8323</ul>
8324</li>
8325</ul>
8326</li>
8327<li>Return Value:
8328<ul>
8329
8330<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the non-null and non-missing numbers in the given collection,</li>
8331<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8332<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8333<li>any other non-array and non-multiset input value will cause a type error,</li>
8334<li>any other non-numeric value in the input collection will cause a type error.</li>
8335</ul>
8336</li>
8337<li>
8338
8339<p>Example:</p>
8340
8341<div>
8342<div>
8343<pre class="source">array_kurtosis( [1.2, 2.3, 3.4, 0, null] );
8344</pre></div></div>
8345</li>
8346<li>
8347
8348<p>The expected result is:</p>
8349
8350<div>
8351<div>
8352<pre class="source">-1.342049701096427
8353</pre></div></div>
8354</li>
8355</ul></div>
8356<div class="section">
8357<h3><a name="strict_count"></a>strict_count</h3>
8358<ul>
8359
8360<li>
8361
8362<p>Syntax:</p>
8363
8364<div>
8365<div>
8366<pre class="source">strict_count(collection)
8367</pre></div></div>
8368</li>
8369<li>
8370
8371<p>Gets the number of items in the given collection.</p>
8372</li>
8373<li>Arguments:
8374<ul>
8375
8376<li><tt>collection</tt> could be:
8377<ul>
8378
8379<li>an <tt>array</tt> or <tt>multiset</tt> containing the items to be counted,</li>
8380<li>or a <tt>null</tt> value,</li>
8381<li>or a <tt>missing</tt> value.</li>
8382</ul>
8383</li>
8384</ul>
8385</li>
8386<li>Return Value:
8387<ul>
8388
8389<li>a <tt>bigint</tt> value representing the number of items in the given collection,</li>
8390<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>.</li>
8391</ul>
8392</li>
8393<li>
8394
8395<p>Example:</p>
8396
8397<div>
8398<div>
8399<pre class="source">strict_count( [1, 2, null, missing] );
8400</pre></div></div>
8401</li>
8402<li>
8403
8404<p>The expected result is:</p>
8405
8406<div>
8407<div>
8408<pre class="source">4
8409</pre></div></div>
8410</li>
8411</ul></div>
8412<div class="section">
8413<h3><a name="strict_avg"></a>strict_avg</h3>
8414<ul>
8415
8416<li>
8417
8418<p>Syntax:</p>
8419
8420<div>
8421<div>
8422<pre class="source">strict_avg(num_collection)
8423</pre></div></div>
8424</li>
8425<li>
8426
8427<p>Gets the average value of the numeric items in the given collection.</p>
8428</li>
8429<li>Arguments:
8430<ul>
8431
8432<li><tt>num_collection</tt> could be:
8433<ul>
8434
8435<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8436<li>or, a <tt>null</tt> value,</li>
8437<li>or, a <tt>missing</tt> value.</li>
8438</ul>
8439</li>
8440</ul>
8441</li>
8442<li>Return Value:
8443<ul>
8444
8445<li>a <tt>double</tt> value representing the average of the numbers in the given collection,</li>
8446<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8447<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8448<li>any other non-numeric value in the input collection will cause a type error.</li>
8449</ul>
8450</li>
8451<li>
8452
8453<p>Example:</p>
8454
8455<div>
8456<div>
8457<pre class="source">strict_avg( [100, 200, 300] );
8458</pre></div></div>
8459</li>
8460<li>
8461
8462<p>The expected result is:</p>
8463
8464<div>
8465<div>
8466<pre class="source">200.0
8467</pre></div></div>
8468</li>
8469</ul></div>
8470<div class="section">
8471<h3><a name="strict_sum"></a>strict_sum</h3>
8472<ul>
8473
8474<li>
8475
8476<p>Syntax:</p>
8477
8478<div>
8479<div>
8480<pre class="source">strict_sum(num_collection)
8481</pre></div></div>
8482</li>
8483<li>
8484
8485<p>Gets the sum of the items in the given collection.</p>
8486</li>
8487<li>Arguments:
8488<ul>
8489
8490<li><tt>num_collection</tt> could be:
8491<ul>
8492
8493<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8494<li>or, a <tt>null</tt> value,</li>
8495<li>or, a <tt>missing</tt> value.</li>
8496</ul>
8497</li>
8498</ul>
8499</li>
8500<li>Return Value:
8501<ul>
8502
8503<li>the sum of the numbers in the given collection. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items.</li>
8504<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8505<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8506<li>any other non-numeric value in the input collection will cause a type error.</li>
8507</ul>
8508</li>
8509<li>
8510
8511<p>Example:</p>
8512
8513<div>
8514<div>
8515<pre class="source">strict_sum( [100, 200, 300] );
8516</pre></div></div>
8517</li>
8518<li>
8519
8520<p>The expected result is:</p>
8521
8522<div>
8523<div>
8524<pre class="source">600
8525</pre></div></div>
8526</li>
8527</ul></div>
8528<div class="section">
8529<h3><a name="strict_min"></a>strict_min</h3>
8530<ul>
8531
8532<li>
8533
8534<p>Syntax:</p>
8535
8536<div>
8537<div>
8538<pre class="source">strict_min(num_collection)
8539</pre></div></div>
8540</li>
8541<li>
8542
8543<p>Gets the min value of comparable items in the given collection.</p>
8544</li>
8545<li>Arguments:
8546<ul>
8547
8548<li><tt>num_collection</tt> could be:
8549<ul>
8550
8551<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8552<li>or, a <tt>null</tt> value,</li>
8553<li>or, a <tt>missing</tt> value.</li>
8554</ul>
8555</li>
8556</ul>
8557</li>
8558<li>Return Value:
8559<ul>
8560
8561<li>the min value of the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among numeric items.</li>
8562<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8563<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8564<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8565<li>any other non-array and non-multiset input value will cause a type error.</li>
8566</ul>
8567</li>
8568<li>
8569
8570<p>Example:</p>
8571
8572<div>
8573<div>
8574<pre class="source">strict_min( [10.2, 100, 5] );
8575</pre></div></div>
8576</li>
8577<li>
8578
8579<p>The expected result is:</p>
8580
8581<div>
8582<div>
8583<pre class="source">5.0
8584</pre></div></div>
8585</li>
8586</ul></div>
8587<div class="section">
8588<h3><a name="strict_max"></a>strict_max</h3>
8589<ul>
8590
8591<li>
8592
8593<p>Syntax:</p>
8594
8595<div>
8596<div>
8597<pre class="source">strict_max(num_collection)
8598</pre></div></div>
8599</li>
8600<li>
8601
8602<p>Gets the max value of numeric items in the given collection.</p>
8603</li>
8604<li>Arguments:
8605<ul>
8606
8607<li><tt>num_collection</tt> could be:
8608<ul>
8609
8610<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8611<li>or, a <tt>null</tt> value,</li>
8612<li>or, a <tt>missing</tt> value.</li>
8613</ul>
8614</li>
8615</ul>
8616</li>
8617<li>Return Value:
8618<ul>
8619
8620<li>The max value of the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among numeric items.</li>
8621<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8622<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8623<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8624<li>any other non-array and non-multiset input value will cause a type error.</li>
8625</ul>
8626</li>
8627<li>
8628
8629<p>Example:</p>
8630
8631<div>
8632<div>
8633<pre class="source">strict_max( [10.2, 100, 5] );
8634</pre></div></div>
8635</li>
8636<li>
8637
8638<p>The expected result is:</p>
8639
8640<div>
8641<div>
8642<pre class="source">100.0
8643</pre></div></div>
8644</li>
8645</ul></div>
8646<div class="section">
8647<h3><a name="strict_stddev_samp"></a>strict_stddev_samp</h3>
8648<ul>
8649
8650<li>
8651
8652<p>Syntax:</p>
8653
8654<div>
8655<div>
8656<pre class="source">strict_stddev_samp(num_collection)
8657</pre></div></div>
8658</li>
8659<li>
8660
8661<p>Gets the sample standard deviation value of the numeric items in the given collection.</p>
8662</li>
8663<li>Arguments:
8664<ul>
8665
8666<li><tt>num_collection</tt> could be:
8667<ul>
8668
8669<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8670<li>or, a <tt>null</tt> value,</li>
8671<li>or, a <tt>missing</tt> value.</li>
8672</ul>
8673</li>
8674</ul>
8675</li>
8676<li>Return Value:
8677<ul>
8678
8679<li>a <tt>double</tt> value representing the sample standard deviation of the numbers in the given collection,</li>
8680<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8681<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8682<li>any other non-numeric value in the input collection will cause a type error.</li>
8683</ul>
8684</li>
8685<li>
8686
8687<p>Example:</p>
8688
8689<div>
8690<div>
8691<pre class="source">strict_stddev_samp( [100, 200, 300] );
8692</pre></div></div>
8693</li>
8694<li>
8695
8696<p>The expected result is:</p>
8697
8698<div>
8699<div>
8700<pre class="source">100.0
8701</pre></div></div>
8702</li>
8703</ul></div>
8704<div class="section">
8705<h3><a name="strict_stddev_pop"></a>strict_stddev_pop</h3>
8706<ul>
8707
8708<li>
8709
8710<p>Syntax:</p>
8711
8712<div>
8713<div>
8714<pre class="source">strict_stddev_pop(num_collection)
8715</pre></div></div>
8716</li>
8717<li>
8718
8719<p>Gets the population standard deviation value of the numeric items in the given collection.</p>
8720</li>
8721<li>Arguments:
8722<ul>
8723
8724<li><tt>num_collection</tt> could be:
8725<ul>
8726
8727<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8728<li>or, a <tt>null</tt> value,</li>
8729<li>or, a <tt>missing</tt> value.</li>
8730</ul>
8731</li>
8732</ul>
8733</li>
8734<li>Return Value:
8735<ul>
8736
8737<li>a <tt>double</tt> value representing the population standard deviation of the numbers in the given collection,</li>
8738<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8739<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8740<li>any other non-numeric value in the input collection will cause a type error.</li>
8741</ul>
8742</li>
8743<li>
8744
8745<p>Example:</p>
8746
8747<div>
8748<div>
8749<pre class="source">strict_stddev_pop( [100, 200, 300] );
8750</pre></div></div>
8751</li>
8752<li>
8753
8754<p>The expected result is:</p>
8755
8756<div>
8757<div>
8758<pre class="source">81.64965809277261
8759</pre></div></div>
8760</li>
8761</ul></div>
8762<div class="section">
8763<h3><a name="strict_var_samp"></a>strict_var_samp</h3>
8764<ul>
8765
8766<li>
8767
8768<p>Syntax:</p>
8769
8770<div>
8771<div>
8772<pre class="source">strict_var_samp(num_collection)
8773</pre></div></div>
8774</li>
8775<li>
8776
8777<p>Gets the sample variance value of the numeric items in the given collection.</p>
8778</li>
8779<li>Arguments:
8780<ul>
8781
8782<li><tt>num_collection</tt> could be:
8783<ul>
8784
8785<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8786<li>or, a <tt>null</tt> value,</li>
8787<li>or, a <tt>missing</tt> value.</li>
8788</ul>
8789</li>
8790</ul>
8791</li>
8792<li>Return Value:
8793<ul>
8794
8795<li>a <tt>double</tt> value representing the sample variance of the numbers in the given collection,</li>
8796<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8797<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8798<li>any other non-numeric value in the input collection will cause a type error.</li>
8799</ul>
8800</li>
8801<li>
8802
8803<p>Example:</p>
8804
8805<div>
8806<div>
8807<pre class="source">strict_var_samp( [100, 200, 300] );
8808</pre></div></div>
8809</li>
8810<li>
8811
8812<p>The expected result is:</p>
8813
8814<div>
8815<div>
8816<pre class="source">10000.0
8817</pre></div></div>
8818</li>
8819</ul></div>
8820<div class="section">
8821<h3><a name="strict_var_pop"></a>strict_var_pop</h3>
8822<ul>
8823
8824<li>
8825
8826<p>Syntax:</p>
8827
8828<div>
8829<div>
8830<pre class="source">strict_var_pop(num_collection)
8831</pre></div></div>
8832</li>
8833<li>
8834
8835<p>Gets the population variance value of the numeric items in the given collection.</p>
8836</li>
8837<li>Arguments:
8838<ul>
8839
8840<li><tt>num_collection</tt> could be:
8841<ul>
8842
8843<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8844<li>or, a <tt>null</tt> value,</li>
8845<li>or, a <tt>missing</tt> value.</li>
8846</ul>
8847</li>
8848</ul>
8849</li>
8850<li>Return Value:
8851<ul>
8852
8853<li>a <tt>double</tt> value representing the population variance of the numbers in the given collection,</li>
8854<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8855<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8856<li>any other non-numeric value in the input collection will cause a type error.</li>
8857</ul>
8858</li>
8859<li>
8860
8861<p>Example:</p>
8862
8863<div>
8864<div>
8865<pre class="source">strict_var_pop( [100, 200, 300] );
8866</pre></div></div>
8867</li>
8868<li>
8869
8870<p>The expected result is:</p>
8871
8872<div>
8873<div>
8874<pre class="source">6666.666666666667
8875</pre></div></div>
8876</li>
8877</ul></div>
8878<div class="section">
8879<h3><a name="strict_skewness"></a>strict_skewness</h3>
8880<ul>
8881
8882<li>
8883
8884<p>Syntax:</p>
8885
8886<div>
8887<div>
8888<pre class="source">strict_skewness(num_collection)
8889</pre></div></div>
8890</li>
8891<li>
8892
8893<p>Gets the skewness value of the numeric items in the given collection.</p>
8894</li>
8895<li>Arguments:
8896<ul>
8897
8898<li><tt>num_collection</tt> could be:
8899<ul>
8900
8901<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8902<li>or, a <tt>null</tt> value,</li>
8903<li>or, a <tt>missing</tt> value.</li>
8904</ul>
8905</li>
8906</ul>
8907</li>
8908<li>Return Value:
8909<ul>
8910
8911<li>a <tt>double</tt> value representing the skewness of the numbers in the given collection,</li>
8912<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8913<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8914<li>any other non-numeric value in the input collection will cause a type error.</li>
8915</ul>
8916</li>
8917<li>
8918
8919<p>Example:</p>
8920
8921<div>
8922<div>
8923<pre class="source">strict_skewness( [100, 200, 300] );
8924</pre></div></div>
8925</li>
8926<li>
8927
8928<p>The expected result is:</p>
8929
8930<div>
8931<div>
8932<pre class="source">0.0
8933</pre></div></div>
8934</li>
8935</ul></div>
8936<div class="section">
8937<h3><a name="strict_kurtosis"></a>strict_kurtosis</h3>
8938<ul>
8939
8940<li>
8941
8942<p>Syntax:</p>
8943
8944<div>
8945<div>
8946<pre class="source">strict_kurtosis(num_collection)
8947</pre></div></div>
8948</li>
8949<li>
8950
8951<p>Gets the kurtosis value from the normal distribution of the numeric items in the given collection.</p>
8952</li>
8953<li>Arguments:
8954<ul>
8955
8956<li><tt>num_collection</tt> could be:
8957<ul>
8958
8959<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8960<li>or, a <tt>null</tt> value,</li>
8961<li>or, a <tt>missing</tt> value.</li>
8962</ul>
8963</li>
8964</ul>
8965</li>
8966<li>Return Value:
8967<ul>
8968
8969<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the numbers in the given collection,</li>
8970<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8971<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8972<li>any other non-numeric value in the input collection will cause a type error.</li>
8973</ul>
8974</li>
8975<li>
8976
8977<p>Example:</p>
8978
8979<div>
8980<div>
8981<pre class="source">strict_kurtosis( [100, 200, 300] );
8982</pre></div></div>
8983</li>
8984<li>
8985
8986<p>The expected result is:</p>
8987
8988<div>
8989<div>
8990<pre class="source">-1.5
8991</pre></div></div>
8992</li>
8993</ul><!--
8994 ! Licensed to the Apache Software Foundation (ASF) under one
8995 ! or more contributor license agreements. See the NOTICE file
8996 ! distributed with this work for additional information
8997 ! regarding copyright ownership. The ASF licenses this file
8998 ! to you under the Apache License, Version 2.0 (the
8999 ! "License"); you may not use this file except in compliance
9000 ! with the License. You may obtain a copy of the License at
9001 !
9002 ! http://www.apache.org/licenses/LICENSE-2.0
9003 !
9004 ! Unless required by applicable law or agreed to in writing,
9005 ! software distributed under the License is distributed on an
9006 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9007 ! KIND, either express or implied. See the License for the
9008 ! specific language governing permissions and limitations
9009 ! under the License.
9010 !-->
9011</div></div>
9012<div class="section">
9013<h2><a name="Comparison_Functions"></a><a name="ComparisonFunctions" id="ComparisonFunctions">Comparison Functions</a></h2>
9014<div class="section">
9015<h3><a name="greatest"></a>greatest</h3>
9016<ul>
9017
9018<li>
9019
9020<p>Syntax:</p>
9021
9022<div>
9023<div>
9024<pre class="source">greatest(numeric_value1, numeric_value2, ...)
9025</pre></div></div>
9026</li>
9027<li>
9028
9029<p>Computes the greatest value among arguments.</p>
9030</li>
9031<li>Arguments:
9032<ul>
9033
9034<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
9035<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
9036<li>&#x2026;.</li>
9037</ul>
9038</li>
9039<li>Return Value:
9040<ul>
9041
9042<li>the greatest values among arguments. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items.</li>
9043<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
9044<li>any other non-numeric input value will cause a type error.</li>
9045</ul>
9046</li>
9047<li>
9048
9049<p>Example:</p>
9050
9051<div>
9052<div>
9053<pre class="source">{ &quot;v1&quot;: greatest(1, 2, 3), &quot;v2&quot;: greatest(float(&quot;0.5&quot;), double(&quot;-0.5&quot;), 5000) };
9054</pre></div></div>
9055</li>
9056<li>
9057
9058<p>The expected result is:</p>
9059
9060<div>
9061<div>
9062<pre class="source">{ &quot;v1&quot;: 3, &quot;v2&quot;: 5000.0 }
9063</pre></div></div>
9064</li>
9065</ul></div>
9066<div class="section">
9067<h3><a name="least"></a>least</h3>
9068<ul>
9069
9070<li>
9071
9072<p>Syntax:</p>
9073
9074<div>
9075<div>
9076<pre class="source">least(numeric_value1, numeric_value2, ...)
9077</pre></div></div>
9078</li>
9079<li>
9080
9081<p>Computes the least value among arguments.</p>
9082</li>
9083<li>Arguments:
9084<ul>
9085
9086<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
9087<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
9088<li>&#x2026;.</li>
9089</ul>
9090</li>
9091<li>Return Value:
9092<ul>
9093
9094<li>the least values among arguments. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items.</li>
9095<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
9096<li>any other non-numeric input value will cause a type error.</li>
9097</ul>
9098</li>
9099<li>
9100
9101<p>Example:</p>
9102
9103<div>
9104<div>
9105<pre class="source">{ &quot;v1&quot;: least(1, 2, 3), &quot;v2&quot;: least(float(&quot;0.5&quot;), double(&quot;-0.5&quot;), 5000) };
9106</pre></div></div>
9107</li>
9108<li>
9109
9110<p>The expected result is:</p>
9111
9112<div>
9113<div>
9114<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: -0.5 }
9115</pre></div></div>
9116</li>
9117</ul><!--
9118 ! Licensed to the Apache Software Foundation (ASF) under one
9119 ! or more contributor license agreements. See the NOTICE file
9120 ! distributed with this work for additional information
9121 ! regarding copyright ownership. The ASF licenses this file
9122 ! to you under the Apache License, Version 2.0 (the
9123 ! "License"); you may not use this file except in compliance
9124 ! with the License. You may obtain a copy of the License at
9125 !
9126 ! http://www.apache.org/licenses/LICENSE-2.0
9127 !
9128 ! Unless required by applicable law or agreed to in writing,
9129 ! software distributed under the License is distributed on an
9130 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9131 ! KIND, either express or implied. See the License for the
9132 ! specific language governing permissions and limitations
9133 ! under the License.
9134 !-->
9135</div></div>
9136<div class="section">
9137<h2><a name="Type_Functions"></a><a name="TypeFunctions" id="TypeFunctions">Type Functions</a></h2>
9138<div class="section">
9139<h3><a name="is_array"></a>is_array</h3>
9140<ul>
9141
9142<li>
9143
9144<p>Syntax:</p>
9145
9146<div>
9147<div>
9148<pre class="source">is_array(expr)
9149</pre></div></div>
9150</li>
9151<li>
9152
9153<p>Checks whether the given expression is evaluated to be an <tt>array</tt> value.</p>
9154</li>
9155<li>Arguments:
9156<ul>
9157
9158<li><tt>expr</tt> : an expression (any type is allowed).</li>
9159</ul>
9160</li>
9161<li>Return Value:
9162<ul>
9163
9164<li>a <tt>boolean</tt> on whether the argument is an <tt>array</tt> value or not,</li>
9165<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9166<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9167</ul>
9168</li>
9169<li>
9170
9171<p>Example:</p>
9172
9173<div>
9174<div>
9175<pre class="source">{
9176 &quot;a&quot;: is_array(true),
9177 &quot;b&quot;: is_array(false),
9178 &quot;c&quot;: isarray(null),
9179 &quot;d&quot;: isarray(missing),
9180 &quot;e&quot;: isarray(&quot;d&quot;),
9181 &quot;f&quot;: isarray(4.0),
9182 &quot;g&quot;: isarray(5),
9183 &quot;h&quot;: isarray([&quot;1&quot;, 2]),
9184 &quot;i&quot;: isarray({&quot;a&quot;:1})
9185};
9186</pre></div></div>
9187</li>
9188<li>
9189
9190<p>The expected result is:</p>
9191
9192<div>
9193<div>
9194<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: true, &quot;i&quot;: false }
9195</pre></div></div>
9196</li>
9197</ul>
9198<p>The function has an alias <tt>isarray</tt>.</p></div>
9199<div class="section">
9200<h3><a name="is_multiset"></a>is_multiset</h3>
9201<ul>
9202
9203<li>
9204
9205<p>Syntax:</p>
9206
9207<div>
9208<div>
9209<pre class="source">is_multiset(expr)
9210</pre></div></div>
9211</li>
9212<li>
9213
9214<p>Checks whether the given expression is evaluated to be an <tt>multiset</tt> value.</p>
9215</li>
9216<li>Arguments:
9217<ul>
9218
9219<li><tt>expr</tt> : an expression (any type is allowed).</li>
9220</ul>
9221</li>
9222<li>Return Value:
9223<ul>
9224
9225<li>a <tt>boolean</tt> on whether the argument is an <tt>multiset</tt> value or not,</li>
9226<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9227<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9228</ul>
9229</li>
9230<li>
9231
9232<p>Example:</p>
9233
9234<div>
9235<div>
9236<pre class="source">{
9237 &quot;a&quot;: is_multiset(true),
9238 &quot;b&quot;: is_multiset(false),
9239 &quot;c&quot;: is_multiset(null),
9240 &quot;d&quot;: is_multiset(missing),
9241 &quot;e&quot;: is_multiset(&quot;d&quot;),
9242 &quot;f&quot;: ismultiset(4.0),
9243 &quot;g&quot;: ismultiset([&quot;1&quot;, 2]),
9244 &quot;h&quot;: ismultiset({&quot;a&quot;:1}),
9245 &quot;i&quot;: ismultiset({{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}})
9246};
9247</pre></div></div>
9248</li>
9249<li>
9250
9251<p>The expected result is:</p>
9252
9253<div>
9254<div>
9255<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: true }
9256</pre></div></div>
9257</li>
9258</ul>
9259<p>The function has an alias <tt>ismultiset</tt>.</p></div>
9260<div class="section">
9261<h3><a name="is_atomic_.28is_atom.29"></a>is_atomic (is_atom)</h3>
9262<ul>
9263
9264<li>
9265
9266<p>Syntax:</p>
9267
9268<div>
9269<div>
9270<pre class="source">is_atomic(expr)
9271</pre></div></div>
9272</li>
9273<li>
9274
9275<p>Checks whether the given expression is evaluated to be a value of a <a href="../datamodel.html#PrimitiveTypes">primitive</a> type.</p>
9276</li>
9277<li>Arguments:
9278<ul>
9279
9280<li><tt>expr</tt> : an expression (any type is allowed).</li>
9281</ul>
9282</li>
9283<li>Return Value:
9284<ul>
9285
9286<li>a <tt>boolean</tt> on whether the argument is a primitive type or not,</li>
9287<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9288<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9289</ul>
9290</li>
9291<li>
9292
9293<p>Example:</p>
9294
9295<div>
9296<div>
9297<pre class="source">{
9298 &quot;a&quot;: is_atomic(true),
9299 &quot;b&quot;: is_atomic(false),
9300 &quot;c&quot;: isatomic(null),
9301 &quot;d&quot;: isatomic(missing),
9302 &quot;e&quot;: isatomic(&quot;d&quot;),
9303 &quot;f&quot;: isatom(4.0),
9304 &quot;g&quot;: isatom(5),
9305 &quot;h&quot;: isatom([&quot;1&quot;, 2]),
9306 &quot;i&quot;: isatom({&quot;a&quot;:1})
9307};
9308</pre></div></div>
9309</li>
9310<li>
9311
9312<p>The expected result is:</p>
9313
9314<div>
9315<div>
9316<pre class="source">{ &quot;a&quot;: true, &quot;b&quot;: true, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: false, &quot;i&quot;: false }
9317</pre></div></div>
9318</li>
9319</ul>
9320<p>The function has three aliases: <tt>isatomic</tt>, <tt>is_atom</tt>, and <tt>isatom</tt>.</p></div>
9321<div class="section">
9322<h3><a name="is_boolean_.28is_bool.29"></a>is_boolean (is_bool)</h3>
9323<ul>
9324
9325<li>
9326
9327<p>Syntax:</p>
9328
9329<div>
9330<div>
9331<pre class="source">is_boolean(expr)
9332</pre></div></div>
9333</li>
9334<li>
9335
9336<p>Checks whether the given expression is evaluated to be a <tt>boolean</tt> value.</p>
9337</li>
9338<li>Arguments:
9339<ul>
9340
9341<li><tt>expr</tt> : an expression (any type is allowed).</li>
9342</ul>
9343</li>
9344<li>Return Value:
9345<ul>
9346
9347<li>a <tt>boolean</tt> on whether the argument is a <tt>boolean</tt> value or not,</li>
9348<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9349<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9350</ul>
9351</li>
9352<li>
9353
9354<p>Example:</p>
9355
9356<div>
9357<div>
9358<pre class="source">{
9359 &quot;a&quot;: isboolean(true),
9360 &quot;b&quot;: isboolean(false),
9361 &quot;c&quot;: is_boolean(null),
9362 &quot;d&quot;: is_boolean(missing),
9363 &quot;e&quot;: isbool(&quot;d&quot;),
9364 &quot;f&quot;: isbool(4.0),
9365 &quot;g&quot;: isbool(5),
9366 &quot;h&quot;: isbool([&quot;1&quot;, 2]),
9367 &quot;i&quot;: isbool({&quot;a&quot;:1})
9368};
9369</pre></div></div>
9370</li>
9371<li>
9372
9373<p>The expected result is:</p>
9374
9375<div>
9376<div>
9377<pre class="source">{ &quot;a&quot;: true, &quot;b&quot;: true, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false }
9378</pre></div></div>
9379</li>
9380</ul>
9381<p>The function has three aliases: <tt>isboolean</tt>, <tt>is_bool</tt>, and <tt>isbool</tt>.</p></div>
9382<div class="section">
9383<h3><a name="is_number_.28is_num.29"></a>is_number (is_num)</h3>
9384<ul>
9385
9386<li>
9387
9388<p>Syntax:</p>
9389
9390<div>
9391<div>
9392<pre class="source">is_number(expr)
9393</pre></div></div>
9394</li>
9395<li>
9396
9397<p>Checks whether the given expression is evaluated to be a numeric value.</p>
9398</li>
9399<li>Arguments:
9400<ul>
9401
9402<li><tt>expr</tt> : an expression (any type is allowed).</li>
9403</ul>
9404</li>
9405<li>Return Value:
9406<ul>
9407
9408<li>a <tt>boolean</tt> on whether the argument is a <tt>smallint</tt>/<tt>tinyint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value or not,</li>
9409<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9410<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9411</ul>
9412</li>
9413<li>
9414
9415<p>Example:</p>
9416
9417<div>
9418<div>
9419<pre class="source">{
9420 &quot;a&quot;: is_number(true),
9421 &quot;b&quot;: is_number(false),
9422 &quot;c&quot;: isnumber(null),
9423 &quot;d&quot;: isnumber(missing),
9424 &quot;e&quot;: isnumber(&quot;d&quot;),
9425 &quot;f&quot;: isnum(4.0),
9426 &quot;g&quot;: isnum(5),
9427 &quot;h&quot;: isnum([&quot;1&quot;, 2]),
9428 &quot;i&quot;: isnum({&quot;a&quot;:1})
9429};
9430</pre></div></div>
9431</li>
9432<li>
9433
9434<p>The expected result is:</p>
9435
9436<div>
9437<div>
9438<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: false, &quot;i&quot;: false }
9439</pre></div></div>
9440</li>
9441</ul>
9442<p>The function has three aliases: <tt>isnumber</tt>, <tt>is_num</tt>, and <tt>isnum</tt>.</p></div>
9443<div class="section">
9444<h3><a name="is_object_.28is_obj.29"></a>is_object (is_obj)</h3>
9445<ul>
9446
9447<li>
9448
9449<p>Syntax:</p>
9450
9451<div>
9452<div>
9453<pre class="source">is_object(expr)
9454</pre></div></div>
9455</li>
9456<li>
9457
9458<p>Checks whether the given expression is evaluated to be a <tt>object</tt> value.</p>
9459</li>
9460<li>Arguments:
9461<ul>
9462
9463<li><tt>expr</tt> : an expression (any type is allowed).</li>
9464</ul>
9465</li>
9466<li>Return Value:
9467<ul>
9468
9469<li>a <tt>boolean</tt> on whether the argument is a <tt>object</tt> value or not,</li>
9470<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9471<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9472</ul>
9473</li>
9474<li>
9475
9476<p>Example:</p>
9477
9478<div>
9479<div>
9480<pre class="source">{
9481 &quot;a&quot;: is_object(true),
9482 &quot;b&quot;: is_object(false),
9483 &quot;c&quot;: isobject(null),
9484 &quot;d&quot;: isobject(missing),
9485 &quot;e&quot;: isobj(&quot;d&quot;),
9486 &quot;f&quot;: isobj(4.0),
9487 &quot;g&quot;: isobj(5),
9488 &quot;h&quot;: isobj([&quot;1&quot;, 2]),
9489 &quot;i&quot;: isobj({&quot;a&quot;:1})
9490};
9491</pre></div></div>
9492</li>
9493<li>
9494
9495<p>The expected result is:</p>
9496<p>{ &#x201c;a&#x201d;: false, &#x201c;b&#x201d;: false, &#x201c;c&#x201d;: null, &#x201c;e&#x201d;: false, &#x201c;f&#x201d;: false, &#x201c;g&#x201d;: false, &#x201c;h&#x201d;: false, &#x201c;i&#x201d;: true }</p>
9497</li>
9498</ul>
9499<p>The function has three aliases: <tt>isobject</tt>, <tt>is_obj</tt>, and <tt>isobj</tt>.</p></div>
9500<div class="section">
9501<h3><a name="is_string_.28is_str.29"></a>is_string (is_str)</h3>
9502<ul>
9503
9504<li>
9505
9506<p>Syntax:</p>
9507
9508<div>
9509<div>
9510<pre class="source">is_string(expr)
9511</pre></div></div>
9512</li>
9513<li>
9514
9515<p>Checks whether the given expression is evaluated to be a <tt>string</tt> value.</p>
9516</li>
9517<li>Arguments:
9518<ul>
9519
9520<li><tt>expr</tt> : an expression (any type is allowed).</li>
9521</ul>
9522</li>
9523<li>Return Value:
9524<ul>
9525
9526<li>a <tt>boolean</tt> on whether the argument is a <tt>string</tt> value or not,</li>
9527<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9528<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9529</ul>
9530</li>
9531<li>
9532
9533<p>Example:</p>
9534
9535<div>
9536<div>
9537<pre class="source">{
9538 &quot;a&quot;: is_string(true),
9539 &quot;b&quot;: isstring(false),
9540 &quot;c&quot;: isstring(null),
9541 &quot;d&quot;: isstr(missing),
9542 &quot;e&quot;: isstr(&quot;d&quot;),
9543 &quot;f&quot;: isstr(4.0),
9544 &quot;g&quot;: isstr(5),
9545 &quot;h&quot;: isstr([&quot;1&quot;, 2]),
9546 &quot;i&quot;: isstr({&quot;a&quot;:1})
9547};
9548</pre></div></div>
9549</li>
9550<li>
9551
9552<p>The expected result is:</p>
9553
9554<div>
9555<div>
9556<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false }
9557</pre></div></div>
9558</li>
9559</ul>
9560<p>The function has three aliases: <tt>isstring</tt>, <tt>is_str</tt>, and <tt>isstr</tt>.</p></div>
9561<div class="section">
9562<h3><a name="is_null"></a>is_null</h3>
9563<ul>
9564
9565<li>
9566
9567<p>Syntax:</p>
9568
9569<div>
9570<div>
9571<pre class="source">is_null(expr)
9572</pre></div></div>
9573</li>
9574<li>
9575
9576<p>Checks whether the given expression is evaluated to be a <tt>null</tt> value.</p>
9577</li>
9578<li>Arguments:
9579<ul>
9580
9581<li><tt>expr</tt> : an expression (any type is allowed).</li>
9582</ul>
9583</li>
9584<li>Return Value:
9585<ul>
9586
9587<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt> or not,</li>
9588<li>a <tt>missing</tt> if the input is <tt>missing</tt>.</li>
9589</ul>
9590</li>
9591<li>
9592
9593<p>Example:</p>
9594
9595<div>
9596<div>
9597<pre class="source">{ &quot;v1&quot;: is_null(null), &quot;v2&quot;: is_null(1), &quot;v3&quot;: is_null(missing) };
9598</pre></div></div>
9599</li>
9600<li>
9601
9602<p>The expected result is:</p>
9603
9604<div>
9605<div>
9606<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
9607</pre></div></div>
9608</li>
9609</ul>
9610<p>The function has an alias <tt>isnull</tt>.</p></div>
9611<div class="section">
9612<h3><a name="is_missing"></a>is_missing</h3>
9613<ul>
9614
9615<li>
9616
9617<p>Syntax:</p>
9618
9619<div>
9620<div>
9621<pre class="source">is_missing(expr)
9622</pre></div></div>
9623</li>
9624<li>
9625
9626<p>Checks whether the given expression is evaluated to be a <tt>missing</tt> value.</p>
9627</li>
9628<li>Arguments:
9629<ul>
9630
9631<li><tt>expr</tt> : an expression (any type is allowed).</li>
9632</ul>
9633</li>
9634<li>Return Value:
9635<ul>
9636
9637<li>a <tt>boolean</tt> on whether the variable is a <tt>missing</tt> or not.</li>
9638</ul>
9639</li>
9640<li>
9641
9642<p>Example:</p>
9643
9644<div>
9645<div>
9646<pre class="source">{ &quot;v1&quot;: is_missing(null), &quot;v2&quot;: is_missing(1), &quot;v3&quot;: is_missing(missing) };
9647</pre></div></div>
9648</li>
9649<li>
9650
9651<p>The expected result is:</p>
9652
9653<div>
9654<div>
9655<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: false, &quot;v3&quot;: true }
9656</pre></div></div>
9657</li>
9658</ul>
9659<p>The function has an alias <tt>ismissing</tt>.</p></div>
9660<div class="section">
9661<h3><a name="is_unknown"></a>is_unknown</h3>
9662<ul>
9663
9664<li>
9665
9666<p>Syntax:</p>
9667
9668<div>
9669<div>
9670<pre class="source">is_unknown(expr)
9671</pre></div></div>
9672</li>
9673<li>
9674
9675<p>Checks whether the given variable is a <tt>null</tt> value or a <tt>missing</tt> value.</p>
9676</li>
9677<li>Arguments:
9678<ul>
9679
9680<li><tt>expr</tt> : an expression (any type is allowed).</li>
9681</ul>
9682</li>
9683<li>Return Value:
9684<ul>
9685
9686<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt>/``missing<tt>value (</tt>true<tt>) or not (</tt>false`).</li>
9687</ul>
9688</li>
9689<li>
9690
9691<p>Example:</p>
9692
9693<div>
9694<div>
9695<pre class="source">{ &quot;v1&quot;: is_unknown(null), &quot;v2&quot;: is_unknown(1), &quot;v3&quot;: is_unknown(missing) };
9696</pre></div></div>
9697</li>
9698<li>
9699
9700<p>The expected result is:</p>
9701
9702<div>
9703<div>
9704<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false, &quot;v3&quot;: true }
9705</pre></div></div>
9706</li>
9707</ul>
9708<p>The function has an alias <tt>isunknown</tt>.</p><!--
9709 ! Licensed to the Apache Software Foundation (ASF) under one
9710 ! or more contributor license agreements. See the NOTICE file
9711 ! distributed with this work for additional information
9712 ! regarding copyright ownership. The ASF licenses this file
9713 ! to you under the Apache License, Version 2.0 (the
9714 ! "License"); you may not use this file except in compliance
9715 ! with the License. You may obtain a copy of the License at
9716 !
9717 ! http://www.apache.org/licenses/LICENSE-2.0
9718 !
9719 ! Unless required by applicable law or agreed to in writing,
9720 ! software distributed under the License is distributed on an
9721 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9722 ! KIND, either express or implied. See the License for the
9723 ! specific language governing permissions and limitations
9724 ! under the License.
9725 !-->
9726</div>
9727<div class="section">
9728<h3><a name="is_binary_.28is_bin.29"></a>is_binary (is_bin)</h3>
9729<ul>
9730
9731<li>
9732
9733<p>Syntax:</p>
9734
9735<div>
9736<div>
9737<pre class="source">is_binary(expr)
9738</pre></div></div>
9739</li>
9740<li>
9741
9742<p>Checks whether the given expression is evaluated to be a <tt>binary</tt> value.</p>
9743</li>
9744<li>Arguments:
9745<ul>
9746
9747<li><tt>expr</tt> : an expression (any type is allowed).</li>
9748</ul>
9749</li>
9750<li>Return Value:
9751<ul>
9752
9753<li>a <tt>boolean</tt> on whether the argument is a <tt>binary</tt> value or not,</li>
9754<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9755<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9756</ul>
9757</li>
9758<li>
9759
9760<p>Example:</p>
9761
9762<div>
9763<div>
9764<pre class="source">{
9765 &quot;a&quot;: is_binary(true),
9766 &quot;b&quot;: is_binary(false),
9767 &quot;c&quot;: isbinary(null),
9768 &quot;d&quot;: isbinary(missing),
9769 &quot;e&quot;: isbin(point(&quot;1,2&quot;)),
9770 &quot;f&quot;: isbin(hex(&quot;ABCDEF0123456789&quot;)),
9771 &quot;g&quot;: is_bin(sub_binary(hex(&quot;AABBCCDD&quot;), 4)),
9772 &quot;h&quot;: is_bin(2),
9773 &quot;i&quot;: is_bin({&quot;a&quot;:1})
9774};
9775</pre></div></div>
9776</li>
9777<li>
9778
9779<p>The expected result is:</p>
9780
9781<div>
9782<div>
9783<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: false, &quot;i&quot;: false }
9784</pre></div></div>
9785</li>
9786</ul>
9787<p>The function has three aliases: <tt>isbinary</tt>, <tt>is_bin</tt>, and <tt>isbin</tt>.</p></div>
9788<div class="section">
9789<h3><a name="is_uuid"></a>is_uuid</h3>
9790<ul>
9791
9792<li>
9793
9794<p>Syntax:</p>
9795
9796<div>
9797<div>
9798<pre class="source">is_uuid(expr)
9799</pre></div></div>
9800</li>
9801<li>
9802
9803<p>Checks whether the given expression is evaluated to be a <tt>uuid</tt> value.</p>
9804</li>
9805<li>Arguments:
9806<ul>
9807
9808<li><tt>expr</tt> : an expression (any type is allowed).</li>
9809</ul>
9810</li>
9811<li>Return Value:
9812<ul>
9813
9814<li>a <tt>boolean</tt> on whether the argument is a <tt>uuid</tt> value or not,</li>
9815<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9816<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9817</ul>
9818</li>
9819<li>
9820
9821<p>Example:</p>
9822
9823<div>
9824<div>
9825<pre class="source"> {
9826 &quot;a&quot;: is_uuid(true),
9827 &quot;b&quot;: is_uuid(false),
9828 &quot;c&quot;: is_uuid(null),
9829 &quot;d&quot;: is_uuid(missing),
9830 &quot;e&quot;: isuuid(4.0),
9831 &quot;f&quot;: isuuid(date(&quot;2013-01-01&quot;)),
9832 &quot;g&quot;: isuuid(uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;))
9833};
9834</pre></div></div>
9835</li>
9836<li>
9837
9838<p>The expected result is:</p>
9839
9840<div>
9841<div>
9842<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: true }
9843</pre></div></div>
9844</li>
9845</ul>
9846<p>The function has an alias <tt>isuuid</tt>.</p></div>
9847<div class="section">
9848<h3><a name="is_point"></a>is_point</h3>
9849<ul>
9850
9851<li>
9852
9853<p>Syntax:</p>
9854
9855<div>
9856<div>
9857<pre class="source">is_point(expr)
9858</pre></div></div>
9859</li>
9860<li>
9861
9862<p>Checks whether the given expression is evaluated to be a <tt>point</tt> value.</p>
9863</li>
9864<li>Arguments:
9865<ul>
9866
9867<li><tt>expr</tt> : an expression (any type is allowed).</li>
9868</ul>
9869</li>
9870<li>Return Value:
9871<ul>
9872
9873<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt> value or not,</li>
9874<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9875<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9876</ul>
9877</li>
9878<li>
9879
9880<p>Example:</p>
9881
9882<div>
9883<div>
9884<pre class="source">{
9885 &quot;a&quot;: is_point(true),
9886 &quot;b&quot;: is_point(false),
9887 &quot;c&quot;: is_point(null),
9888 &quot;d&quot;: is_point(missing),
9889 &quot;e&quot;: is_point(point(&quot;1,2&quot;)),
9890 &quot;f&quot;: ispoint(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9891 &quot;g&quot;: ispoint(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9892 &quot;h&quot;: ispoint(circle(&quot;30.0,70.0 5.0&quot;)),
9893 &quot;i&quot;: ispoint(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9894 &quot;j&quot;: ispoint(3)
9895};
9896</pre></div></div>
9897</li>
9898<li>
9899
9900<p>The expected result is:</p>
9901
9902<div>
9903<div>
9904<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false }
9905</pre></div></div>
9906</li>
9907</ul>
9908<p>The function has an alias <tt>ispoint</tt>.</p></div>
9909<div class="section">
9910<h3><a name="is_line"></a>is_line</h3>
9911<ul>
9912
9913<li>
9914
9915<p>Syntax:</p>
9916
9917<div>
9918<div>
9919<pre class="source">is_line(expr)
9920</pre></div></div>
9921</li>
9922<li>
9923
9924<p>Checks whether the given expression is evaluated to be a <tt>line</tt> value.</p>
9925</li>
9926<li>Arguments:
9927<ul>
9928
9929<li><tt>expr</tt> : an expression (any type is allowed).</li>
9930</ul>
9931</li>
9932<li>Return Value:
9933<ul>
9934
9935<li>a <tt>boolean</tt> on whether the argument is a <tt>line</tt> value or not,</li>
9936<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9937<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9938</ul>
9939</li>
9940<li>
9941
9942<p>Example:</p>
9943
9944<div>
9945<div>
9946<pre class="source">{
9947 &quot;a&quot;: is_line(true),
9948 &quot;b&quot;: is_line(false),
9949 &quot;c&quot;: is_line(null),
9950 &quot;d&quot;: is_line(missing),
9951 &quot;e&quot;: is_line(point(&quot;1,2&quot;)),
9952 &quot;f&quot;: isline(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9953 &quot;g&quot;: isline(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9954 &quot;h&quot;: isline(circle(&quot;30.0,70.0 5.0&quot;)),
9955 &quot;i&quot;: isline(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9956 &quot;j&quot;: isline(3)
9957};
9958</pre></div></div>
9959</li>
9960<li>
9961
9962<p>The expected result is:</p>
9963
9964<div>
9965<div>
9966<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: true, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false }
9967</pre></div></div>
9968</li>
9969</ul>
9970<p>The function has an alias <tt>isline</tt>.</p></div>
9971<div class="section">
9972<h3><a name="is_rectangle"></a>is_rectangle</h3>
9973<ul>
9974
9975<li>
9976
9977<p>Syntax:</p>
9978
9979<div>
9980<div>
9981<pre class="source">is_rectangle(expr)
9982</pre></div></div>
9983</li>
9984<li>
9985
9986<p>Checks whether the given expression is evaluated to be a <tt>rectangle</tt> value.</p>
9987</li>
9988<li>Arguments:
9989<ul>
9990
9991<li><tt>expr</tt> : an expression (any type is allowed).</li>
9992</ul>
9993</li>
9994<li>Return Value:
9995<ul>
9996
9997<li>a <tt>boolean</tt> on whether the argument is a <tt>rectangle</tt> value or not,</li>
9998<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9999<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10000</ul>
10001</li>
10002<li>
10003
10004<p>Example:</p>
10005
10006<div>
10007<div>
10008<pre class="source">{
10009 &quot;a&quot;: is_rectangle(true),
10010 &quot;b&quot;: is_rectangle(false),
10011 &quot;c&quot;: is_rectangle(null),
10012 &quot;d&quot;: is_rectangle(missing),
10013 &quot;e&quot;: is_rectangle(point(&quot;1,2&quot;)),
10014 &quot;f&quot;: isrectangle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
10015 &quot;g&quot;: isrectangle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
10016 &quot;h&quot;: isrectangle(circle(&quot;30.0,70.0 5.0&quot;)),
10017 &quot;i&quot;: isrectangle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
10018 &quot;j&quot;: isrectangle(3)
10019};
10020</pre></div></div>
10021</li>
10022<li>
10023
10024<p>The expected result is:</p>
10025
10026<div>
10027<div>
10028<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: true, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false }
10029</pre></div></div>
10030</li>
10031</ul>
10032<p>The function has an alias <tt>isrectangle</tt>.</p></div>
10033<div class="section">
10034<h3><a name="is_circle"></a>is_circle</h3>
10035<ul>
10036
10037<li>
10038
10039<p>Syntax:</p>
10040
10041<div>
10042<div>
10043<pre class="source">is_circle(expr)
10044</pre></div></div>
10045</li>
10046<li>
10047
10048<p>Checks whether the given expression is evaluated to be a <tt>circle</tt> value.</p>
10049</li>
10050<li>Arguments:
10051<ul>
10052
10053<li><tt>expr</tt> : an expression (any type is allowed).</li>
10054</ul>
10055</li>
10056<li>Return Value:
10057<ul>
10058
10059<li>a <tt>boolean</tt> on whether the argument is a <tt>circle</tt> value or not,</li>
10060<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10061<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10062</ul>
10063</li>
10064<li>
10065
10066<p>Example:</p>
10067
10068<div>
10069<div>
10070<pre class="source">{
10071 &quot;a&quot;: is_circle(true),
10072 &quot;b&quot;: is_circle(false),
10073 &quot;c&quot;: is_circle(null),
10074 &quot;d&quot;: is_circle(missing),
10075 &quot;e&quot;: is_circle(point(&quot;1,2&quot;)),
10076 &quot;f&quot;: iscircle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
10077 &quot;g&quot;: iscircle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
10078 &quot;h&quot;: iscircle(circle(&quot;30.0,70.0 5.0&quot;)),
10079 &quot;i&quot;: iscircle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
10080 &quot;j&quot;: iscircle(3)
10081};
10082</pre></div></div>
10083</li>
10084<li>
10085
10086<p>The expected result is:</p>
10087
10088<div>
10089<div>
10090<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: true, &quot;i&quot;: false, &quot;j&quot;: false }
10091</pre></div></div>
10092</li>
10093</ul>
10094<p>The function has an alias <tt>iscircle</tt>.</p></div>
10095<div class="section">
10096<h3><a name="is_polygon"></a>is_polygon</h3>
10097<ul>
10098
10099<li>
10100
10101<p>Syntax:</p>
10102
10103<div>
10104<div>
10105<pre class="source">is_polygon(expr)
10106</pre></div></div>
10107</li>
10108<li>
10109
10110<p>Checks whether the given expression is evaluated to be a <tt>polygon</tt> value.</p>
10111</li>
10112<li>Arguments:
10113<ul>
10114
10115<li><tt>expr</tt> : an expression (any type is allowed).</li>
10116</ul>
10117</li>
10118<li>Return Value:
10119<ul>
10120
10121<li>a <tt>boolean</tt> on whether the argument is a <tt>polygon</tt> value or not,</li>
10122<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10123<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10124</ul>
10125</li>
10126<li>
10127
10128<p>Example:</p>
10129
10130<div>
10131<div>
10132<pre class="source">{
10133 &quot;a&quot;: is_polygon(true),
10134 &quot;b&quot;: is_polygon(false),
10135 &quot;c&quot;: is_polygon(null),
10136 &quot;d&quot;: is_polygon(missing),
10137 &quot;e&quot;: is_polygon(point(&quot;1,2&quot;)),
10138 &quot;f&quot;: ispolygon(line(&quot;30.0,70.0 50.0,90.0&quot;)),
10139 &quot;g&quot;: ispolygon(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
10140 &quot;h&quot;: ispolygon(circle(&quot;30.0,70.0 5.0&quot;)),
10141 &quot;i&quot;: ispolygon(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
10142 &quot;j&quot;: ispolygon(3)
10143};
10144</pre></div></div>
10145</li>
10146<li>
10147
10148<p>The expected result is:</p>
10149
10150<div>
10151<div>
10152<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: true, &quot;j&quot;: false }
10153</pre></div></div>
10154</li>
10155</ul>
10156<p>The function has an alias <tt>ispolygon</tt>.</p></div>
10157<div class="section">
10158<h3><a name="is_spatial"></a>is_spatial</h3>
10159<ul>
10160
10161<li>
10162
10163<p>Syntax:</p>
10164
10165<div>
10166<div>
10167<pre class="source">is_spatial(expr)
10168</pre></div></div>
10169</li>
10170<li>
10171
10172<p>Checks whether the given expression is evaluated to be a spatial value.</p>
10173</li>
10174<li>Arguments:
10175<ul>
10176
10177<li><tt>expr</tt> : an expression (any type is allowed).</li>
10178</ul>
10179</li>
10180<li>Return Value:
10181<ul>
10182
10183<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt>/<tt>line</tt>/<tt>rectangle</tt>/<tt>circle</tt>/<tt>polygon</tt> value or not,</li>
10184<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10185<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10186</ul>
10187</li>
10188<li>
10189
10190<p>Example:</p>
10191
10192<div>
10193<div>
10194<pre class="source">{
10195 &quot;a&quot;: is_spatial(true),
10196 &quot;b&quot;: is_spatial(false),
10197 &quot;c&quot;: is_spatial(null),
10198 &quot;d&quot;: is_spatial(missing),
10199 &quot;e&quot;: is_spatial(point(&quot;1,2&quot;)),
10200 &quot;f&quot;: isspatial(line(&quot;30.0,70.0 50.0,90.0&quot;)),
10201 &quot;g&quot;: isspatial(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
10202 &quot;h&quot;: isspatial(circle(&quot;30.0,70.0 5.0&quot;)),
10203 &quot;i&quot;: isspatial(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
10204 &quot;j&quot;: isspatial(3)
10205};
10206</pre></div></div>
10207</li>
10208<li>
10209
10210<p>The expected result is:</p>
10211
10212<div>
10213<div>
10214<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: true, &quot;i&quot;: true, &quot;j&quot;: false }
10215</pre></div></div>
10216</li>
10217</ul>
10218<p>The function has an alias <tt>isspatial</tt>.</p></div>
10219<div class="section">
10220<h3><a name="is_date"></a>is_date</h3>
10221<ul>
10222
10223<li>
10224
10225<p>Syntax:</p>
10226
10227<div>
10228<div>
10229<pre class="source">is_date(expr)
10230</pre></div></div>
10231</li>
10232<li>
10233
10234<p>Checks whether the given expression is evaluated to be a <tt>date</tt> value.</p>
10235</li>
10236<li>Arguments:
10237<ul>
10238
10239<li><tt>expr</tt> : an expression (any type is allowed).</li>
10240</ul>
10241</li>
10242<li>Return Value:
10243<ul>
10244
10245<li>a <tt>boolean</tt> on whether the argument is a <tt>date</tt> value or not,</li>
10246<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10247<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10248</ul>
10249</li>
10250<li>
10251
10252<p>Example:</p>
10253
10254<div>
10255<div>
10256<pre class="source">{
10257 &quot;a&quot;: is_date(true),
10258 &quot;b&quot;: is_date(false),
10259 &quot;c&quot;: is_date(null),
10260 &quot;d&quot;: is_date(missing),
10261 &quot;e&quot;: is_date(date(&quot;-19700101&quot;)),
10262 &quot;f&quot;: isdate(date(&quot;2013-01-01&quot;)),
10263 &quot;g&quot;: isdate(time(&quot;12:12:12.039Z&quot;)),
10264 &quot;h&quot;: isdate(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10265 &quot;i&quot;: isdate(duration(&quot;P100Y12MT12M&quot;)),
10266 &quot;j&quot;: isdate(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10267 &quot;k&quot;: isdate(3)
10268};
10269</pre></div></div>
10270</li>
10271<li>
10272
10273<p>The expected result is:</p>
10274
10275<div>
10276<div>
10277<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false, &quot;k&quot;: false }
10278</pre></div></div>
10279</li>
10280</ul>
10281<p>The function has an alias <tt>isdate</tt>.</p></div>
10282<div class="section">
10283<h3><a name="is_datetime_.28is_timestamp.29"></a>is_datetime (is_timestamp)</h3>
10284<ul>
10285
10286<li>
10287
10288<p>Syntax:</p>
10289
10290<div>
10291<div>
10292<pre class="source">is_datetime(expr)
10293</pre></div></div>
10294</li>
10295<li>
10296
10297<p>Checks whether the given expression is evaluated to be a <tt>datetime</tt> value.</p>
10298</li>
10299<li>Arguments:
10300<ul>
10301
10302<li><tt>expr</tt> : an expression (any type is allowed).</li>
10303</ul>
10304</li>
10305<li>Return Value:
10306<ul>
10307
10308<li>a <tt>boolean</tt> on whether the argument is a <tt>datetime</tt> value or not,</li>
10309<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10310<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10311</ul>
10312</li>
10313<li>
10314
10315<p>Example:</p>
10316
10317<div>
10318<div>
10319<pre class="source">{
10320 &quot;a&quot;: is_datetime(true),
10321 &quot;b&quot;: is_datetime(false),
10322 &quot;c&quot;: is_datetime(null),
10323 &quot;d&quot;: is_datetime(missing),
10324 &quot;e&quot;: is_datetime(datetime(&quot;2016-02-02T12:09:22.023Z&quot;)),
10325 &quot;f&quot;: isdatetime(datetime(&quot;2011-03-03T12:10:42.011Z&quot;)),
10326 &quot;g&quot;: isdatetime(time(&quot;12:12:12.039Z&quot;)),
10327 &quot;h&quot;: is_timestamp(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10328 &quot;i&quot;: is_timestamp(duration(&quot;P100Y12MT12M&quot;)),
10329 &quot;j&quot;: istimestamp(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10330 &quot;k&quot;: istimestamp(3)
10331};
10332</pre></div></div>
10333</li>
10334<li>
10335
10336<p>The expected result is:</p>
10337
10338<div>
10339<div>
10340<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: false, &quot;h&quot;: true, &quot;i&quot;: false, &quot;j&quot;: false, &quot;k&quot;: false }
10341</pre></div></div>
10342</li>
10343</ul>
10344<p>The function has three aliases: <tt>isdatetime</tt>, <tt>is_timestamp</tt>, and <tt>istimestamp</tt>.</p></div>
10345<div class="section">
10346<h3><a name="is_time"></a>is_time</h3>
10347<ul>
10348
10349<li>
10350
10351<p>Syntax:</p>
10352
10353<div>
10354<div>
10355<pre class="source">is_time(expr)
10356</pre></div></div>
10357</li>
10358<li>
10359
10360<p>Checks whether the given expression is evaluated to be a <tt>time</tt> value.</p>
10361</li>
10362<li>Arguments:
10363<ul>
10364
10365<li><tt>expr</tt> : an expression (any type is allowed).</li>
10366</ul>
10367</li>
10368<li>Return Value:
10369<ul>
10370
10371<li>a <tt>boolean</tt> on whether the argument is a <tt>time</tt> value or not,</li>
10372<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10373<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10374</ul>
10375</li>
10376<li>
10377
10378<p>Example:</p>
10379
10380<div>
10381<div>
10382<pre class="source"> {
10383 &quot;a&quot;: is_time(true),
10384 &quot;b&quot;: is_time(false),
10385 &quot;c&quot;: is_time(null),
10386 &quot;d&quot;: is_time(missing),
10387 &quot;e&quot;: is_time(time(&quot;08:00:00.000Z&quot;)),
10388 &quot;f&quot;: istime(date(&quot;2013-01-01&quot;)),
10389 &quot;g&quot;: istime(time(&quot;12:12:12.039Z&quot;)),
10390 &quot;h&quot;: istime(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10391 &quot;i&quot;: istime(duration(&quot;P100Y12MT12M&quot;)),
10392 &quot;j&quot;: istime(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10393 &quot;k&quot;: istime(3)
10394};
10395</pre></div></div>
10396</li>
10397<li>
10398
10399<p>The expected result is:</p>
10400
10401<div>
10402<div>
10403<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: false, &quot;g&quot;: true, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false, &quot;k&quot;: false }
10404</pre></div></div>
10405</li>
10406</ul>
10407<p>The function has an alias <tt>istime</tt>.</p></div>
10408<div class="section">
10409<h3><a name="is_duration"></a>is_duration</h3>
10410<ul>
10411
10412<li>
10413
10414<p>Syntax:</p>
10415
10416<div>
10417<div>
10418<pre class="source">is_duration(expr)
10419</pre></div></div>
10420</li>
10421<li>
10422
10423<p>Checks whether the given expression is evaluated to be a duration value.</p>
10424</li>
10425<li>Arguments:
10426<ul>
10427
10428<li><tt>expr</tt> : an expression (any type is allowed).</li>
10429</ul>
10430</li>
10431<li>Return Value:
10432<ul>
10433
10434<li>a <tt>boolean</tt> on whether the argument is a <tt>duration/year_month_duration/day_time_duration</tt> value or not,</li>
10435<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10436<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10437</ul>
10438</li>
10439<li>
10440
10441<p>Example:</p>
10442
10443<div>
10444<div>
10445<pre class="source"> {
10446 &quot;a&quot;: is_duration(true),
10447 &quot;b&quot;: is_duration(false),
10448 &quot;c&quot;: is_duration(null),
10449 &quot;d&quot;: is_duration(missing),
10450 &quot;e&quot;: is_duration(duration(&quot;-PT20.943S&quot;)),
10451 &quot;f&quot;: isduration(date(&quot;2013-01-01&quot;)),
10452 &quot;g&quot;: isduration(time(&quot;12:12:12.039Z&quot;)),
10453 &quot;h&quot;: isduration(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10454 &quot;i&quot;: isduration(duration(&quot;P100Y12MT12M&quot;)),
10455 &quot;j&quot;: isduration(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10456 &quot;k&quot;: isduration(3)
10457};
10458</pre></div></div>
10459</li>
10460<li>
10461
10462<p>The expected result is:</p>
10463
10464<div>
10465<div>
10466<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: true, &quot;j&quot;: false, &quot;k&quot;: false }
10467</pre></div></div>
10468</li>
10469</ul>
10470<p>The function has an alias <tt>isduration</tt>.</p></div>
10471<div class="section">
10472<h3><a name="is_interval"></a>is_interval</h3>
10473<ul>
10474
10475<li>
10476
10477<p>Syntax:</p>
10478
10479<div>
10480<div>
10481<pre class="source">is_interval(expr)
10482</pre></div></div>
10483</li>
10484<li>
10485
10486<p>Checks whether the given expression is evaluated to be a <tt>interval</tt> value.</p>
10487</li>
10488<li>Arguments:
10489<ul>
10490
10491<li><tt>expr</tt> : an expression (any type is allowed).</li>
10492</ul>
10493</li>
10494<li>Return Value:
10495<ul>
10496
10497<li>a <tt>boolean</tt> on whether the argument is a <tt>interval</tt> value or not,</li>
10498<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10499<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10500</ul>
10501</li>
10502<li>
10503
10504<p>Example:</p>
10505
10506<div>
10507<div>
10508<pre class="source"> {
10509 &quot;a&quot;: is_interval(true),
10510 &quot;b&quot;: is_interval(false),
10511 &quot;c&quot;: is_interval(null),
10512 &quot;d&quot;: is_interval(missing),
10513 &quot;e&quot;: is_interval(interval(datetime(&quot;2013-01-01T00:01:01.000Z&quot;), datetime(&quot;2013-05-05T13:39:01.049Z&quot;))),
10514 &quot;f&quot;: isinterval(date(&quot;2013-01-01&quot;)),
10515 &quot;g&quot;: isinterval(time(&quot;12:12:12.039Z&quot;)),
10516 &quot;h&quot;: isinterval(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10517 &quot;i&quot;: isinterval(duration(&quot;P100Y12MT12M&quot;)),
10518 &quot;j&quot;: isinterval(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10519 &quot;k&quot;: isinterval(3)
10520};
10521</pre></div></div>
10522</li>
10523<li>
10524
10525<p>The expected result is:</p>
10526
10527<div>
10528<div>
10529<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: true, &quot;k&quot;: false }
10530</pre></div></div>
10531</li>
10532</ul>
10533<p>The function has an alias <tt>isinterval</tt>.</p></div>
10534<div class="section">
10535<h3><a name="is_temporal"></a>is_temporal</h3>
10536<ul>
10537
10538<li>
10539
10540<p>Syntax:</p>
10541
10542<div>
10543<div>
10544<pre class="source">is_temporal(expr)
10545</pre></div></div>
10546</li>
10547<li>
10548
10549<p>Checks whether the given expression is evaluated to be a temporal value.</p>
10550</li>
10551<li>Arguments:
10552<ul>
10553
10554<li><tt>expr</tt> : an expression (any type is allowed).</li>
10555</ul>
10556</li>
10557<li>Return Value:
10558<ul>
10559
10560<li>a <tt>boolean</tt> on whether the argument is a <tt>date/datetime/time/duration/year_month_duration/day_time_duration/interval</tt> value or not,</li>
10561<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10562<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10563</ul>
10564</li>
10565<li>
10566
10567<p>Example:</p>
10568
10569<div>
10570<div>
10571<pre class="source"> {
10572 &quot;a&quot;: is_temporal(true),
10573 &quot;b&quot;: is_temporal(false),
10574 &quot;c&quot;: is_temporal(null),
10575 &quot;d&quot;: is_temporal(missing),
10576 &quot;e&quot;: is_temporal(duration(&quot;-PT20.943S&quot;)),
10577 &quot;f&quot;: istemporal(date(&quot;2013-01-01&quot;)),
10578 &quot;g&quot;: istemporal(time(&quot;12:12:12.039Z&quot;)),
10579 &quot;h&quot;: istemporal(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10580 &quot;i&quot;: istemporal(duration(&quot;P100Y12MT12M&quot;)),
10581 &quot;j&quot;: istemporal(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10582 &quot;k&quot;: istemporal(3)
10583};
10584</pre></div></div>
10585</li>
10586<li>
10587
10588<p>The expected result is:</p>
10589
10590<div>
10591<div>
10592<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: true, &quot;i&quot;: true, &quot;j&quot;: true, &quot;k&quot;: false }
10593</pre></div></div>
10594</li>
10595</ul>
10596<p>The function has an alias <tt>istemporal</tt>.</p></div>
10597<div class="section">
10598<h3><a name="get_type"></a>get_type</h3>
10599<ul>
10600
10601<li>
10602
10603<p>Syntax:</p>
10604
10605<div>
10606<div>
10607<pre class="source">get_type(expr)
10608</pre></div></div>
10609</li>
10610<li>
10611
10612<p>Returns a string describing the type of the given <tt>expr</tt>. This includes incomplete information types (i.e. <tt>missing</tt> and <tt>null</tt>).</p>
10613</li>
10614<li>Arguments:
10615<ul>
10616
10617<li><tt>expr</tt> : an expression (any type is allowed).</li>
10618</ul>
10619</li>
10620<li>
10621
10622<p>Example:</p>
10623
10624<div>
10625<div>
10626<pre class="source">{
10627 &quot;a&quot;: get_type(true),
10628 &quot;b&quot;: get_type(false),
10629 &quot;c&quot;: get_type(null),
10630 &quot;d&quot;: get_type(missing),
10631 &quot;e&quot;: get_type(&quot;d&quot;),
10632 &quot;f&quot;: gettype(4.0),
10633 &quot;g&quot;: gettype(5),
10634 &quot;h&quot;: gettype([&quot;1&quot;, 2]),
10635 &quot;i&quot;: gettype({&quot;a&quot;:1})
10636};
10637</pre></div></div>
10638</li>
10639<li>
10640
10641<p>The expected result is:</p>
10642
10643<div>
10644<div>
10645<pre class="source">{ &quot;a&quot;: &quot;boolean&quot;, &quot;b&quot;: &quot;boolean&quot;, &quot;c&quot;: &quot;null&quot;, &quot;d&quot;: &quot;missing&quot;, &quot;e&quot;: &quot;string&quot;, &quot;f&quot;: &quot;double&quot;, &quot;g&quot;: &quot;bigint&quot;, &quot;h&quot;: &quot;array&quot;, &quot;i&quot;: &quot;object&quot; }
10646</pre></div></div>
10647</li>
10648</ul>
10649<p>The function has an alias <tt>gettype</tt>.</p><!--
10650 ! Licensed to the Apache Software Foundation (ASF) under one
10651 ! or more contributor license agreements. See the NOTICE file
10652 ! distributed with this work for additional information
10653 ! regarding copyright ownership. The ASF licenses this file
10654 ! to you under the Apache License, Version 2.0 (the
10655 ! "License"); you may not use this file except in compliance
10656 ! with the License. You may obtain a copy of the License at
10657 !
10658 ! http://www.apache.org/licenses/LICENSE-2.0
10659 !
10660 ! Unless required by applicable law or agreed to in writing,
10661 ! software distributed under the License is distributed on an
10662 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10663 ! KIND, either express or implied. See the License for the
10664 ! specific language governing permissions and limitations
10665 ! under the License.
10666 !-->
10667</div>
10668<div class="section">
10669<h3><a name="to_array"></a>to_array</h3>
10670<ul>
10671
10672<li>
10673
10674<p>Syntax:</p>
10675
10676<div>
10677<div>
10678<pre class="source">to_array(expr)
10679</pre></div></div>
10680</li>
10681<li>
10682
10683<p>Converts input value to an <tt>array</tt> value</p>
10684</li>
10685<li>Arguments:
10686<ul>
10687
10688<li><tt>expr</tt> : an expression</li>
10689</ul>
10690</li>
10691<li>Return Value:
10692<ul>
10693
10694<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10695<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10696<li>if the argument is of <tt>array</tt> type then it is returned as is</li>
10697<li>if the argument is of <tt>multiset</tt> type then it is returned as an <tt>array</tt> with elements in an undefined order</li>
10698<li>otherwise an <tt>array</tt> containing the input expression as its single item is returned</li>
10699</ul>
10700</li>
10701<li>
10702
10703<p>Example:</p>
10704
10705<div>
10706<div>
10707<pre class="source">{
10708 &quot;v1&quot;: to_array(&quot;asterix&quot;),
10709 &quot;v2&quot;: to_array([&quot;asterix&quot;]),
10710};
10711</pre></div></div>
10712</li>
10713<li>
10714
10715<p>The expected result is:</p>
10716
10717<div>
10718<div>
10719<pre class="source">{ &quot;v1&quot;: [&quot;asterix&quot;], &quot;v2&quot;: [&quot;asterix&quot;] }
10720</pre></div></div>
10721</li>
10722</ul>
10723<p>The function has an alias <tt>toarray</tt>.</p></div>
10724<div class="section">
10725<h3><a name="to_atomic_.28to_atom.29"></a>to_atomic (to_atom)</h3>
10726<ul>
10727
10728<li>
10729
10730<p>Syntax:</p>
10731
10732<div>
10733<div>
10734<pre class="source">to_atomic(expr)
10735</pre></div></div>
10736</li>
10737<li>
10738
10739<p>Converts input value to a <a href="../datamodel.html#PrimitiveTypes">primitive</a> value</p>
10740</li>
10741<li>Arguments:
10742<ul>
10743
10744<li><tt>expr</tt> : an expression</li>
10745</ul>
10746</li>
10747<li>Return Value:
10748<ul>
10749
10750<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10751<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10752<li>if the argument is of primitive type then it is returned as is</li>
10753<li>if the argument is of <tt>array</tt> or <tt>multiset</tt> type and has only one element then the result of invoking to_atomic() on that element is returned</li>
10754<li>if the argument is of <tt>object</tt> type and has only one field then the result of invoking to_atomic() on the value of that field is returned</li>
10755<li>otherwise <tt>null</tt> is returned</li>
10756</ul>
10757</li>
10758<li>
10759
10760<p>Example:</p>
10761
10762<div>
10763<div>
10764<pre class="source">{
10765 &quot;v1&quot;: to_atomic(&quot;asterix&quot;),
10766 &quot;v2&quot;: to_atomic([&quot;asterix&quot;]),
10767 &quot;v3&quot;: to_atomic([0, 1]),
10768 &quot;v4&quot;: to_atomic({&quot;value&quot;: &quot;asterix&quot;}),
10769 &quot;v5&quot;: to_number({&quot;x&quot;: 1, &quot;y&quot;: 2})
10770};
10771</pre></div></div>
10772</li>
10773<li>
10774
10775<p>The expected result is:</p>
10776
10777<div>
10778<div>
10779<pre class="source">{ &quot;v1&quot;: &quot;asterix&quot;, &quot;v2&quot;: &quot;asterix&quot;, &quot;v3&quot;: null, &quot;v4&quot;: &quot;asterix&quot;, &quot;v5&quot;: null }
10780</pre></div></div>
10781</li>
10782</ul>
10783<p>The function has three aliases: <tt>toatomic</tt>, <tt>to_atom</tt>, and <tt>toatom</tt>.</p></div>
10784<div class="section">
10785<h3><a name="to_boolean_.28to_bool.29"></a>to_boolean (to_bool)</h3>
10786<ul>
10787
10788<li>
10789
10790<p>Syntax:</p>
10791
10792<div>
10793<div>
10794<pre class="source">to_boolean(expr)
10795</pre></div></div>
10796</li>
10797<li>
10798
10799<p>Converts input value to a <tt>boolean</tt> value</p>
10800</li>
10801<li>Arguments:
10802<ul>
10803
10804<li><tt>expr</tt> : an expression</li>
10805</ul>
10806</li>
10807<li>Return Value:
10808<ul>
10809
10810<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10811<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10812<li>if the argument is of <tt>boolean</tt> type then it is returned as is</li>
10813<li>if the argument is of numeric type then <tt>false</tt> is returned if it is <tt>0</tt> or <tt>NaN</tt>, otherwise <tt>true</tt></li>
10814<li>if the argument is of <tt>string</tt> type then <tt>false</tt> is returned if it&#x2019;s empty, otherwise <tt>true</tt></li>
10815<li>if the argument is of <tt>array</tt> or <tt>multiset</tt> type then <tt>false</tt> is returned if it&#x2019;s size is <tt>0</tt>, otherwise <tt>true</tt></li>
10816<li>if the argument is of <tt>object</tt> type then <tt>false</tt> is returned if it has no fields, otherwise <tt>true</tt></li>
10817<li>type error is raised for all other input types</li>
10818</ul>
10819</li>
10820<li>
10821
10822<p>Example:</p>
10823
10824<div>
10825<div>
10826<pre class="source">{
10827 &quot;v1&quot;: to_boolean(0),
10828 &quot;v2&quot;: to_boolean(1),
10829 &quot;v3&quot;: to_boolean(&quot;&quot;),
10830 &quot;v4&quot;: to_boolean(&quot;asterix&quot;)
10831};
10832</pre></div></div>
10833</li>
10834<li>
10835
10836<p>The expected result is:</p>
10837
10838<div>
10839<div>
10840<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: false, &quot;v4&quot;: true }
10841</pre></div></div>
10842</li>
10843</ul>
10844<p>The function has three aliases: <tt>toboolean</tt>, <tt>to_bool</tt>, and <tt>tobool</tt>.</p></div>
10845<div class="section">
10846<h3><a name="to_bigint"></a>to_bigint</h3>
10847<ul>
10848
10849<li>
10850
10851<p>Syntax:</p>
10852
10853<div>
10854<div>
10855<pre class="source">to_bigint(expr)
10856</pre></div></div>
10857</li>
10858<li>
10859
10860<p>Converts input value to an integer value</p>
10861</li>
10862<li>Arguments:
10863<ul>
10864
10865<li><tt>expr</tt> : an expression</li>
10866</ul>
10867</li>
10868<li>Return Value:
10869<ul>
10870
10871<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10872<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10873<li>if the argument is of <tt>boolean</tt> type then <tt>1</tt> is returned if it is <tt>true</tt>, <tt>0</tt> if it is <tt>false</tt></li>
10874<li>if the argument is of numeric integer type then it is returned as the same value of <tt>bigint</tt> type</li>
10875<li>if the argument is of numeric <tt>float</tt>/<tt>double</tt> type then it is converted to <tt>bigint</tt> type</li>
10876<li>if the argument is of <tt>string</tt> type and can be parsed as integer then that integer value is returned, otherwise <tt>null</tt> is returned</li>
10877<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10878<li>type error is raised for all other input types</li>
10879</ul>
10880</li>
10881<li>
10882
10883<p>Example:</p>
10884
10885<div>
10886<div>
10887<pre class="source">{
10888 &quot;v1&quot;: to_bigint(false),
10889 &quot;v2&quot;: to_bigint(true),
10890 &quot;v3&quot;: to_bigint(10),
10891 &quot;v4&quot;: to_bigint(float(&quot;1e100&quot;)),
10892 &quot;v5&quot;: to_bigint(double(&quot;1e1000&quot;)),
10893 &quot;v6&quot;: to_bigint(&quot;20&quot;)
10894};
10895</pre></div></div>
10896</li>
10897<li>
10898
10899<p>The expected result is:</p>
10900
10901<div>
10902<div>
10903<pre class="source">{ &quot;v1&quot;: 0, &quot;v2&quot;: 1, &quot;v3&quot;: 10, &quot;v4&quot;: 9223372036854775807, &quot;v5&quot;: 9223372036854775807, &quot;v6&quot;: 20 }
10904</pre></div></div>
10905</li>
10906</ul>
10907<p>The function has an alias <tt>tobigint</tt>.</p></div>
10908<div class="section">
10909<h3><a name="to_double"></a>to_double</h3>
10910<ul>
10911
10912<li>
10913
10914<p>Syntax:</p>
10915
10916<div>
10917<div>
10918<pre class="source">to_double(expr)
10919</pre></div></div>
10920</li>
10921<li>
10922
10923<p>Converts input value to a <tt>double</tt> value</p>
10924</li>
10925<li>Arguments:
10926<ul>
10927
10928<li><tt>expr</tt> : an expression</li>
10929</ul>
10930</li>
10931<li>Return Value:
10932<ul>
10933
10934<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10935<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10936<li>if the argument is of <tt>boolean</tt> type then <tt>1.0</tt> is returned if it is <tt>true</tt>, <tt>0.0</tt> if it is <tt>false</tt></li>
10937<li>if the argument is of numeric type then it is returned as the value of <tt>double</tt> type</li>
10938<li>if the argument is of <tt>string</tt> type and can be parsed as <tt>double</tt> then that <tt>double</tt> value is returned, otherwise <tt>null</tt> is returned</li>
10939<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10940<li>type error is raised for all other input types</li>
10941</ul>
10942</li>
10943<li>
10944
10945<p>Example:</p>
10946
10947<div>
10948<div>
10949<pre class="source">{
10950 &quot;v1&quot;: to_double(false),
10951 &quot;v2&quot;: to_double(true),
10952 &quot;v3&quot;: to_double(10),
10953 &quot;v4&quot;: to_double(11.5),
10954 &quot;v5&quot;: to_double(&quot;12.5&quot;)
10955};
10956</pre></div></div>
10957</li>
10958<li>
10959
10960<p>The expected result is:</p>
10961
10962<div>
10963<div>
10964<pre class="source">{ &quot;v1&quot;: 0.0, &quot;v2&quot;: 1.0, &quot;v3&quot;: 10.0, &quot;v4&quot;: 11.5, &quot;v5&quot;: 12.5 }
10965</pre></div></div>
10966</li>
10967</ul>
10968<p>The function has an alias <tt>todouble</tt>.</p></div>
10969<div class="section">
10970<h3><a name="to_number_.28to_num.29"></a>to_number (to_num)</h3>
10971<ul>
10972
10973<li>
10974
10975<p>Syntax:</p>
10976
10977<div>
10978<div>
10979<pre class="source">to_number(expr)
10980</pre></div></div>
10981</li>
10982<li>
10983
10984<p>Converts input value to a numeric value</p>
10985</li>
10986<li>Arguments:
10987<ul>
10988
10989<li><tt>expr</tt> : an expression</li>
10990</ul>
10991</li>
10992<li>Return Value:
10993<ul>
10994
10995<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10996<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10997<li>if the argument is of numeric type then it is returned as is</li>
10998<li>if the argument is of <tt>boolean</tt> type then <tt>1</tt> is returned if it is <tt>true</tt>, <tt>0</tt> if it is <tt>false</tt></li>
10999<li>if the argument is of <tt>string</tt> type and can be parsed as <tt>bigint</tt> then that <tt>bigint</tt> value is returned, otherwise if it can be parsed as <tt>double</tt> then that <tt>double</tt> value is returned, otherwise <tt>null</tt> is returned</li>
11000<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
11001<li>type error is raised for all other input types</li>
11002</ul>
11003</li>
11004<li>
11005
11006<p>Example:</p>
11007
11008<div>
11009<div>
11010<pre class="source">{
11011 &quot;v1&quot;: to_number(false),
11012 &quot;v2&quot;: to_number(true),
11013 &quot;v3&quot;: to_number(10),
11014 &quot;v4&quot;: to_number(11.5),
11015 &quot;v5&quot;: to_number(&quot;12.5&quot;)
11016};
11017</pre></div></div>
11018</li>
11019<li>
11020
11021<p>The expected result is:</p>
11022
11023<div>
11024<div>
11025<pre class="source">{ &quot;v1&quot;: 0, &quot;v2&quot;: 1, &quot;v3&quot;: 10, &quot;v4&quot;: 11.5, &quot;v5&quot;: 12.5 }
11026</pre></div></div>
11027</li>
11028</ul>
11029<p>The function has three aliases: <tt>tonumber</tt>, <tt>to_num</tt>, and <tt>tonum</tt>.</p></div>
11030<div class="section">
11031<h3><a name="to_object_.28to_obj.29"></a>to_object (to_obj)</h3>
11032<ul>
11033
11034<li>
11035
11036<p>Syntax:</p>
11037
11038<div>
11039<div>
11040<pre class="source">to_object(expr)
11041</pre></div></div>
11042</li>
11043<li>
11044
11045<p>Converts input value to an <tt>object</tt> value</p>
11046</li>
11047<li>Arguments:
11048<ul>
11049
11050<li><tt>expr</tt> : an expression</li>
11051</ul>
11052</li>
11053<li>Return Value:
11054<ul>
11055
11056<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
11057<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
11058<li>if the argument is of <tt>object</tt> type then it is returned as is</li>
11059<li>otherwise an empty <tt>object</tt> is returned</li>
11060</ul>
11061</li>
11062<li>
11063
11064<p>Example:</p>
11065
11066<div>
11067<div>
11068<pre class="source">{
11069 &quot;v1&quot;: to_object({&quot;value&quot;: &quot;asterix&quot;}),
11070 &quot;v2&quot;: to_object(&quot;asterix&quot;)
11071};
11072</pre></div></div>
11073</li>
11074<li>
11075
11076<p>The expected result is:</p>
11077
11078<div>
11079<div>
11080<pre class="source">{ &quot;v1&quot;: {&quot;value&quot;: &quot;asterix&quot;}, &quot;v2&quot;: {} }
11081</pre></div></div>
11082</li>
11083</ul>
11084<p>The function has three aliases: <tt>toobject</tt>, <tt>to_obj</tt>, and <tt>toobj</tt>.</p></div>
11085<div class="section">
11086<h3><a name="to_string_.28to_str.29"></a>to_string (to_str)</h3>
11087<ul>
11088
11089<li>
11090
11091<p>Syntax:</p>
11092
11093<div>
11094<div>
11095<pre class="source">to_string(expr)
11096</pre></div></div>
11097</li>
11098<li>
11099
11100<p>Converts input value to a string value</p>
11101</li>
11102<li>Arguments:
11103<ul>
11104
11105<li><tt>expr</tt> : an expression</li>
11106</ul>
11107</li>
11108<li>Return Value:
11109<ul>
11110
11111<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
11112<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
11113<li>if the argument is of <tt>boolean</tt> type then <tt>&quot;true&quot;</tt> is returned if it is <tt>true</tt>, <tt>&quot;false&quot;</tt> if it is <tt>false</tt></li>
11114<li>if the argument is of numeric type then its string representation is returned</li>
11115<li>if the argument is of <tt>string</tt> type then it is returned as is</li>
11116<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
11117<li>type error is raised for all other input types</li>
11118</ul>
11119</li>
11120<li>
11121
11122<p>Example:</p>
11123
11124<div>
11125<div>
11126<pre class="source">{
11127 &quot;v1&quot;: to_string(false),
11128 &quot;v2&quot;: to_string(true),
11129 &quot;v3&quot;: to_string(10),
11130 &quot;v4&quot;: to_string(11.5),
11131 &quot;v5&quot;: to_string(&quot;asterix&quot;)
11132};
11133</pre></div></div>
11134</li>
11135<li>
11136
11137<p>The expected result is:</p>
11138
11139<div>
11140<div>
11141<pre class="source">{ &quot;v1&quot;: &quot;false&quot;, &quot;v2&quot;: &quot;true&quot;, &quot;v3&quot;: &quot;10&quot;, &quot;v4&quot;: &quot;11.5&quot;, &quot;v5&quot;: &quot;asterix&quot; }
11142</pre></div></div>
11143</li>
11144</ul>
11145<p>The function has three aliases: <tt>tostring</tt>, <tt>to_str</tt>, and <tt>tostr</tt>.</p><!--
11146 ! Licensed to the Apache Software Foundation (ASF) under one
11147 ! or more contributor license agreements. See the NOTICE file
11148 ! distributed with this work for additional information
11149 ! regarding copyright ownership. The ASF licenses this file
11150 ! to you under the Apache License, Version 2.0 (the
11151 ! "License"); you may not use this file except in compliance
11152 ! with the License. You may obtain a copy of the License at
11153 !
11154 ! http://www.apache.org/licenses/LICENSE-2.0
11155 !
11156 ! Unless required by applicable law or agreed to in writing,
11157 ! software distributed under the License is distributed on an
11158 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11159 ! KIND, either express or implied. See the License for the
11160 ! specific language governing permissions and limitations
11161 ! under the License.
11162 !-->
11163</div></div>
11164<div class="section">
11165<h2><a name="Conditional_Functions"></a><a name="ConditionalFunctions" id="ConditionalFunctions">Conditional Functions</a></h2>
11166<div class="section">
11167<h3><a name="if_null_.28ifnull.29"></a>if_null (ifnull)</h3>
11168<ul>
11169
11170<li>
11171
11172<p>Syntax:</p>
11173
11174<div>
11175<div>
11176<pre class="source">if_null(expression1, expression2, ... expressionN)
11177</pre></div></div>
11178</li>
11179<li>
11180
11181<p>Finds first argument which value is not <tt>null</tt> and returns that value</p>
11182</li>
11183<li>Arguments:
11184<ul>
11185
11186<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11187</ul>
11188</li>
11189<li>Return Value:
11190<ul>
11191
11192<li>a <tt>null</tt> if all arguments evaluate to <tt>null</tt> or no arguments specified</li>
11193<li>a value of the first non-<tt>null</tt> argument otherwise</li>
11194</ul>
11195</li>
11196<li>
11197
11198<p>Example:</p>
11199
11200<div>
11201<div>
11202<pre class="source">{
11203 &quot;a&quot;: if_null(),
11204 &quot;b&quot;: if_null(null),
11205 &quot;c&quot;: if_null(null, &quot;asterixdb&quot;),
11206 &quot;d&quot;: is_missing(if_null(missing))
11207};
11208</pre></div></div>
11209</li>
11210<li>
11211
11212<p>The expected result is:</p>
11213
11214<div>
11215<div>
11216<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: true }
11217</pre></div></div>
11218</li>
11219</ul>
11220<p>The function has an alias <tt>ifnull</tt>.</p></div>
11221<div class="section">
11222<h3><a name="if_missing_.28ifmissing.29"></a>if_missing (ifmissing)</h3>
11223<ul>
11224
11225<li>
11226
11227<p>Syntax:</p>
11228
11229<div>
11230<div>
11231<pre class="source">if_missing(expression1, expression2, ... expressionN)
11232</pre></div></div>
11233</li>
11234<li>
11235
11236<p>Finds first argument which value is not <tt>missing</tt> and returns that value</p>
11237</li>
11238<li>Arguments:
11239<ul>
11240
11241<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11242</ul>
11243</li>
11244<li>Return Value:
11245<ul>
11246
11247<li>a <tt>null</tt> if all arguments evaluate to <tt>missing</tt> or no arguments specified</li>
11248<li>a value of the first non-<tt>missing</tt> argument otherwise</li>
11249</ul>
11250</li>
11251<li>
11252
11253<p>Example:</p>
11254
11255<div>
11256<div>
11257<pre class="source">{
11258 &quot;a&quot;: if_missing(),
11259 &quot;b&quot;: if_missing(missing),
11260 &quot;c&quot;: if_missing(missing, &quot;asterixdb&quot;),
11261 &quot;d&quot;: if_missing(null, &quot;asterixdb&quot;)
11262};
11263</pre></div></div>
11264</li>
11265<li>
11266
11267<p>The expected result is:</p>
11268
11269<div>
11270<div>
11271<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: null }
11272</pre></div></div>
11273</li>
11274</ul>
11275<p>The function has an alias <tt>ifmissing</tt>.</p></div>
11276<div class="section">
11277<h3><a name="if_missing_or_null_.28ifmissingornull.2C_coalesce.29"></a>if_missing_or_null (ifmissingornull, coalesce)</h3>
11278<ul>
11279
11280<li>
11281
11282<p>Syntax:</p>
11283
11284<div>
11285<div>
11286<pre class="source">if_missing_or_null(expression1, expression2, ... expressionN)
11287</pre></div></div>
11288</li>
11289<li>
11290
11291<p>Finds first argument which value is not <tt>null</tt> or <tt>missing</tt> and returns that value</p>
11292</li>
11293<li>Arguments:
11294<ul>
11295
11296<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11297</ul>
11298</li>
11299<li>Return Value:
11300<ul>
11301
11302<li>a <tt>null</tt> if all arguments evaluate to either <tt>null</tt> or <tt>missing</tt>, or no arguments specified</li>
11303<li>a value of the first non-<tt>null</tt>, non-<tt>missing</tt> argument otherwise</li>
11304</ul>
11305</li>
11306<li>
11307
11308<p>Example:</p>
11309
11310<div>
11311<div>
11312<pre class="source">{
11313 &quot;a&quot;: if_missing_or_null(),
11314 &quot;b&quot;: if_missing_or_null(null, missing),
11315 &quot;c&quot;: if_missing_or_null(null, missing, &quot;asterixdb&quot;)
11316};
11317</pre></div></div>
11318</li>
11319<li>
11320
11321<p>The expected result is:</p>
11322
11323<div>
11324<div>
11325<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot; }
11326</pre></div></div>
11327</li>
11328</ul>
11329<p>The function has two aliases: <tt>ifmissingornull</tt> and <tt>coalesce</tt>.</p></div>
11330<div class="section">
11331<h3><a name="if_inf_.28ifinf.29"></a>if_inf (ifinf)</h3>
11332<ul>
11333
11334<li>
11335
11336<p>Syntax:</p>
11337
11338<div>
11339<div>
11340<pre class="source">if_inf(expression1, expression2, ... expressionN)
11341</pre></div></div>
11342</li>
11343<li>
11344
11345<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) number</p>
11346</li>
11347<li>Arguments:
11348<ul>
11349
11350<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11351</ul>
11352</li>
11353<li>Return Value:
11354<ul>
11355
11356<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-infinite number argument</li>
11357<li>a <tt>null</tt> if <tt>null</tt> argument or any other non-number argument was encountered before the first non-infinite number argument</li>
11358<li>the first non-infinite number argument otherwise</li>
11359</ul>
11360</li>
11361<li>
11362
11363<p>Example:</p>
11364
11365<div>
11366<div>
11367<pre class="source">{
11368 &quot;a&quot;: is_null(if_inf(null)),
11369 &quot;b&quot;: is_missing(if_inf(missing)),
11370 &quot;c&quot;: is_null(if_inf(double(&quot;INF&quot;))),
11371 &quot;d&quot;: if_inf(1, null, missing) ],
11372 &quot;e&quot;: is_null(if_inf(null, missing, 1)) ],
11373 &quot;f&quot;: is_missing(if_inf(missing, null, 1)) ],
11374 &quot;g&quot;: if_inf(float(&quot;INF&quot;), 1) ],
11375 &quot;h&quot;: to_string(if_inf(float(&quot;INF&quot;), double(&quot;NaN&quot;), 1)) ]
11376};
11377</pre></div></div>
11378</li>
11379<li>
11380
11381<p>The expected result is:</p>
11382
11383<div>
11384<div>
11385<pre class="source">{ &quot;a&quot;: true, &quot;b&quot;: true, &quot;c&quot;: true, &quot;d&quot;: 1, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: 1, &quot;h&quot;: &quot;NaN&quot; }
11386</pre></div></div>
11387</li>
11388</ul>
11389<p>The function has an alias <tt>ifinf</tt>.</p></div>
11390<div class="section">
11391<h3><a name="if_nan_.28ifnan.29"></a>if_nan (ifnan)</h3>
11392<ul>
11393
11394<li>
11395
11396<p>Syntax:</p>
11397
11398<div>
11399<div>
11400<pre class="source">if_nan(expression1, expression2, ... expressionN)
11401</pre></div></div>
11402</li>
11403<li>
11404
11405<p>Finds first argument which is a non-<tt>NaN</tt> number</p>
11406</li>
11407<li>Arguments:
11408<ul>
11409
11410<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11411</ul>
11412</li>
11413<li>Return Value:
11414<ul>
11415
11416<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-<tt>NaN</tt> number argument</li>
11417<li>a <tt>null</tt> if <tt>null</tt> argument or any other non-number argument was encountered before the first non-<tt>NaN</tt> number argument</li>
11418<li>the first non-<tt>NaN</tt> number argument otherwise</li>
11419</ul>
11420</li>
11421<li>
11422
11423<p>Example:</p>
11424
11425<div>
11426<div>
11427<pre class="source">{
11428 &quot;a&quot;: is_null(if_nan(null)),
11429 &quot;b&quot;: is_missing(if_nan(missing)),
11430 &quot;c&quot;: is_null(if_nan(double(&quot;NaN&quot;))),
11431 &quot;d&quot;: if_nan(1, null, missing) ],
11432 &quot;e&quot;: is_null(if_nan(null, missing, 1)) ],
11433 &quot;f&quot;: is_missing(if_nan(missing, null, 1)) ],
11434 &quot;g&quot;: if_nan(float(&quot;NaN&quot;), 1) ],
11435 &quot;h&quot;: to_string(if_nan(float(&quot;NaN&quot;), double(&quot;INF&quot;), 1)) ]
11436};
11437</pre></div></div>
11438</li>
11439<li>
11440
11441<p>The expected result is:</p>
11442
11443<div>
11444<div>
11445<pre class="source">{ &quot;a&quot;: true, &quot;b&quot;: true, &quot;c&quot;: true, &quot;d&quot;: 1, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: 1, &quot;h&quot;: &quot;INF&quot; }
11446</pre></div></div>
11447</li>
11448</ul>
11449<p>The function has an alias <tt>ifnan</tt>.</p></div>
11450<div class="section">
11451<h3><a name="if_nan_or_inf_.28ifnanorinf.29"></a>if_nan_or_inf (ifnanorinf)</h3>
11452<ul>
11453
11454<li>
11455
11456<p>Syntax:</p>
11457
11458<div>
11459<div>
11460<pre class="source">if_nan_or_inf(expression1, expression2, ... expressionN)
11461</pre></div></div>
11462</li>
11463<li>
11464
11465<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) and non-<tt>NaN</tt> number</p>
11466</li>
11467<li>Arguments:
11468<ul>
11469
11470<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11471</ul>
11472</li>
11473<li>Return Value:
11474<ul>
11475
11476<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-infinite and non-<tt>NaN</tt> number argument</li>
11477<li>a <tt>null</tt> if <tt>null</tt> argument or any other non-number argument was encountered before the first non-infinite and non-<tt>NaN</tt> number argument</li>
11478<li>the first non-infinite and non-<tt>NaN</tt> number argument otherwise</li>
11479</ul>
11480</li>
11481<li>
11482
11483<p>Example:</p>
11484
11485<div>
11486<div>
11487<pre class="source">{
11488 &quot;a&quot;: is_null(if_nan_or_inf(null)),
11489 &quot;b&quot;: is_missing(if_nan_or_inf(missing)),
11490 &quot;c&quot;: is_null(if_nan_or_inf(double(&quot;NaN&quot;), double(&quot;INF&quot;))),
11491 &quot;d&quot;: if_nan_or_inf(1, null, missing) ],
11492 &quot;e&quot;: is_null(if_nan_or_inf(null, missing, 1)) ],
11493 &quot;f&quot;: is_missing(if_nan_or_inf(missing, null, 1)) ],
11494 &quot;g&quot;: if_nan_or_inf(float(&quot;NaN&quot;), float(&quot;INF&quot;), 1) ],
11495};
11496</pre></div></div>
11497</li>
11498<li>
11499
11500<p>The expected result is:</p>
11501
11502<div>
11503<div>
11504<pre class="source">{ &quot;a&quot;: true, &quot;b&quot;: true, &quot;c&quot;: true, &quot;d&quot;: 1, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: 1 }
11505</pre></div></div>
11506</li>
11507</ul>
11508<p>The function has an alias <tt>ifnanorinf</tt>.</p></div>
11509<div class="section">
11510<h3><a name="null_if_.28nullif.29"></a>null_if (nullif)</h3>
11511<ul>
11512
11513<li>
11514
11515<p>Syntax:</p>
11516
11517<div>
11518<div>
11519<pre class="source">null_if(expression1, expression2)
11520</pre></div></div>
11521</li>
11522<li>
11523
11524<p>Compares two arguments and returns <tt>null</tt> if they are equal, otherwise returns the first argument.</p>
11525</li>
11526<li>Arguments:
11527<ul>
11528
11529<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11530</ul>
11531</li>
11532<li>Return Value:
11533<ul>
11534
11535<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11536<li><tt>null</tt> if
11537<ul>
11538
11539<li>any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or</li>
11540<li><tt>argument1</tt> = <tt>argument2</tt></li>
11541</ul>
11542</li>
11543<li>a value of the first argument otherwise</li>
11544</ul>
11545</li>
11546<li>
11547
11548<p>Example:</p>
11549
11550<div>
11551<div>
11552<pre class="source">{
11553 &quot;a&quot;: null_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;),
11554 &quot;b&quot;: null_if(1, 2)
11555};
11556</pre></div></div>
11557</li>
11558<li>
11559
11560<p>The expected result is:</p>
11561
11562<div>
11563<div>
11564<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: 1 }
11565</pre></div></div>
11566</li>
11567</ul>
11568<p>The function has an alias <tt>nullif</tt>.</p></div>
11569<div class="section">
11570<h3><a name="missing_if_.28missingif.29"></a>missing_if (missingif)</h3>
11571<ul>
11572
11573<li>
11574
11575<p>Syntax:</p>
11576
11577<div>
11578<div>
11579<pre class="source">missing_if(expression1, expression2)
11580</pre></div></div>
11581</li>
11582<li>
11583
11584<p>Compares two arguments and returns <tt>missing</tt> if they are equal, otherwise returns the first argument.</p>
11585</li>
11586<li>Arguments:
11587<ul>
11588
11589<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11590</ul>
11591</li>
11592<li>Return Value:
11593<ul>
11594
11595<li><tt>missing</tt> if
11596<ul>
11597
11598<li>any argument is a <tt>missing</tt> value, or</li>
11599<li>no argument is a <tt>null</tt> value and <tt>argument1</tt> = <tt>argument2</tt></li>
11600</ul>
11601</li>
11602<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11603<li>a value of the first argument otherwise</li>
11604</ul>
11605</li>
11606<li>
11607
11608<p>Example:</p>
11609
11610<div>
11611<div>
11612<pre class="source">{
11613 &quot;a&quot;: missing_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)
11614 &quot;b&quot;: missing_if(1, 2),
11615};
11616</pre></div></div>
11617</li>
11618<li>
11619
11620<p>The expected result is:</p>
11621
11622<div>
11623<div>
11624<pre class="source">{ &quot;b&quot;: 1 }
11625</pre></div></div>
11626</li>
11627</ul>
11628<p>The function has an alias <tt>missingif</tt>.</p></div>
11629<div class="section">
11630<h3><a name="nan_if_.28nanif.29"></a>nan_if (nanif)</h3>
11631<ul>
11632
11633<li>
11634
11635<p>Syntax:</p>
11636
11637<div>
11638<div>
11639<pre class="source">nan_if(expression1, expression2)
11640</pre></div></div>
11641</li>
11642<li>
11643
11644<p>Compares two arguments and returns <tt>NaN</tt> value if they are equal, otherwise returns the first argument.</p>
11645</li>
11646<li>Arguments:
11647<ul>
11648
11649<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11650</ul>
11651</li>
11652<li>Return Value:
11653<ul>
11654
11655<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11656<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11657<li><tt>NaN</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11658<li>a value of the first argument otherwise</li>
11659</ul>
11660</li>
11661<li>
11662
11663<p>Example:</p>
11664
11665<div>
11666<div>
11667<pre class="source">{
11668 &quot;a&quot;: to_string(nan_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11669 &quot;b&quot;: nan_if(1, 2)
11670};
11671</pre></div></div>
11672</li>
11673<li>
11674
11675<p>The expected result is:</p>
11676
11677<div>
11678<div>
11679<pre class="source">{ &quot;a&quot;: &quot;NaN&quot;, &quot;b&quot;: 1 }
11680</pre></div></div>
11681</li>
11682</ul>
11683<p>The function has an alias <tt>nanif</tt>.</p></div>
11684<div class="section">
11685<h3><a name="posinf_if_.28posinfif.29"></a>posinf_if (posinfif)</h3>
11686<ul>
11687
11688<li>
11689
11690<p>Syntax:</p>
11691
11692<div>
11693<div>
11694<pre class="source">posinf_if(expression1, expression2)
11695</pre></div></div>
11696</li>
11697<li>
11698
11699<p>Compares two arguments and returns <tt>+INF</tt> value if they are equal, otherwise returns the first argument.</p>
11700</li>
11701<li>Arguments:
11702<ul>
11703
11704<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11705</ul>
11706</li>
11707<li>Return Value:
11708<ul>
11709
11710<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11711<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11712<li><tt>+INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11713<li>a value of the first argument otherwise</li>
11714</ul>
11715</li>
11716<li>
11717
11718<p>Example:</p>
11719
11720<div>
11721<div>
11722<pre class="source">{
11723 &quot;a&quot;: to_string(posinf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11724 &quot;b&quot;: posinf_if(1, 2)
11725};
11726</pre></div></div>
11727</li>
11728<li>
11729
11730<p>The expected result is:</p>
11731
11732<div>
11733<div>
11734<pre class="source">{ &quot;a&quot;: &quot;+INF&quot;, &quot;b&quot;: 1 }
11735</pre></div></div>
11736</li>
11737</ul>
11738<p>The function has an alias <tt>posinfif</tt>.</p></div>
11739<div class="section">
11740<h3><a name="neginf_if_.28neginfif.29"></a>neginf_if (neginfif)</h3>
11741<ul>
11742
11743<li>
11744
11745<p>Syntax:</p>
11746
11747<div>
11748<div>
11749<pre class="source">neginf_if(expression1, expression2)
11750</pre></div></div>
11751</li>
11752<li>
11753
11754<p>Compares two arguments and returns <tt>-INF</tt> value if they are equal, otherwise returns the first argument.</p>
11755</li>
11756<li>Arguments:
11757<ul>
11758
11759<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11760</ul>
11761</li>
11762<li>Return Value:
11763<ul>
11764
11765<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11766<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11767<li><tt>-INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11768<li>a value of the first argument otherwise</li>
11769</ul>
11770</li>
11771<li>
11772
11773<p>Example:</p>
11774
11775<div>
11776<div>
11777<pre class="source">{
11778 &quot;a&quot;: to_string(neginf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11779 &quot;b&quot;: neginf_if(1, 2)
11780};
11781</pre></div></div>
11782</li>
11783<li>
11784
11785<p>The expected result is:</p>
11786
11787<div>
11788<div>
11789<pre class="source">{ &quot;a&quot;: &quot;-INF&quot;, &quot;b&quot;: 1 }
11790</pre></div></div>
11791</li>
11792</ul>
11793<p>The function has an alias <tt>neginfif</tt>.</p><!--
11794 ! Licensed to the Apache Software Foundation (ASF) under one
11795 ! or more contributor license agreements. See the NOTICE file
11796 ! distributed with this work for additional information
11797 ! regarding copyright ownership. The ASF licenses this file
11798 ! to you under the Apache License, Version 2.0 (the
11799 ! "License"); you may not use this file except in compliance
11800 ! with the License. You may obtain a copy of the License at
11801 !
11802 ! http://www.apache.org/licenses/LICENSE-2.0
11803 !
11804 ! Unless required by applicable law or agreed to in writing,
11805 ! software distributed under the License is distributed on an
11806 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11807 ! KIND, either express or implied. See the License for the
11808 ! specific language governing permissions and limitations
11809 ! under the License.
11810 !-->
11811</div></div>
11812<div class="section">
11813<h2><a name="Miscellaneous_Functions"></a><a name="MiscFunctions" id="MiscFunctions">Miscellaneous Functions</a></h2>
11814<div class="section">
11815<h3><a name="uuid"></a>uuid</h3>
11816<ul>
11817
11818<li>
11819
11820<p>Syntax:</p>
11821
11822<div>
11823<div>
11824<pre class="source">uuid()
11825</pre></div></div>
11826</li>
11827<li>
11828
11829<p>Generates a <tt>uuid</tt>.</p>
11830</li>
11831<li>Arguments:
11832<ul>
11833
11834<li>none</li>
11835</ul>
11836</li>
11837<li>Return Value:
11838<ul>
11839
11840<li>a generated, random <tt>uuid</tt>.</li>
11841</ul>
11842</li>
11843</ul></div>
11844<div class="section">
11845<h3><a name="len"></a>len</h3>
11846<ul>
11847
11848<li>
11849
11850<p>Syntax:</p>
11851<p>len(array)</p>
11852</li>
11853<li>
11854
11855<p>Returns the length of the array array.</p>
11856</li>
11857<li>Arguments:
11858<ul>
11859
11860<li><tt>array</tt> : an <tt>array</tt>, <tt>multiset</tt>, <tt>null</tt>, or <tt>missing</tt>, represents the collection that needs to be checked.</li>
11861</ul>
11862</li>
11863<li>Return Value:
11864<ul>
11865
11866<li>an <tt>integer</tt> that represents the length of input array or the size of the input multiset,</li>
11867<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11868<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
11869</ul>
11870</li>
11871<li>
11872
11873<p>Example:</p>
11874
11875<div>
11876<div>
11877<pre class="source">len([&quot;Hello&quot;, &quot;World&quot;])
11878</pre></div></div>
11879</li>
11880<li>
11881
11882<p>The expected result is:</p>
11883
11884<div>
11885<div>
11886<pre class="source">2
11887</pre></div></div>
11888</li>
11889</ul></div>
11890<div class="section">
11891<h3><a name="not"></a>not</h3>
11892<ul>
11893
11894<li>
11895
11896<p>Syntax:</p>
11897
11898<div>
11899<div>
11900<pre class="source">not(expr)
11901</pre></div></div>
11902</li>
11903<li>
11904
11905<p>Inverts a <tt>boolean</tt> value</p>
11906</li>
11907<li>Arguments:
11908<ul>
11909
11910<li><tt>expr</tt> : an expression</li>
11911</ul>
11912</li>
11913<li>Return Value:
11914<ul>
11915
11916<li>a <tt>boolean</tt>, the inverse of <tt>expr</tt>,</li>
11917<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11918<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
11919<li>other non-boolean argument value will cause a type error.</li>
11920</ul>
11921</li>
11922<li>Example:
11923
11924<div>
11925<div>
11926<pre class="source">{ &quot;v1&quot;: `not`(true), &quot;v2&quot;: `not`(false), &quot;v3&quot;: `not`(null), &quot;v4&quot;: `not`(missing) };
11927</pre></div></div>
11928</li>
11929<li>
11930
11931<p>The expected result is:</p>
11932
11933<div>
11934<div>
11935<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: null }
11936</pre></div></div>
11937</li>
11938</ul></div>
11939<div class="section">
11940<h3><a name="random"></a>random</h3>
11941<ul>
11942
11943<li>
11944
11945<p>Syntax:</p>
11946
11947<div>
11948<div>
11949<pre class="source">random( [seed_value] )
11950</pre></div></div>
11951</li>
11952<li>
11953
11954<p>Returns a random number, accepting an optional seed value</p>
11955</li>
11956<li>Arguments:
11957<ul>
11958
11959<li><tt>seed_value</tt>: an optional <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value representing the seed number.</li>
11960</ul>
11961</li>
11962<li>Return Value:
11963<ul>
11964
11965<li>A random number of type <tt>double</tt> between 0 and 1,</li>
11966<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
11967<li><tt>null</tt> if the argument is a <tt>null</tt> value or a non-numeric value.</li>
11968</ul>
11969</li>
11970<li>
11971
11972<p>Example:</p>
11973
11974<div>
11975<div>
11976<pre class="source">{
11977 &quot;v1&quot;: random(),
11978 &quot;v2&quot;: random(unix_time_from_datetime_in_ms(current_datetime()))
11979};
11980</pre></div></div>
11981</li>
11982</ul></div>
11983<div class="section">
11984<h3><a name="range"></a>range</h3>
11985<ul>
11986
11987<li>
11988
11989<p>Syntax:</p>
11990
11991<div>
11992<div>
11993<pre class="source">range(start_numeric_value, end_numeric_value)
11994</pre></div></div>
11995</li>
11996<li>
11997
11998<p>Generates a series of <tt>bigint</tt> values based start the <tt>start_numeric_value</tt> until the <tt>end_numeric_value</tt>.</p>
11999</li>
12000<li>Arguments:</li>
12001<li><tt>start_numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the start value.</li>
12002<li><tt>end_numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the max final value.</li>
12003<li>Return Value:
12004<ul>
12005
12006<li>an array that starts with the integer value of <tt>start_numeric_value</tt> and ends with the integer value of <tt>end_numeric_value</tt>, where the value of each entry in the array is the integer successor of the value in the preceding entry.</li>
12007</ul>
12008</li>
12009<li>Example:
12010
12011<div>
12012<div>
12013<pre class="source">range(0, 3);
12014</pre></div></div>
12015</li>
12016<li>
12017
12018<p>The expected result is:</p>
12019
12020<div>
12021<div>
12022<pre class="source">[ 0, 1, 2, 3 ]
12023</pre></div></div>
12024</li>
12025</ul></div>
12026<div class="section">
12027<h3><a name="switch_case"></a>switch_case</h3>
12028<ul>
12029
12030<li>
12031
12032<p>Syntax:</p>
12033
12034<div>
12035<div>
12036<pre class="source">switch_case(
12037 condition,
12038 case1, case1_result,
12039 case2, case2_result,
12040 ...,
12041 default, default_result
12042)
12043</pre></div></div>
12044</li>
12045<li>
12046
12047<p>Switches amongst a sequence of cases and returns the result of the first matching case. If no match is found, the result of the default case is returned.</p>
12048</li>
12049<li>Arguments:
12050<ul>
12051
12052<li><tt>condition</tt>: a variable (any type is allowed).</li>
12053<li><tt>caseI/default</tt>: a variable (any type is allowed).</li>
12054<li><tt>caseI/default_result</tt>: a variable (any type is allowed).</li>
12055</ul>
12056</li>
12057<li>Return Value:
12058<ul>
12059
12060<li><tt>caseI_result</tt> if <tt>condition</tt> matches <tt>caseI</tt>, otherwise <tt>default_result</tt>.</li>
12061</ul>
12062</li>
12063<li>Example 1:
12064
12065<div>
12066<div>
12067<pre class="source">switch_case(
12068 &quot;a&quot;,
12069 &quot;a&quot;, 0,
12070 &quot;x&quot;, 1,
12071 &quot;y&quot;, 2,
12072 &quot;z&quot;, 3
12073);
12074</pre></div></div>
12075</li>
12076<li>
12077
12078<p>The expected result is:</p>
12079
12080<div>
12081<div>
12082<pre class="source">0
12083</pre></div></div>
12084</li>
12085<li>
12086
12087<p>Example 2:</p>
12088
12089<div>
12090<div>
12091<pre class="source">switch_case(
12092 &quot;a&quot;,
12093 &quot;x&quot;, 1,
12094 &quot;y&quot;, 2,
12095 &quot;z&quot;, 3
12096);
12097</pre></div></div>
12098</li>
12099<li>
12100
12101<p>The expected result is:</p>
12102
12103<div>
12104<div>
12105<pre class="source">3
12106</pre></div></div>
12107</li>
12108</ul></div>
12109<div class="section">
12110<h3><a name="deep_equal"></a>deep_equal</h3>
12111<ul>
12112
12113<li>
12114
12115<p>Syntax:</p>
12116
12117<div>
12118<div>
12119<pre class="source">deep_equal(expr1, expr2)
12120</pre></div></div>
12121</li>
12122<li>
12123
12124<p>Assess the equality between two expressions of any type (e.g., object, arrays, or multiset). Two objects are deeply equal iff both their types and values are equal.</p>
12125</li>
12126<li>Arguments:
12127<ul>
12128
12129<li><tt>expr1</tt> : an expression,</li>
12130<li><tt>expr2</tt> : an expression.</li>
12131</ul>
12132</li>
12133<li>Return Value:
12134<ul>
12135
12136<li><tt>true</tt> or <tt>false</tt> depending on the data equality,</li>
12137<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
12138<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
12139</ul>
12140</li>
12141<li>
12142
12143<p>Example:</p>
12144
12145<div>
12146<div>
12147<pre class="source">deep_equal(
12148 {
12149 &quot;id&quot;:1,
12150 &quot;project&quot;:&quot;AsterixDB&quot;,
12151 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
12152 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
12153 },
12154 {
12155 &quot;id&quot;:1,
12156 &quot;project&quot;:&quot;AsterixDB&quot;,
12157 &quot;address&quot;:{&quot;city&quot;:&quot;San Diego&quot;, &quot;state&quot;:&quot;CA&quot;},
12158 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
12159 }
12160);
12161</pre></div></div>
12162</li>
12163<li>
12164
12165<p>The expected result is:</p>
12166
12167<div>
12168<div>
12169<pre class="source">false
12170</pre></div></div>
12171</li>
12172</ul><!--
12173 ! Licensed to the Apache Software Foundation (ASF) under one
12174 ! or more contributor license agreements. See the NOTICE file
12175 ! distributed with this work for additional information
12176 ! regarding copyright ownership. The ASF licenses this file
12177 ! to you under the Apache License, Version 2.0 (the
12178 ! "License"); you may not use this file except in compliance
12179 ! with the License. You may obtain a copy of the License at
12180 !
12181 ! http://www.apache.org/licenses/LICENSE-2.0
12182 !
12183 ! Unless required by applicable law or agreed to in writing,
12184 ! software distributed under the License is distributed on an
12185 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12186 ! KIND, either express or implied. See the License for the
12187 ! specific language governing permissions and limitations
12188 ! under the License.
12189 !-->
12190</div></div>
12191<div class="section">
12192<h2><a name="Bitwise_Functions"></a><a name="BitwiseFunctions" id="BitwiseFunctions">Bitwise Functions</a></h2>
12193<p>All Bit/Binary functions can only operate on 64-bit signed integers.</p>
12194<p><b>Note:</b> All non-integer numbers and other data types result in null.</p>
12195<p><b>Note:</b> The query language uses two&#x2019;s complement representation.</p>
12196<p>When looking at the value in binary form, bit 1 is the Least Significant Bit (LSB) and bit 32 is the Most Significant Bit (MSB).</p>
12197<p>(MSB) Bit 32 &#x2192; <tt>0000 0000 0000 0000 0000 0000 0000 0000</tt> &#x2190; Bit 1 (LSB)</p>
12198<div class="section">
12199<h3><a name="bitand"></a>bitand</h3>
12200<ul>
12201
12202<li>
12203
12204<p>Syntax:</p>
12205
12206<div>
12207<div>
12208<pre class="source">BITAND(int_value1, int_value2, ... , int_valueN)
12209</pre></div></div>
12210</li>
12211<li>
12212
12213<p>Returns the result of a bitwise AND operation performed on all input integer values.</p>
12214<p>The bitwise AND operation compares each bit of <tt>int_value1</tt> to the corresponding bit of every other <tt>int_value</tt>. If all bits are 1, then the corresponding result bit is set to 1; otherwise it is set to 0 (zero).</p>
12215</li>
12216<li>
12217
12218<p>Arguments:</p>
12219<ul>
12220
12221<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
12222</ul>
12223</li>
12224<li>
12225
12226<p>Return Value:</p>
12227<ul>
12228
12229<li>An integer, representing the bitwise AND between all of the input integers.</li>
12230</ul>
12231</li>
12232<li>
12233
12234<p>Limitations:</p>
12235<ul>
12236
12237<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12238</ul>
12239</li>
12240<li>
12241
12242<p>Example 1:</p>
12243<p>Compare 3 (0011 in binary) and 6 (0110 in binary).</p>
12244
12245<div>
12246<div>
12247<pre class="source">{ &quot;BitAND&quot;: BITAND(3,6) };
12248</pre></div></div>
12249</li>
12250<li>
12251
12252<p>The expected result is:</p>
12253
12254<div>
12255<div>
12256<pre class="source">{ &quot;BitAND&quot;: 2 }
12257</pre></div></div>
12258
12259<p>This results in 2 (0010 in binary) because only bit 2 is set in both 3 (00<b>1</b>1) and 6 (01<b>1</b>0).</p>
12260</li>
12261<li>
12262
12263<p>Example 2:</p>
12264<p>Compare 4.5 and 3 (0011 in binary).</p>
12265
12266<div>
12267<div>
12268<pre class="source">{ &quot;BitAND&quot;: BITAND(4.5,3) };
12269</pre></div></div>
12270</li>
12271<li>
12272
12273<p>The expected result is:</p>
12274
12275<div>
12276<div>
12277<pre class="source">{ &quot;BitAND&quot;: null }
12278</pre></div></div>
12279
12280<p>The result is null because 4.5 is not an integer.</p>
12281</li>
12282<li>
12283
12284<p>Example 3:</p>
12285<p>Compare 4.0 (0100 in binary) and 3 (0011 in binary).</p>
12286
12287<div>
12288<div>
12289<pre class="source">{ &quot;BitAND&quot;: BITAND(4.0,3) };
12290</pre></div></div>
12291</li>
12292<li>
12293
12294<p>The expected result is:</p>
12295
12296<div>
12297<div>
12298<pre class="source">{ &quot;BitAND&quot;: 0 }
12299</pre></div></div>
12300
12301<p>This results in 0 (zero) because 4.0 (0100) and 3 (0011) do not share any bits that are both 1.</p>
12302</li>
12303<li>
12304
12305<p>Example 4:</p>
12306<p>Compare 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
12307
12308<div>
12309<div>
12310<pre class="source">{ &quot;BitAND&quot;: BITAND(3,6,15) };
12311</pre></div></div>
12312</li>
12313<li>
12314
12315<p>The expected result is:</p>
12316
12317<div>
12318<div>
12319<pre class="source">{ &quot;BitAND&quot;: 2 }
12320</pre></div></div>
12321
12322<p>This results in 2 (0010 in binary) because only the 2nd bit from the right is 1 in all three numbers.</p>
12323</li>
12324</ul></div>
12325<div class="section">
12326<h3><a name="bitclear"></a>bitclear</h3>
12327<ul>
12328
12329<li>
12330
12331<p>Syntax:</p>
12332
12333<div>
12334<div>
12335<pre class="source">BITCLEAR(int_value, positions)
12336</pre></div></div>
12337</li>
12338<li>
12339
12340<p>Returns the result after clearing the specified bit, or array of bits in <tt>int_value</tt> using the given <tt>positions</tt>.</p>
12341<p><b>Note:</b> Specifying a negative or zero bit position makes the function return a null.</p>
12342</li>
12343<li>
12344
12345<p>Arguments:</p>
12346<ul>
12347
12348<li>
12349
12350<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to clear.</p>
12351</li>
12352<li>
12353
12354<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be cleared.</p>
12355</li>
12356</ul>
12357</li>
12358<li>
12359
12360<p>Return Value:</p>
12361<ul>
12362
12363<li>An integer, representing the result after clearing the bit or bits specified.</li>
12364</ul>
12365</li>
12366<li>
12367
12368<p>Limitations:</p>
12369<ul>
12370
12371<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12372</ul>
12373</li>
12374<li>
12375
12376<p>Example 1:</p>
12377<p>Clear bit 1 from 6 (0110 in binary).</p>
12378
12379<div>
12380<div>
12381<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(6,1) };
12382</pre></div></div>
12383</li>
12384<li>
12385
12386<p>The expected result is:</p>
12387
12388<div>
12389<div>
12390<pre class="source">{ &quot;BitCLEAR&quot;: 6 }
12391</pre></div></div>
12392
12393<p>This results in 6 (011<b>0</b> in binary) because bit 1 was already zero.</p>
12394</li>
12395<li>
12396
12397<p>Example 2:</p>
12398<p>Clear bits 1 and 2 from 6 (01<b>10</b> in binary).</p>
12399
12400<div>
12401<div>
12402<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(6,[1,2]) };
12403</pre></div></div>
12404</li>
12405<li>
12406
12407<p>The expected result is:</p>
12408
12409<div>
12410<div>
12411<pre class="source">{ &quot;BitCLEAR&quot;: 4 }
12412</pre></div></div>
12413
12414<p>This results in 4 (01<b>0</b>0 in binary) because bit 2 changed to zero.</p>
12415</li>
12416<li>
12417
12418<p>Example 3:</p>
12419<p>Clear bits 1, 2, 4, and 5 from 31 (0<b>11</b>1<b>11</b> in binary).</p>
12420
12421<div>
12422<div>
12423<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(31,[1,2,4,5]) };
12424</pre></div></div>
12425</li>
12426<li>
12427
12428<p>The expected result is:</p>
12429
12430<div>
12431<div>
12432<pre class="source">{ &quot;BitCLEAR&quot;: 4 }
12433</pre></div></div>
12434
12435<p>This results in 4 (0<b>00</b>1<b>00</b>) because bits 1, 2, 4, and 5 changed to zero.</p>
12436</li>
12437</ul></div>
12438<div class="section">
12439<h3><a name="bitnot"></a>bitnot</h3>
12440<ul>
12441
12442<li>
12443
12444<p>Syntax:</p>
12445
12446<div>
12447<div>
12448<pre class="source">BITNOT(int_value)
12449</pre></div></div>
12450</li>
12451<li>
12452
12453<p>Returns the results of a bitwise logical NOT operation performed on an integer value.</p>
12454<p>The bitwise logical NOT operation reverses the bits in the value. For each value bit that is 1, the corresponding result bit will be set to 0 (zero); and for each value bit that is 0 (zero), the corresponding result bit will be set to 1.</p>
12455<p><b>Note:</b> All bits of the integer will be altered by this operation.</p>
12456</li>
12457<li>
12458
12459<p>Arguments:</p>
12460<ul>
12461
12462<li><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bits to reverse.</li>
12463</ul>
12464</li>
12465<li>
12466
12467<p>Return Value:</p>
12468<ul>
12469
12470<li>An integer, representing the result after performing the logical NOT operation.</li>
12471</ul>
12472</li>
12473<li>
12474
12475<p>Limitations:</p>
12476<ul>
12477
12478<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12479</ul>
12480</li>
12481<li>
12482
12483<p>Example 1:</p>
12484<p>Perform the NOT operation on 3 (0000 0000 0000 0000 0000 0000 0000 0011 in binary).</p>
12485
12486<div>
12487<div>
12488<pre class="source">{ &quot;BitNOT&quot;: BITNOT(3) };
12489</pre></div></div>
12490</li>
12491<li>
12492
12493<p>The expected result is:</p>
12494
12495<div>
12496<div>
12497<pre class="source">{ &quot;BitNOT&quot;: -4 }
12498</pre></div></div>
12499
12500<p>This results in -4 (<b>1111 1111 1111 1111 1111 1111 1111 1100</b> in binary) because all bits changed.</p>
12501</li>
12502</ul></div>
12503<div class="section">
12504<h3><a name="bitor"></a>bitor</h3>
12505<ul>
12506
12507<li>
12508
12509<p>Syntax:</p>
12510
12511<div>
12512<div>
12513<pre class="source">BITOR(int_value1, int_value2, ... , int_valueN)
12514</pre></div></div>
12515</li>
12516<li>
12517
12518<p>Returns the result of a bitwise inclusive OR operation performed on all input integer values.</p>
12519<p>The bitwise inclusive OR operation compares each bit of <tt>int_value1</tt> to the corresponding bit of every other <tt>int_value</tt>. If any bit is 1, the corresponding result bit is set to 1; otherwise, it is set to 0 (zero).</p>
12520</li>
12521<li>
12522
12523<p>Arguments:</p>
12524<ul>
12525
12526<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
12527</ul>
12528</li>
12529<li>
12530
12531<p>Return Value:</p>
12532<ul>
12533
12534<li>An integer, representing the bitwise OR between all of the input integers.</li>
12535</ul>
12536</li>
12537<li>
12538
12539<p>Limitations:</p>
12540<ul>
12541
12542<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12543</ul>
12544</li>
12545<li>
12546
12547<p>Example 1:</p>
12548<p>Perform OR on 3 (0011 in binary) and 6 (0110 in binary).</p>
12549
12550<div>
12551<div>
12552<pre class="source">{ &quot;BitOR&quot;: BITOR(3,6) };
12553</pre></div></div>
12554</li>
12555<li>
12556
12557<p>The expected result is:</p>
12558
12559<div>
12560<div>
12561<pre class="source">{ &quot;BitOR&quot;: 7 }
12562</pre></div></div>
12563
12564<p>This results in 7 (0<b>111</b> in binary) because at least 1 bit of each (00<b>11</b> and 0<b>11</b>0) is 1 in bits 1, 2, and 3.</p>
12565</li>
12566<li>
12567
12568<p>Example 2:</p>
12569<p>Perform OR on 3 (0011 in binary) and -4 (1000 0000 0000 &#x2026; 0000 1100 in binary).</p>
12570
12571<div>
12572<div>
12573<pre class="source">{ &quot;BitOR&quot;: BITOR(3,-4) };
12574</pre></div></div>
12575</li>
12576<li>
12577
12578<p>The expected result is:</p>
12579
12580<div>
12581<div>
12582<pre class="source">{ &quot;BitOR&quot;: -1 }
12583</pre></div></div>
12584
12585<p>This results in -1 (<b>1111 1111 1111 &#x2026; 1111 1111</b> in binary) because the two 1 bits in 3 fill in the two 0 bits in -4 to turn on all the bits.</p>
12586</li>
12587<li>
12588
12589<p>Example 3:</p>
12590<p>Perform OR on 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
12591
12592<div>
12593<div>
12594<pre class="source">{ &quot;BitOR&quot;: BITOR(3,6,15) };
12595</pre></div></div>
12596</li>
12597<li>
12598
12599<p>The expected result is:</p>
12600
12601<div>
12602<div>
12603<pre class="source">{ &quot;BitOR&quot;: 15 }
12604</pre></div></div>
12605
12606<p>This results in 15 (1111 in binary) because there is at least one 1 in each of the four rightmost bits.</p>
12607</li>
12608</ul></div>
12609<div class="section">
12610<h3><a name="bitset"></a>bitset</h3>
12611<ul>
12612
12613<li>
12614
12615<p>Syntax:</p>
12616
12617<div>
12618<div>
12619<pre class="source">BITSET(int_value, positions)
12620</pre></div></div>
12621</li>
12622<li>
12623
12624<p>Returns the result after setting the specified bit <tt>position</tt>, or array of bit positions, to 1 in the given <tt>int_value</tt>.</p>
12625<p><b>Note:</b> Specifying a negative or zero position makes the function return a null.</p>
12626</li>
12627<li>
12628
12629<p>Arguments:</p>
12630<ul>
12631
12632<li>
12633
12634<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to set.</p>
12635</li>
12636<li>
12637
12638<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be set.</p>
12639</li>
12640</ul>
12641</li>
12642<li>
12643
12644<p>Return Value:</p>
12645<ul>
12646
12647<li>An integer, representing the result after setting the bit or bits specified. If the bit is already set, then it stays set.</li>
12648</ul>
12649</li>
12650<li>
12651
12652<p>Limitations:</p>
12653<ul>
12654
12655<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12656</ul>
12657</li>
12658<li>
12659
12660<p>Example 1:</p>
12661<p>Set bit 1 in the value 6 (011<b>0</b> in binary).</p>
12662
12663<div>
12664<div>
12665<pre class="source">{ &quot;BitSET&quot;: BITSET(6,1) };
12666</pre></div></div>
12667</li>
12668<li>
12669
12670<p>The expected result is:</p>
12671
12672<div>
12673<div>
12674<pre class="source">{ &quot;BitSET&quot;: 7 }
12675</pre></div></div>
12676
12677<p>This results in 7 (011<b>1</b> in binary) because bit 1 changed to 1.</p>
12678</li>
12679<li>
12680
12681<p>Example 2:</p>
12682<p>Set bits 1 and 2 in the value 6 (01<b>10</b> in binary).</p>
12683
12684<div>
12685<div>
12686<pre class="source">{ &quot;BitSET&quot;: BITSET(6,[1,2]) };
12687</pre></div></div>
12688</li>
12689<li>
12690
12691<p>The expected result is:</p>
12692
12693<div>
12694<div>
12695<pre class="source">{ &quot;BitSET&quot;: 7 }
12696</pre></div></div>
12697
12698<p>This also results in 7 (01<b>11</b> in binary) because bit 1 changed while bit 2 remained the same.</p>
12699</li>
12700<li>
12701
12702<p>Example 3:</p>
12703<p>Set bits 1 and 4 in the value 6 (<b>0</b>11<b>0</b> in binary).</p>
12704
12705<div>
12706<div>
12707<pre class="source">{ &quot;BitSET&quot;: BITSET(6,[1,4]) };
12708</pre></div></div>
12709</li>
12710<li>
12711
12712<p>The expected result is:</p>
12713
12714<div>
12715<div>
12716<pre class="source">{ &quot;BitSET&quot;: 15 }
12717</pre></div></div>
12718
12719<p>This results in 15 (<b>1</b>11<b>1</b> in binary) because bit 1 and 4 changed to ones.</p>
12720</li>
12721</ul></div>
12722<div class="section">
12723<h3><a name="bitshift"></a>bitshift</h3>
12724<ul>
12725
12726<li>
12727
12728<p>Syntax:</p>
12729
12730<div>
12731<div>
12732<pre class="source">BITSHIFT(int_value, shift_amount[, rotate])
12733</pre></div></div>
12734</li>
12735<li>
12736
12737<p>Returns the result of a bit shift operation performed on the integer value <tt>int_value</tt>. The <tt>shift_amount</tt> supports left and right shifts. These are logical shifts. The third parameter <tt>rotate</tt> supports circular shift. This is similar to the BitROTATE function in Oracle.</p>
12738</li>
12739<li>
12740
12741<p>Arguments:</p>
12742<ul>
12743
12744<li>
12745
12746<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to shift.</p>
12747</li>
12748<li>
12749
12750<p><tt>shift_amount</tt>: An integer, or any valid expression which evaluates to an integer, that contains the number of bits to shift.</p>
12751<ul>
12752
12753<li>
12754
12755<p>A positive (+) number means this is a LEFT shift.</p>
12756</li>
12757<li>
12758
12759<p>A negative (-) number means this is a RIGHT shift.</p>
12760</li>
12761</ul>
12762</li>
12763<li>
12764
12765<p><tt>rotate</tt>: (Optional) A boolean, or any valid expression which evaluates to a boolean, where:</p>
12766<ul>
12767
12768<li>
12769
12770<p>FALSE means this is a LOGICAL shift, where bits shifted off the end of a value are considered lost.</p>
12771</li>
12772<li>
12773
12774<p>TRUE means this is a CIRCULAR shift (shift-and-rotate operation), where bits shifted off the end of a value are rotated back onto the value at the <i>other</i> end. In other words, the bits rotate in what might be thought of as a circular pattern; therefore, these bits are not lost.</p>
12775</li>
12776</ul>
12777<p>If omitted, the default is FALSE.</p>
12778</li>
12779</ul>
12780<p>For comparison, see the below table.</p>
12781<table border="0" class="table table-striped">
12782<thead>
12783
12784<tr class="a">
12785<th> Input </th>
12786<th> Shift </th>
12787<th> Result of Logical Shift (Rotate FALSE) </th>
12788<th> Result of Circular Shift (Rotate TRUE) </th></tr>
12789</thead><tbody>
12790
12791<tr class="b">
12792<td> 6 (0000 0110) </td>
12793<td> 4 </td>
12794<td> 96 (0110 0000) </td>
12795<td> 96 (0110 0000) </td></tr>
12796<tr class="a">
12797<td> 6 (0000 0110) </td>
12798<td> 3 </td>
12799<td> 48 (0011 0000) </td>
12800<td> 48 (0011 0000) </td></tr>
12801<tr class="b">
12802<td> 6 (0000 0110) </td>
12803<td> 2 </td>
12804<td> 24 (0001 1000) </td>
12805<td> 24 (0001 1000) </td></tr>
12806<tr class="a">
12807<td> 6 (0000 0110) </td>
12808<td> 1 </td>
12809<td> 12 (0000 1100) </td>
12810<td> 12 (0000 1100) </td></tr>
12811<tr class="b">
12812<td> <b>6 (0000 0110)</b> </td>
12813<td> <b>0</b> </td>
12814<td> <b>6 (0000 0110)</b> </td>
12815<td> <b>6 (0000 0110)</b> </td></tr>
12816<tr class="a">
12817<td> 6 (0000 0110) </td>
12818<td> -1 </td>
12819<td> 3 (0000 0011) </td>
12820<td> 3 (0000 0011) </td></tr>
12821<tr class="b">
12822<td> 6 (0000 0110) </td>
12823<td> -2 </td>
12824<td> 1 (0000 0001) </td>
12825<td> -9223372036854775807 (1000 0000 &#x2026; 0000 0001) </td></tr>
12826<tr class="a">
12827<td> 6 (0000 0110) </td>
12828<td> -3 </td>
12829<td> 0 (0000 0000) </td>
12830<td> -4611686018427387904 (1100 0000 &#x2026; 0000 0000) </td></tr>
12831<tr class="b">
12832<td> 6 (0000 0110) </td>
12833<td> -4 </td>
12834<td> 0 (0000 0000) </td>
12835<td> 6917529027641081856 (0110 0000 &#x2026; 0000 0000) </td></tr>
12836</tbody>
12837</table>
12838</li>
12839<li>
12840
12841<p>Return Value:</p>
12842<ul>
12843
12844<li>An integer, representing the result of either a logical or circular shift of the given integer.</li>
12845</ul>
12846</li>
12847<li>
12848
12849<p>Limitations:</p>
12850<ul>
12851
12852<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12853</ul>
12854</li>
12855<li>
12856
12857<p>Example 1:</p>
12858<p>Logical left shift of the number 6 (0110 in binary) by one bit.</p>
12859
12860<div>
12861<div>
12862<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,1,FALSE) };
12863</pre></div></div>
12864</li>
12865<li>
12866
12867<p>The expected result is:</p>
12868
12869<div>
12870<div>
12871<pre class="source">{ &quot;BitSHIFT&quot;: 12 }
12872</pre></div></div>
12873
12874<p>This results in 12 (1100 in binary) because the 1-bits moved from positions 2 and 3 to positions 3 and 4.</p>
12875</li>
12876<li>
12877
12878<p>Example 2:</p>
12879<p>Logical right shift of the number 6 (0110 in binary) by two bits.</p>
12880
12881<div>
12882<div>
12883<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,-2) };
12884</pre></div></div>
12885</li>
12886<li>
12887
12888<p>The expected result is:</p>
12889
12890<div>
12891<div>
12892<pre class="source">{ &quot;BitSHIFT&quot;: 1 }
12893</pre></div></div>
12894
12895<p>This results in 1 (0001 in binary) because the 1-bit in position 3 moved to position 1 and the 1-bit in position 2 was dropped.</p>
12896</li>
12897<li>
12898
12899<p>Example 2b:</p>
12900<p>Circular right shift of the number 6 (0110 in binary) by two bits.</p>
12901
12902<div>
12903<div>
12904<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,-2,TRUE) };
12905</pre></div></div>
12906</li>
12907<li>
12908
12909<p>The expected result is:</p>
12910
12911<div>
12912<div>
12913<pre class="source">{ &quot;BitSHIFT&quot;: -9223372036854775807 }
12914</pre></div></div>
12915
12916<p>This results in -9223372036854775807 (1100 0000 0000 0000 0000 0000 0000 0000 in binary) because the two 1-bits wrapped right, around to the Most Significant Digit position and changed the integer&#x2019;s sign to negative.</p>
12917</li>
12918<li>
12919
12920<p>Example 3:</p>
12921<p>Circular left shift of the number 524288 (1000 0000 0000 0000 0000 in binary) by 45 bits.</p>
12922
12923<div>
12924<div>
12925<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(524288,45,TRUE) };
12926</pre></div></div>
12927</li>
12928<li>
12929
12930<p>The expected result is:</p>
12931
12932<div>
12933<div>
12934<pre class="source">{ &quot;BitSHIFT&quot;: 1 }
12935</pre></div></div>
12936
12937<p>This results in 1 because the 1-bit wrapped left, around to the Least Significant Digit position.</p>
12938</li>
12939</ul></div>
12940<div class="section">
12941<h3><a name="bittest"></a>bittest</h3>
12942<ul>
12943
12944<li>
12945
12946<p>Syntax:</p>
12947
12948<div>
12949<div>
12950<pre class="source">BITTEST(int_value, positions [, all_set])
12951</pre></div></div>
12952</li>
12953<li>
12954
12955<p>Returns TRUE if the specified bit, or bits, is a 1; otherwise, returns FALSE if the specified bit, or bits, is a 0 (zero).</p>
12956<p><b>Note:</b> Specifying a negative or zero bit position will result in null being returned.</p>
12957</li>
12958<li>
12959
12960<p>Arguments:</p>
12961<ul>
12962
12963<li>
12964
12965<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to test.</p>
12966</li>
12967<li>
12968
12969<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be tested.</p>
12970</li>
12971<li>
12972
12973<p><tt>all_set</tt>: (Optional) A boolean, or any valid expression which evaluates to a boolean.</p>
12974<ul>
12975
12976<li>
12977
12978<p>When <tt>all_set</tt> is FALSE, then it returns TRUE even if one bit in one of the positions is set.</p>
12979</li>
12980<li>
12981
12982<p>When <tt>all_set</tt> is TRUE, then it returns TRUE only if all input positions are set.</p>
12983</li>
12984</ul>
12985<p>If omitted, the default is FALSE.</p>
12986</li>
12987</ul>
12988</li>
12989<li>
12990
12991<p>Return Value:</p>
12992<ul>
12993
12994<li>A boolean, that follows the below table:
12995<table border="0" class="table table-striped">
12996<thead>
12997
12998<tr class="a">
12999<th> <tt>int_value</tt> </th>
13000<th> <tt>all_set</tt> </th>
13001<th> Return Value </th></tr>
13002</thead><tbody>
13003
13004<tr class="b">
13005<td> <i>all</i> specified bits are TRUE </td>
13006<td> FALSE </td>
13007<td> TRUE </td></tr>
13008<tr class="a">
13009<td> <i>all</i> specified bits are TRUE </td>
13010<td> TRUE </td>
13011<td> TRUE </td></tr>
13012<tr class="b">
13013<td> <i>some</i> specified bits are TRUE </td>
13014<td> FALSE </td>
13015<td> TRUE </td></tr>
13016<tr class="a">
13017<td> <i>some</i> specified bits are TRUE </td>
13018<td> TRUE </td>
13019<td> FALSE </td></tr>
13020</tbody>
13021</table>
13022</li>
13023</ul>
13024</li>
13025<li>
13026
13027<p>Limitations:</p>
13028<ul>
13029
13030<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
13031</ul>
13032</li>
13033<li>
13034
13035<p>Example 1:</p>
13036<p>In the number 6 (0110 in binary), is bit 1 set?</p>
13037
13038<div>
13039<div>
13040<pre class="source">{ &quot;IsBitSET&quot;: ISBITSET(6,1) };
13041</pre></div></div>
13042</li>
13043<li>
13044
13045<p>The expected result is:</p>
13046
13047<div>
13048<div>
13049<pre class="source">{ &quot;IsBitSET&quot;: false }
13050</pre></div></div>
13051
13052<p>This returns FALSE because bit 1 of 6 (011<b>0</b> in binary) is not set to 1.</p>
13053</li>
13054<li>
13055
13056<p>Example 2:</p>
13057<p>In the number 1, is either bit 1 or bit 2 set?</p>
13058
13059<div>
13060<div>
13061<pre class="source">{ &quot;BitTEST&quot;: BITTEST(1,[1,2],FALSE) };
13062</pre></div></div>
13063</li>
13064<li>
13065
13066<p>The expected result is:</p>
13067
13068<div>
13069<div>
13070<pre class="source">{ &quot;BitTEST&quot;: true }
13071</pre></div></div>
13072
13073<p>This returns TRUE because bit 1 of the number 1 (000<b>1</b> in binary) is set to 1.</p>
13074</li>
13075<li>
13076
13077<p>Example 3:</p>
13078<p>In the number 6 (0110 in binary), are both bits 2 and 3 set?</p>
13079
13080<div>
13081<div>
13082<pre class="source">{ &quot;IsBitSET&quot;: ISBITSET(6,[2,3],TRUE) };
13083</pre></div></div>
13084</li>
13085<li>
13086
13087<p>The expected result is:</p>
13088
13089<div>
13090<div>
13091<pre class="source">{ &quot;IsBitSET&quot;: true }
13092</pre></div></div>
13093
13094<p>This returns TRUE because both bits 2 and 3 in the number 6 (0<b>11</b>0 in binary) are set to 1.</p>
13095</li>
13096<li>
13097
13098<p>Example 4:</p>
13099<p>In the number 6 (0110 in binary), are all the bits in positions 1 through 3 set?</p>
13100
13101<div>
13102<div>
13103<pre class="source">{ &quot;BitTEST&quot;: BITTEST(6,[1,3],TRUE) };
13104</pre></div></div>
13105</li>
13106<li>
13107
13108<p>The expected result is:</p>
13109
13110<div>
13111<div>
13112<pre class="source">{ &quot;BitTEST&quot;: false }
13113</pre></div></div>
13114
13115<p>This returns FALSE because bit 1 in the number 6 (011<b>0</b> in binary) is set to 0 (zero).</p>
13116</li>
13117</ul>
13118<p>The function has an alias <tt>isbitset</tt>.</p></div>
13119<div class="section">
13120<h3><a name="bitxor"></a>bitxor</h3>
13121<ul>
13122
13123<li>
13124
13125<p>Syntax:</p>
13126
13127<div>
13128<div>
13129<pre class="source">BITXOR(int_value1, int_value2, ... , int_valueN)
13130</pre></div></div>
13131</li>
13132<li>
13133
13134<p>Returns the result of a bitwise Exclusive OR operation performed on two or more integer values.</p>
13135<p>The bitwise Exclusive OR operation compares each bit of <tt>int_value1</tt> to the corresponding bit of <tt>int_value2</tt>.</p>
13136<p>If there are more than two input values, the first two are compared; then their result is compared to the next input value; and so on.</p>
13137<p>When the compared bits do not match, the result bit is 1; otherwise, the compared bits do match, and the result bit is 0 (zero), as summarized:</p>
13138<table border="0" class="table table-striped">
13139<thead>
13140
13141<tr class="a">
13142<th> Bit 1 </th>
13143<th> Bit 2 </th>
13144<th> XOR Result Bit </th></tr>
13145</thead><tbody>
13146
13147<tr class="b">
13148<td> 0 </td>
13149<td> 0 </td>
13150<td> 0 </td></tr>
13151<tr class="a">
13152<td> 0 </td>
13153<td> 1 </td>
13154<td> 1 </td></tr>
13155<tr class="b">
13156<td> 1 </td>
13157<td> 0 </td>
13158<td> 1 </td></tr>
13159<tr class="a">
13160<td> 1 </td>
13161<td> 1 </td>
13162<td> 0 </td></tr>
13163</tbody>
13164</table>
13165</li>
13166<li>
13167
13168<p>Arguments:</p>
13169<ul>
13170
13171<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
13172</ul>
13173</li>
13174<li>
13175
13176<p>Return Value:</p>
13177<ul>
13178
13179<li>An integer, representing the bitwise XOR between the input integers.</li>
13180</ul>
13181</li>
13182<li>
13183
13184<p>Limitations:</p>
13185<ul>
13186
13187<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
13188</ul>
13189</li>
13190<li>
13191
13192<p>Example 1:</p>
13193<p>Perform the XOR operation on 3 (0011 in binary) and 6 (0110 in binary).</p>
13194
13195<div>
13196<div>
13197<pre class="source">{ &quot;BitXOR&quot;: BITXOR(3,6) };
13198</pre></div></div>
13199</li>
13200<li>
13201
13202<p>The expected result is:</p>
13203
13204<div>
13205<div>
13206<pre class="source">{ &quot;BitXOR&quot;: 5 }
13207</pre></div></div>
13208
13209<p>This returns 5 (0101 in binary) because the 1st bit pair and 3rd bit pair are different (resulting in 1) while the 2nd bit pair and 4th bit pair are the same (resulting in 0):</p>
13210
13211<div>
13212<div>
13213<pre class="source">0011 (3)
132140110 (6)
13215====
132160101 (5)
13217</pre></div></div>
13218</li>
13219<li>
13220
13221<p>Example 2:</p>
13222<p>Perform the XOR operation on 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
13223
13224<div>
13225<div>
13226<pre class="source">{ &quot;BitXOR&quot;: BITXOR(3,6,15) };
13227</pre></div></div>
13228</li>
13229<li>
13230
13231<p>The expected result is:</p>
13232
13233<div>
13234<div>
13235<pre class="source">{ &quot;BitXOR&quot;: 10 }
13236</pre></div></div>
13237
13238<p>This returns 10 (1010 in binary) because 3 XOR 6 equals 5 (0101 in binary), and then 5 XOR 15 equals 10 (1010 in binary).</p>
13239</li>
13240</ul><!--
13241 ! Licensed to the Apache Software Foundation (ASF) under one
13242 ! or more contributor license agreements. See the NOTICE file
13243 ! distributed with this work for additional information
13244 ! regarding copyright ownership. The ASF licenses this file
13245 ! to you under the Apache License, Version 2.0 (the
13246 ! "License"); you may not use this file except in compliance
13247 ! with the License. You may obtain a copy of the License at
13248 !
13249 ! http://www.apache.org/licenses/LICENSE-2.0
13250 !
13251 ! Unless required by applicable law or agreed to in writing,
13252 ! software distributed under the License is distributed on an
13253 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13254 ! KIND, either express or implied. See the License for the
13255 ! specific language governing permissions and limitations
13256 ! under the License.
13257 !-->
13258</div></div>
13259<div class="section">
13260<h2><a name="Window_Functions"></a><a name="WindowFunctions" id="WindowFunctions">Window Functions</a></h2>
13261<p>Window functions are used to compute an aggregate or cumulative value, based on a portion of the tuples selected by a query. For each input tuple, a movable window of tuples is defined. The window determines the tuples to be used by the window function.</p>
13262<p>The tuples are not grouped into a single output tuple &#x2014; each tuple remains separate in the query output.</p>
13263<p>All window functions must be used with an OVER clause. Refer to <a href="manual.html#Over_clauses">Window Queries</a> for details.</p>
13264<p>Window functions cannot appear in the FROM clause clause or LIMIT clause.</p>
13265<div class="section">
13266<h3><a name="cume_dist"></a>cume_dist</h3>
13267<ul>
13268
13269<li>
13270
13271<p>Syntax:</p>
13272
13273<div>
13274<div>
13275<pre class="source">CUME_DIST() OVER ([window-partition-clause] [window-order-clause])
13276</pre></div></div>
13277</li>
13278<li>
13279
13280<p>Returns the percentile rank of the current tuple as part of the cumulative distribution &#x2013; that is, the number of tuples ranked lower than or equal to the current tuple, including the current tuple, divided by the total number of tuples in the window partition.</p>
13281<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the function returns the same result (1.0) for each tuple.</p>
13282</li>
13283<li>
13284
13285<p>Arguments:</p>
13286<ul>
13287
13288<li>None.</li>
13289</ul>
13290</li>
13291<li>
13292
13293<p>Clauses:</p>
13294<ul>
13295
13296<li>
13297
13298<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13299</li>
13300<li>
13301
13302<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13303</li>
13304</ul>
13305</li>
13306<li>
13307
13308<p>Return Value:</p>
13309<ul>
13310
13311<li>A number greater than 0 and less than or equal to 1. The higher the value, the higher the ranking.</li>
13312</ul>
13313</li>
13314<li>
13315
13316<p>Example:</p>
13317<p>For each customer, find the cumulative distribution of all orders by order number.</p>
13318
13319<div>
13320<div>
13321<pre class="source">FROM orders AS o
13322SELECT o.custid, o.orderno, CUME_DIST() OVER (
13323 PARTITION BY o.custid
13324 ORDER BY o.orderno
13325) AS `rank`
13326ORDER BY o.custid, o.orderno;
13327</pre></div></div>
13328</li>
13329<li>
13330
13331<p>The expected result is:</p>
13332
13333<div>
13334<div>
13335<pre class="source">[
13336 {
13337 &quot;rank&quot;: 0.25,
13338 &quot;custid&quot;: &quot;C13&quot;,
13339 &quot;orderno&quot;: 1002
13340 },
13341 {
13342 &quot;rank&quot;: 0.5,
13343 &quot;custid&quot;: &quot;C13&quot;,
13344 &quot;orderno&quot;: 1007
13345 },
13346 {
13347 &quot;rank&quot;: 0.75,
13348 &quot;custid&quot;: &quot;C13&quot;,
13349 &quot;orderno&quot;: 1008
13350 },
13351 {
13352 &quot;rank&quot;: 1,
13353 &quot;custid&quot;: &quot;C13&quot;,
13354 &quot;orderno&quot;: 1009
13355 },
13356 {
13357 &quot;rank&quot;: 1,
13358 &quot;custid&quot;: &quot;C31&quot;,
13359 &quot;orderno&quot;: 1003
13360 },
13361 {
13362 &quot;rank&quot;: 1,
13363 &quot;custid&quot;: &quot;C35&quot;,
13364 &quot;orderno&quot;: 1004
13365 },
13366 {
13367 &quot;rank&quot;: 1,
13368 &quot;custid&quot;: &quot;C37&quot;,
13369 &quot;orderno&quot;: 1005
13370 },
13371 {
13372 &quot;rank&quot;: 0.5,
13373 &quot;custid&quot;: &quot;C41&quot;,
13374 &quot;orderno&quot;: 1001
13375 },
13376 {
13377 &quot;rank&quot;: 1,
13378 &quot;custid&quot;: &quot;C41&quot;,
13379 &quot;orderno&quot;: 1006
13380 }
13381]
13382</pre></div></div>
13383</li>
13384</ul></div>
13385<div class="section">
13386<h3><a name="dense_rank"></a>dense_rank</h3>
13387<ul>
13388
13389<li>
13390
13391<p>Syntax:</p>
13392
13393<div>
13394<div>
13395<pre class="source">DENSE_RANK() OVER ([window-partition-clause] [window-order-clause])
13396</pre></div></div>
13397</li>
13398<li>
13399
13400<p>Returns the dense rank of the current tuple &#x2013; that is, the number of distinct tuples preceding this tuple in the current window partition, plus one.</p>
13401<p>The tuples are ordered by the window order clause. If any tuples are tied, they will have the same rank. If the window order clause is omitted, the function returns the same result (1) for each tuple.</p>
13402<p>For this function, when any tuples have the same rank, the rank of the next tuple will be consecutive, so there will not be a gap in the sequence of returned values. For example, if there are five tuples ranked 3, the next dense rank is 4.</p>
13403</li>
13404<li>
13405
13406<p>Arguments:</p>
13407<ul>
13408
13409<li>None.</li>
13410</ul>
13411</li>
13412<li>
13413
13414<p>Clauses:</p>
13415<ul>
13416
13417<li>
13418
13419<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13420</li>
13421<li>
13422
13423<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13424</li>
13425</ul>
13426</li>
13427<li>
13428
13429<p>Return Value:</p>
13430<ul>
13431
13432<li>An integer, greater than or equal to 1.</li>
13433</ul>
13434</li>
13435<li>
13436
13437<p>Example:</p>
13438<p>Find the dense rank of all orders by number of items.</p>
13439
13440<div>
13441<div>
13442<pre class="source">FROM orders AS o
13443SELECT o.orderno, LEN(o.items) AS items,
13444DENSE_RANK() OVER (
13445 ORDER BY LEN(o.items)
13446) AS `rank`
13447ORDER BY `rank`, o.orderno;
13448</pre></div></div>
13449</li>
13450<li>
13451
13452<p>The expected result is:</p>
13453
13454<div>
13455<div>
13456<pre class="source">[
13457 {
13458 &quot;items&quot;: 0,
13459 &quot;rank&quot;: 1,
13460 &quot;orderno&quot;: 1009
13461 },
13462 {
13463 &quot;items&quot;: 1,
13464 &quot;rank&quot;: 2,
13465 &quot;orderno&quot;: 1008
13466 },
13467 {
13468 &quot;items&quot;: 2,
13469 &quot;rank&quot;: 3,
13470 &quot;orderno&quot;: 1001
13471 },
13472 {
13473 &quot;items&quot;: 2,
13474 &quot;rank&quot;: 3,
13475 &quot;orderno&quot;: 1002
13476 },
13477 {
13478 &quot;items&quot;: 2,
13479 &quot;rank&quot;: 3,
13480 &quot;orderno&quot;: 1003
13481 },
13482 {
13483 &quot;items&quot;: 2,
13484 &quot;rank&quot;: 3,
13485 &quot;orderno&quot;: 1004
13486 },
13487 {
13488 &quot;items&quot;: 2,
13489 &quot;rank&quot;: 3,
13490 &quot;orderno&quot;: 1007
13491 },
13492 {
13493 &quot;items&quot;: 3,
13494 &quot;rank&quot;: 4,
13495 &quot;orderno&quot;: 1006
13496 },
13497 {
13498 &quot;items&quot;: 4,
13499 &quot;rank&quot;: 5,
13500 &quot;orderno&quot;: 1005
13501 }
13502]
13503</pre></div></div>
13504</li>
13505</ul></div>
13506<div class="section">
13507<h3><a name="first_value"></a>first_value</h3>
13508<ul>
13509
13510<li>
13511
13512<p>Syntax:</p>
13513
13514<div>
13515<div>
13516<pre class="source">FIRST_VALUE(expr) [nulls-modifier] OVER (window-definition)
13517</pre></div></div>
13518</li>
13519<li>
13520
13521<p>Returns the requested value from the first tuple in the current window frame, where the window frame is specified by the window definition.</p>
13522</li>
13523<li>
13524
13525<p>Arguments:</p>
13526<ul>
13527
13528<li><tt>expr</tt>: The value that you want to return from the first tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
13529</ul>
13530</li>
13531<li>
13532
13533<p>Modifiers:</p>
13534<ul>
13535
13536<li><a href="manual.html#Window_function_options">NULLS Modifier</a>: (Optional) Determines how NULL or MISSING values are treated when finding the first value in the window frame.
13537<ul>
13538
13539<li>
13540
13541<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the first tuple. In this case, the function returns the first non-NULL, non-MISSING value.</p>
13542</li>
13543<li>
13544
13545<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the first tuple.</p>
13546</li>
13547</ul>
13548<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13549</li>
13550</ul>
13551</li>
13552<li>
13553
13554<p>Clauses:</p>
13555<ul>
13556
13557<li>
13558
13559<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13560</li>
13561<li>
13562
13563<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13564</li>
13565<li>
13566
13567<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
13568</li>
13569</ul>
13570</li>
13571<li>
13572
13573<p>Return Value:</p>
13574<ul>
13575
13576<li>
13577
13578<p>The specified value from the first tuple. The order of the tuples is determined by the window order clause.</p>
13579</li>
13580<li>
13581
13582<p>NULL, if the frame was empty or if all values were NULL or MISSING and the <tt>IGNORE NULLS</tt> modifier was specified.</p>
13583</li>
13584<li>
13585
13586<p>In the following cases, this function may return unpredictable results.</p>
13587<ul>
13588
13589<li>
13590
13591<p>If the window order clause is omitted.</p>
13592</li>
13593<li>
13594
13595<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
13596</li>
13597</ul>
13598</li>
13599<li>
13600
13601<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
13602</li>
13603<li>
13604
13605<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the first value of the input expression.</p>
13606</li>
13607</ul>
13608</li>
13609<li>
13610
13611<p>Example:</p>
13612<p>For each order, show the customer and the value, including the value of the smallest order from that customer.</p>
13613
13614<div>
13615<div>
13616<pre class="source">FROM orders AS o
13617LET revenue = ROUND((
13618 FROM o.items
13619 SELECT VALUE SUM(qty * price)
13620)[0], 2)
13621SELECT o.custid, o.orderno, revenue,
13622FIRST_VALUE(revenue) OVER (
13623 PARTITION BY o.custid
13624 ORDER BY revenue
13625) AS smallest_order;
13626</pre></div></div>
13627</li>
13628<li>
13629
13630<p>The expected result is:</p>
13631
13632<div>
13633<div>
13634<pre class="source">[
13635 {
13636 &quot;custid&quot;: &quot;C13&quot;,
13637 &quot;orderno&quot;: 1009,
13638 &quot;revenue&quot;: null,
13639 &quot;smallest_order&quot;: null
13640 },
13641 {
13642 &quot;custid&quot;: &quot;C13&quot;,
13643 &quot;orderno&quot;: 1007,
13644 &quot;revenue&quot;: 130.45,
13645 &quot;smallest_order&quot;: null
13646 },
13647 {
13648 &quot;custid&quot;: &quot;C13&quot;,
13649 &quot;orderno&quot;: 1008,
13650 &quot;revenue&quot;: 1999.8,
13651 &quot;smallest_order&quot;: null
13652 },
13653 {
13654 &quot;custid&quot;: &quot;C13&quot;,
13655 &quot;orderno&quot;: 1002,
13656 &quot;revenue&quot;: 10906.55,
13657 &quot;smallest_order&quot;: null
13658 },
13659 {
13660 &quot;custid&quot;: &quot;C31&quot;,
13661 &quot;orderno&quot;: 1003,
13662 &quot;revenue&quot;: 477.95,
13663 &quot;smallest_order&quot;: 477.95
13664 },
13665 {
13666 &quot;custid&quot;: &quot;C35&quot;,
13667 &quot;orderno&quot;: 1004,
13668 &quot;revenue&quot;: 199.94,
13669 &quot;smallest_order&quot;: 199.94
13670 },
13671 {
13672 &quot;custid&quot;: &quot;C37&quot;,
13673 &quot;orderno&quot;: 1005,
13674 &quot;revenue&quot;: 4639.92,
13675 &quot;smallest_order&quot;: 4639.92
13676 },
13677 {
13678 &quot;custid&quot;: &quot;C41&quot;,
13679 &quot;orderno&quot;: 1001,
13680 &quot;revenue&quot;: 157.73,
13681 &quot;smallest_order&quot;: 157.73
13682 },
13683 {
13684 &quot;custid&quot;: &quot;C41&quot;,
13685 &quot;orderno&quot;: 1006,
13686 &quot;revenue&quot;: 18847.58,
13687 &quot;smallest_order&quot;: 157.73
13688 }
13689]
13690</pre></div></div>
13691</li>
13692</ul></div>
13693<div class="section">
13694<h3><a name="lag"></a>lag</h3>
13695<ul>
13696
13697<li>
13698
13699<p>Syntax:</p>
13700
13701<div>
13702<div>
13703<pre class="source">LAG(expr[, offset[, default]]) [nulls-modifier] OVER ([window-partition-clause] [window-order-clause])
13704</pre></div></div>
13705</li>
13706<li>
13707
13708<p>Returns the value from a tuple at a given offset prior to the current tuple position.</p>
13709<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
13710</li>
13711<li>
13712
13713<p>Arguments:</p>
13714<ul>
13715
13716<li>
13717
13718<p><tt>expr</tt>: The value that you want to return from the offset tuple. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
13719</li>
13720<li>
13721
13722<p><tt>offset</tt>: (Optional) A positive integer. If omitted, the default is 1.</p>
13723</li>
13724<li>
13725
13726<p><tt>default</tt>: (Optional) The value to return when the offset goes out of partition scope. If omitted, the default is NULL.</p>
13727</li>
13728</ul>
13729</li>
13730<li>
13731
13732<p>Modifiers:</p>
13733<ul>
13734
13735<li><a href="manual.html#Window_function_options">NULLS Modifier</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window partition.
13736<ul>
13737
13738<li>
13739
13740<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
13741</li>
13742<li>
13743
13744<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
13745</li>
13746</ul>
13747<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13748</li>
13749</ul>
13750</li>
13751<li>
13752
13753<p>Clauses:</p>
13754<ul>
13755
13756<li>
13757
13758<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13759</li>
13760<li>
13761
13762<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13763</li>
13764</ul>
13765</li>
13766<li>
13767
13768<p>Return Value:</p>
13769<ul>
13770
13771<li>
13772
13773<p>The specified value from the offset tuple.</p>
13774</li>
13775<li>
13776
13777<p>If the offset tuple is out of partition scope, it returns the default value, or NULL if no default is specified.</p>
13778</li>
13779</ul>
13780</li>
13781<li>
13782
13783<p>Example:</p>
13784<p>For each order, show the customer and the value, including the value of the next-smallest order from that customer.</p>
13785
13786<div>
13787<div>
13788<pre class="source">FROM orders AS o
13789LET revenue = ROUND((
13790 FROM o.items
13791 SELECT VALUE SUM(qty * price)
13792)[0], 2)
13793SELECT o.custid, o.orderno, revenue,
13794LAG(revenue, 1, &quot;No smaller order&quot;) OVER (
13795 PARTITION BY o.custid
13796 ORDER BY revenue
13797) AS next_smallest_order;
13798</pre></div></div>
13799</li>
13800<li>
13801
13802<p>The expected result is:</p>
13803
13804<div>
13805<div>
13806<pre class="source">[
13807 {
13808 &quot;custid&quot;: &quot;C13&quot;,
13809 &quot;orderno&quot;: 1009,
13810 &quot;revenue&quot;: null,
13811 &quot;next_smallest_order&quot;: &quot;No smaller order&quot;
13812 },
13813 {
13814 &quot;custid&quot;: &quot;C13&quot;,
13815 &quot;orderno&quot;: 1007,
13816 &quot;revenue&quot;: 130.45,
13817 &quot;next_smallest_order&quot;: null
13818 },
13819 {
13820 &quot;custid&quot;: &quot;C13&quot;,
13821 &quot;orderno&quot;: 1008,
13822 &quot;revenue&quot;: 1999.8,
13823 &quot;next_smallest_order&quot;: 130.45
13824 },
13825 {
13826 &quot;custid&quot;: &quot;C13&quot;,
13827 &quot;orderno&quot;: 1002,
13828 &quot;revenue&quot;: 10906.55,
13829 &quot;next_smallest_order&quot;: 1999.8
13830 },
13831 {
13832 &quot;custid&quot;: &quot;C31&quot;,
13833 &quot;orderno&quot;: 1003,
13834 &quot;revenue&quot;: 477.95,
13835 &quot;next_smallest_order&quot;: &quot;No smaller order&quot;
13836 },
13837 {
13838 &quot;custid&quot;: &quot;C35&quot;,
13839 &quot;orderno&quot;: 1004,
13840 &quot;revenue&quot;: 199.94,
13841 &quot;next_smallest_order&quot;: &quot;No smaller order&quot;
13842 },
13843 {
13844 &quot;custid&quot;: &quot;C37&quot;,
13845 &quot;orderno&quot;: 1005,
13846 &quot;revenue&quot;: 4639.92,
13847 &quot;next_smallest_order&quot;: &quot;No smaller order&quot;
13848 },
13849 {
13850 &quot;custid&quot;: &quot;C41&quot;,
13851 &quot;orderno&quot;: 1001,
13852 &quot;revenue&quot;: 157.73,
13853 &quot;next_smallest_order&quot;: &quot;No smaller order&quot;
13854 },
13855 {
13856 &quot;custid&quot;: &quot;C41&quot;,
13857 &quot;orderno&quot;: 1006,
13858 &quot;revenue&quot;: 18847.58,
13859 &quot;next_smallest_order&quot;: 157.73
13860 }
13861]
13862</pre></div></div>
13863</li>
13864</ul></div>
13865<div class="section">
13866<h3><a name="last_value"></a>last_value</h3>
13867<ul>
13868
13869<li>
13870
13871<p>Syntax:</p>
13872
13873<div>
13874<div>
13875<pre class="source">LAST_VALUE(expr) [nulls-modifier] OVER (window-definition)
13876</pre></div></div>
13877</li>
13878<li>
13879
13880<p>Returns the requested value from the last tuple in the current window frame, where the window frame is specified by the window definition.</p>
13881</li>
13882<li>
13883
13884<p>Arguments:</p>
13885<ul>
13886
13887<li><tt>expr</tt>: The value that you want to return from the last tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
13888</ul>
13889</li>
13890<li>
13891
13892<p>Modifiers:</p>
13893<ul>
13894
13895<li><a href="manual.html#Window_function_options">NULLS Modifier</a>: (Optional) Determines how NULL or MISSING values are treated when finding the last tuple in the window frame.
13896<ul>
13897
13898<li>
13899
13900<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the last tuple. In this case, the function returns the last non-NULL, non-MISSING value.</p>
13901</li>
13902<li>
13903
13904<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the last tuple.</p>
13905</li>
13906</ul>
13907<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13908</li>
13909</ul>
13910</li>
13911<li>
13912
13913<p>Clauses:</p>
13914<ul>
13915
13916<li>
13917
13918<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13919</li>
13920<li>
13921
13922<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13923</li>
13924<li>
13925
13926<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
13927</li>
13928</ul>
13929</li>
13930<li>
13931
13932<p>Return Value:</p>
13933<ul>
13934
13935<li>
13936
13937<p>The specified value from the last tuple. The order of the tuples is determined by the window order clause.</p>
13938</li>
13939<li>
13940
13941<p>NULL, if the frame was empty or if all values were NULL or MISSING and the <tt>IGNORE NULLS</tt> modifier was specified.</p>
13942</li>
13943<li>
13944
13945<p>In the following cases, this function may return unpredictable results.</p>
13946<ul>
13947
13948<li>
13949
13950<p>If the window order clause is omitted.</p>
13951</li>
13952<li>
13953
13954<p>If the window frame clause is omitted.</p>
13955</li>
13956<li>
13957
13958<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
13959</li>
13960</ul>
13961</li>
13962<li>
13963
13964<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
13965</li>
13966<li>
13967
13968<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the last value of the input expression.</p>
13969</li>
13970</ul>
13971</li>
13972<li>
13973
13974<p>Example:</p>
13975<p>For each order, show the customer and the value, including the value of the largest order from that customer.</p>
13976
13977<div>
13978<div>
13979<pre class="source">FROM orders AS o
13980LET revenue = ROUND((
13981 FROM o.items
13982 SELECT VALUE SUM(qty * price)
13983)[0], 2)
13984SELECT o.custid, o.orderno, revenue,
13985LAST_VALUE(revenue) OVER (
13986 PARTITION BY o.custid
13987 ORDER BY revenue
13988 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
13989) AS largest_order;
13990</pre></div></div>
13991</li>
13992<li>
13993
13994<p>The expected result is:</p>
13995
13996<div>
13997<div>
13998<pre class="source">[
13999 {
14000 &quot;custid&quot;: &quot;C13&quot;,
14001 &quot;orderno&quot;: 1009,
14002 &quot;revenue&quot;: null,
14003 &quot;largest_order&quot;: 10906.55
14004 },
14005 {
14006 &quot;custid&quot;: &quot;C13&quot;,
14007 &quot;orderno&quot;: 1007,
14008 &quot;revenue&quot;: 130.45,
14009 &quot;largest_order&quot;: 10906.55
14010 },
14011 {
14012 &quot;custid&quot;: &quot;C13&quot;,
14013 &quot;orderno&quot;: 1008,
14014 &quot;revenue&quot;: 1999.8,
14015 &quot;largest_order&quot;: 10906.55
14016 },
14017 {
14018 &quot;custid&quot;: &quot;C13&quot;,
14019 &quot;orderno&quot;: 1002,
14020 &quot;revenue&quot;: 10906.55,
14021 &quot;largest_order&quot;: 10906.55
14022 },
14023 {
14024 &quot;custid&quot;: &quot;C31&quot;,
14025 &quot;orderno&quot;: 1003,
14026 &quot;revenue&quot;: 477.95,
14027 &quot;largest_order&quot;: 477.95
14028 },
14029 {
14030 &quot;custid&quot;: &quot;C35&quot;,
14031 &quot;orderno&quot;: 1004,
14032 &quot;revenue&quot;: 199.94,
14033 &quot;largest_order&quot;: 199.94
14034 },
14035 {
14036 &quot;custid&quot;: &quot;C37&quot;,
14037 &quot;orderno&quot;: 1005,
14038 &quot;revenue&quot;: 4639.92,
14039 &quot;largest_order&quot;: 4639.92
14040 },
14041 {
14042 &quot;custid&quot;: &quot;C41&quot;,
14043 &quot;orderno&quot;: 1001,
14044 &quot;revenue&quot;: 157.73,
14045 &quot;largest_order&quot;: 18847.58
14046 },
14047 {
14048 &quot;custid&quot;: &quot;C41&quot;,
14049 &quot;orderno&quot;: 1006,
14050 &quot;revenue&quot;: 18847.58,
14051 &quot;largest_order&quot;: 18847.58
14052 }
14053]
14054</pre></div></div>
14055
14056<p>&#x2780; This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean that the largest order would always be the same as the current order.</p>
14057</li>
14058</ul></div>
14059<div class="section">
14060<h3><a name="lead"></a>lead</h3>
14061<ul>
14062
14063<li>
14064
14065<p>Syntax:</p>
14066
14067<div>
14068<div>
14069<pre class="source">LEAD(expr[, offset[, default]]) [nulls-modifier] OVER ([window-partition-clause] [window-order-clause])
14070</pre></div></div>
14071</li>
14072<li>
14073
14074<p>Returns the value from a tuple at a given offset ahead of the current tuple position.</p>
14075<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
14076</li>
14077<li>
14078
14079<p>Arguments:</p>
14080<ul>
14081
14082<li>
14083
14084<p><tt>expr</tt>: The value that you want to return from the offset tuple. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
14085</li>
14086<li>
14087
14088<p><tt>offset</tt>: (Optional) A positive integer. If omitted, the default is 1.</p>
14089</li>
14090<li>
14091
14092<p><tt>default</tt>: (Optional) The value to return when the offset goes out of window partition scope. If omitted, the default is NULL.</p>
14093</li>
14094</ul>
14095</li>
14096<li>
14097
14098<p>Modifiers:</p>
14099<ul>
14100
14101<li><a href="manual.html#Window_function_options">NULLS Modifier</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window partition.
14102<ul>
14103
14104<li>
14105
14106<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
14107</li>
14108<li>
14109
14110<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
14111</li>
14112</ul>
14113<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
14114</li>
14115</ul>
14116</li>
14117<li>
14118
14119<p>Clauses:</p>
14120<ul>
14121
14122<li>
14123
14124<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14125</li>
14126<li>
14127
14128<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14129</li>
14130</ul>
14131</li>
14132<li>
14133
14134<p>Return Value:</p>
14135<ul>
14136
14137<li>
14138
14139<p>The specified value from the offset tuple.</p>
14140</li>
14141<li>
14142
14143<p>If the offset tuple is out of partition scope, it returns the default value, or NULL if no default is specified.</p>
14144</li>
14145</ul>
14146</li>
14147<li>
14148
14149<p>Example:</p>
14150<p>For each order, show the customer and the value, including the value of the next-largest order from that customer.</p>
14151
14152<div>
14153<div>
14154<pre class="source">FROM orders AS o
14155LET revenue = ROUND((
14156 FROM o.items
14157 SELECT VALUE SUM(qty * price)
14158)[0], 2)
14159SELECT o.custid, o.orderno, revenue,
14160LEAD(revenue, 1, &quot;No larger order&quot;) OVER (
14161 PARTITION BY o.custid
14162 ORDER BY revenue
14163) AS next_largest_order;
14164</pre></div></div>
14165</li>
14166<li>
14167
14168<p>The expected result is:</p>
14169
14170<div>
14171<div>
14172<pre class="source">[
14173 {
14174 &quot;custid&quot;: &quot;C13&quot;,
14175 &quot;orderno&quot;: 1009,
14176 &quot;revenue&quot;: null,
14177 &quot;next_largest_order&quot;: 130.45
14178 },
14179 {
14180 &quot;custid&quot;: &quot;C13&quot;,
14181 &quot;orderno&quot;: 1007,
14182 &quot;revenue&quot;: 130.45,
14183 &quot;next_largest_order&quot;: 1999.8
14184 },
14185 {
14186 &quot;custid&quot;: &quot;C13&quot;,
14187 &quot;orderno&quot;: 1008,
14188 &quot;revenue&quot;: 1999.8,
14189 &quot;next_largest_order&quot;: 10906.55
14190 },
14191 {
14192 &quot;custid&quot;: &quot;C13&quot;,
14193 &quot;orderno&quot;: 1002,
14194 &quot;revenue&quot;: 10906.55,
14195 &quot;next_largest_order&quot;: &quot;No larger order&quot;
14196 },
14197 {
14198 &quot;custid&quot;: &quot;C31&quot;,
14199 &quot;orderno&quot;: 1003,
14200 &quot;revenue&quot;: 477.95,
14201 &quot;next_largest_order&quot;: &quot;No larger order&quot;
14202 },
14203 {
14204 &quot;custid&quot;: &quot;C35&quot;,
14205 &quot;orderno&quot;: 1004,
14206 &quot;revenue&quot;: 199.94,
14207 &quot;next_largest_order&quot;: &quot;No larger order&quot;
14208 },
14209 {
14210 &quot;custid&quot;: &quot;C37&quot;,
14211 &quot;orderno&quot;: 1005,
14212 &quot;revenue&quot;: 4639.92,
14213 &quot;next_largest_order&quot;: &quot;No larger order&quot;
14214 },
14215 {
14216 &quot;custid&quot;: &quot;C41&quot;,
14217 &quot;orderno&quot;: 1001,
14218 &quot;revenue&quot;: 157.73,
14219 &quot;next_largest_order&quot;: 18847.58
14220 },
14221 {
14222 &quot;custid&quot;: &quot;C41&quot;,
14223 &quot;orderno&quot;: 1006,
14224 &quot;revenue&quot;: 18847.58,
14225 &quot;next_largest_order&quot;: &quot;No larger order&quot;
14226 }
14227]
14228</pre></div></div>
14229</li>
14230</ul></div>
14231<div class="section">
14232<h3><a name="nth_value"></a>nth_value</h3>
14233<ul>
14234
14235<li>
14236
14237<p>Syntax:</p>
14238
14239<div>
14240<div>
14241<pre class="source">NTH_VALUE(expr, offset) [from-modifier] [nulls-modifier] OVER (window-definition)
14242</pre></div></div>
14243</li>
14244<li>
14245
14246<p>Returns the requested value from a tuple in the current window frame, where the window frame is specified by the window definition.</p>
14247</li>
14248<li>
14249
14250<p>Arguments:</p>
14251<ul>
14252
14253<li>
14254
14255<p><tt>expr</tt>: The value that you want to return from the offset tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
14256</li>
14257<li>
14258
14259<p><tt>offset</tt>: The number of the offset tuple within the window frame, counting from 1.</p>
14260</li>
14261</ul>
14262</li>
14263<li>
14264
14265<p>Modifiers:</p>
14266<ul>
14267
14268<li>
14269
14270<p><a href="manual.html#Window_function_options">FROM Modifier</a>: (Optional) Determines where the function starts counting the offset.</p>
14271<ul>
14272
14273<li>
14274
14275<p><tt>FROM FIRST</tt>: Counting starts at the first tuple in the window frame. In this case, an offset of 1 is the first tuple in the window frame, 2 is the second tuple, and so on.</p>
14276</li>
14277<li>
14278
14279<p><tt>FROM LAST</tt>: Counting starts at the last tuple in the window frame. In this case, an offset of 1 is the last tuple in the window frame, 2 is the second-to-last tuple, and so on.</p>
14280</li>
14281</ul>
14282<p>The order of the tuples is determined by the window order clause. If this modifier is omitted, the default is <tt>FROM FIRST</tt>.</p>
14283</li>
14284<li>
14285
14286<p><a href="manual.html#Window_function_options">NULLS Modifier</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window frame.</p>
14287<ul>
14288
14289<li>
14290
14291<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
14292</li>
14293<li>
14294
14295<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
14296</li>
14297</ul>
14298<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
14299</li>
14300</ul>
14301</li>
14302<li>
14303
14304<p>Clauses:</p>
14305<ul>
14306
14307<li>
14308
14309<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14310</li>
14311<li>
14312
14313<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14314</li>
14315<li>
14316
14317<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
14318</li>
14319</ul>
14320</li>
14321<li>
14322
14323<p>Return Value:</p>
14324<ul>
14325
14326<li>
14327
14328<p>The specified value from the offset tuple.</p>
14329</li>
14330<li>
14331
14332<p>In the following cases, this function may return unpredictable results.</p>
14333<ul>
14334
14335<li>
14336
14337<p>If the window order clause is omitted.</p>
14338</li>
14339<li>
14340
14341<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
14342</li>
14343</ul>
14344</li>
14345<li>
14346
14347<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
14348</li>
14349<li>
14350
14351<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the first value of the input expression when counting <tt>FROM FIRST</tt>, or the last value of the input expression when counting <tt>FROM LAST</tt>.</p>
14352</li>
14353</ul>
14354</li>
14355<li>
14356
14357<p>Example 1:</p>
14358<p>For each order, show the customer and the value, including the value of the second smallest order from that customer.</p>
14359
14360<div>
14361<div>
14362<pre class="source">FROM orders AS o
14363LET revenue = ROUND((
14364 FROM o.items
14365 SELECT VALUE SUM(qty * price)
14366)[0], 2)
14367SELECT o.custid, o.orderno, revenue,
14368NTH_VALUE(revenue, 2) FROM FIRST OVER (
14369 PARTITION BY o.custid
14370 ORDER BY revenue
14371 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
14372) AS smallest_order_but_1;
14373</pre></div></div>
14374</li>
14375<li>
14376
14377<p>The expected result is:</p>
14378
14379<div>
14380<div>
14381<pre class="source">[
14382 {
14383 &quot;custid&quot;: &quot;C13&quot;,
14384 &quot;orderno&quot;: 1009,
14385 &quot;revenue&quot;: null,
14386 &quot;smallest_order_but_1&quot;: 130.45
14387 },
14388 {
14389 &quot;custid&quot;: &quot;C13&quot;,
14390 &quot;orderno&quot;: 1007,
14391 &quot;revenue&quot;: 130.45, // &#x278b;
14392 &quot;smallest_order_but_1&quot;: 130.45
14393 },
14394 {
14395 &quot;custid&quot;: &quot;C13&quot;,
14396 &quot;orderno&quot;: 1008,
14397 &quot;revenue&quot;: 1999.8,
14398 &quot;smallest_order_but_1&quot;: 130.45
14399 },
14400 {
14401 &quot;custid&quot;: &quot;C13&quot;,
14402 &quot;orderno&quot;: 1002,
14403 &quot;revenue&quot;: 10906.55,
14404 &quot;smallest_order_but_1&quot;: 130.45
14405 },
14406 {
14407 &quot;custid&quot;: &quot;C31&quot;,
14408 &quot;orderno&quot;: 1003,
14409 &quot;revenue&quot;: 477.95,
14410 &quot;smallest_order_but_1&quot;: null
14411 },
14412 {
14413 &quot;custid&quot;: &quot;C35&quot;,
14414 &quot;orderno&quot;: 1004,
14415 &quot;revenue&quot;: 199.94,
14416 &quot;smallest_order_but_1&quot;: null
14417 },
14418 {
14419 &quot;custid&quot;: &quot;C37&quot;,
14420 &quot;orderno&quot;: 1005,
14421 &quot;revenue&quot;: 4639.92,
14422 &quot;smallest_order_but_1&quot;: null
14423 },
14424 {
14425 &quot;custid&quot;: &quot;C41&quot;,
14426 &quot;orderno&quot;: 1001,
14427 &quot;revenue&quot;: 157.73,
14428 &quot;smallest_order_but_1&quot;: 18847.58
14429 },
14430 {
14431 &quot;custid&quot;: &quot;C41&quot;,
14432 &quot;orderno&quot;: 1006,
14433 &quot;revenue&quot;: 18847.58, // &#x278b;
14434 &quot;smallest_order_but_1&quot;: 18847.58
14435 }
14436]
14437</pre></div></div>
14438
14439<p>&#x2780; This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean that for the smallest order, the function would be unable to find the route with the second smallest order.</p>
14440<p>&#x2781; The second smallest order from this customer.</p>
14441</li>
14442<li>
14443
14444<p>Example 2:</p>
14445<p>For each order, show the customer and the value, including the value of the second largest order from that customer.</p>
14446
14447<div>
14448<div>
14449<pre class="source">FROM orders AS o
14450LET revenue = ROUND((
14451 FROM o.items
14452 SELECT VALUE SUM(qty * price)
14453)[0], 2)
14454SELECT o.custid, o.orderno, revenue,
14455NTH_VALUE(revenue, 2) FROM LAST OVER (
14456 PARTITION BY o.custid
14457 ORDER BY revenue
14458 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
14459) AS largest_order_but_1;
14460</pre></div></div>
14461</li>
14462<li>
14463
14464<p>The expected result is:</p>
14465
14466<div>
14467<div>
14468<pre class="source">[
14469 {
14470 &quot;custid&quot;: &quot;C13&quot;,
14471 &quot;orderno&quot;: 1002,
14472 &quot;revenue&quot;: 10906.55,
14473 &quot;largest_order_but_1&quot;: 1999.8
14474 },
14475 {
14476 &quot;custid&quot;: &quot;C13&quot;,
14477 &quot;orderno&quot;: 1008,
14478 &quot;revenue&quot;: 1999.8, // &#x278b;
14479 &quot;largest_order_but_1&quot;: 1999.8
14480 },
14481 {
14482 &quot;custid&quot;: &quot;C13&quot;,
14483 &quot;orderno&quot;: 1007,
14484 &quot;revenue&quot;: 130.45,
14485 &quot;largest_order_but_1&quot;: 1999.8
14486 },
14487 {
14488 &quot;custid&quot;: &quot;C13&quot;,
14489 &quot;orderno&quot;: 1009,
14490 &quot;revenue&quot;: null,
14491 &quot;largest_order_but_1&quot;: 1999.8
14492 },
14493 {
14494 &quot;custid&quot;: &quot;C31&quot;,
14495 &quot;orderno&quot;: 1003,
14496 &quot;revenue&quot;: 477.95,
14497 &quot;largest_order_but_1&quot;: null
14498 },
14499 {
14500 &quot;custid&quot;: &quot;C35&quot;,
14501 &quot;orderno&quot;: 1004,
14502 &quot;revenue&quot;: 199.94,
14503 &quot;largest_order_but_1&quot;: null
14504 },
14505 {
14506 &quot;custid&quot;: &quot;C37&quot;,
14507 &quot;orderno&quot;: 1005,
14508 &quot;revenue&quot;: 4639.92,
14509 &quot;largest_order_but_1&quot;: null
14510 },
14511 {
14512 &quot;custid&quot;: &quot;C41&quot;,
14513 &quot;orderno&quot;: 1006,
14514 &quot;revenue&quot;: 18847.58,
14515 &quot;largest_order_but_1&quot;: 157.73
14516 },
14517 {
14518 &quot;custid&quot;: &quot;C41&quot;,
14519 &quot;orderno&quot;: 1001,
14520 &quot;revenue&quot;: 157.73, // &#x278b;
14521 &quot;largest_order_but_1&quot;: 157.73
14522 }
14523]
14524</pre></div></div>
14525
14526<p>&#x2780; This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean the function would be unable to find the second largest order for smaller orders.</p>
14527<p>&#x2781; The second largest order from this customer.</p>
14528</li>
14529</ul></div>
14530<div class="section">
14531<h3><a name="ntile"></a>ntile</h3>
14532<ul>
14533
14534<li>
14535
14536<p>Syntax:</p>
14537
14538<div>
14539<div>
14540<pre class="source">NTILE(num_tiles) OVER ([window-partition-clause] [window-order-clause])
14541</pre></div></div>
14542</li>
14543<li>
14544
14545<p>Divides the window partition into the specified number of tiles, and allocates each tuple in the window partition to a tile, so that as far as possible each tile has an equal number of tuples. When the set of tuples is not equally divisible by the number of tiles, the function puts more tuples into the lower-numbered tiles. For each tuple, the function returns the number of the tile into which that tuple was placed.</p>
14546<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted then the tuples are processed in an undefined order.</p>
14547</li>
14548<li>
14549
14550<p>Arguments:</p>
14551<ul>
14552
14553<li><tt>num_tiles</tt>: The number of tiles into which you want to divide the window partition. This argument can be an expression and must evaluate to a number. If the number is not an integer, it will be truncated.</li>
14554</ul>
14555</li>
14556<li>
14557
14558<p>Clauses:</p>
14559<ul>
14560
14561<li>
14562
14563<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14564</li>
14565<li>
14566
14567<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14568</li>
14569</ul>
14570</li>
14571<li>
14572
14573<p>Return Value:</p>
14574<ul>
14575
14576<li>An value greater than or equal to 1 and less than or equal to the number of tiles.</li>
14577</ul>
14578</li>
14579<li>
14580
14581<p>Example:</p>
14582<p>Allocate each order to one of three tiles by value.</p>
14583
14584<div>
14585<div>
14586<pre class="source">FROM orders AS o
14587LET revenue = ROUND((
14588 FROM o.items
14589 SELECT VALUE SUM(qty * price)
14590)[0], 2)
14591SELECT o.orderno, revenue,
14592NTILE(3) OVER (
14593 ORDER BY revenue
14594) AS `ntile`;
14595</pre></div></div>
14596</li>
14597<li>
14598
14599<p>The expected result is:</p>
14600
14601<div>
14602<div>
14603<pre class="source">[
14604 {
14605 &quot;ntile&quot;: 1,
14606 &quot;orderno&quot;: 1009,
14607 &quot;revenue&quot;: null
14608 },
14609 {
14610 &quot;ntile&quot;: 1,
14611 &quot;orderno&quot;: 1007,
14612 &quot;revenue&quot;: 130.45
14613 },
14614 {
14615 &quot;ntile&quot;: 1,
14616 &quot;orderno&quot;: 1001,
14617 &quot;revenue&quot;: 157.73
14618 },
14619 {
14620 &quot;ntile&quot;: 2,
14621 &quot;orderno&quot;: 1004,
14622 &quot;revenue&quot;: 199.94
14623 },
14624 {
14625 &quot;ntile&quot;: 2,
14626 &quot;orderno&quot;: 1003,
14627 &quot;revenue&quot;: 477.95
14628 },
14629 {
14630 &quot;ntile&quot;: 2,
14631 &quot;orderno&quot;: 1008,
14632 &quot;revenue&quot;: 1999.8
14633 },
14634 {
14635 &quot;ntile&quot;: 3,
14636 &quot;orderno&quot;: 1005,
14637 &quot;revenue&quot;: 4639.92
14638 },
14639 {
14640 &quot;ntile&quot;: 3,
14641 &quot;orderno&quot;: 1002,
14642 &quot;revenue&quot;: 10906.55
14643 },
14644 {
14645 &quot;ntile&quot;: 3,
14646 &quot;orderno&quot;: 1006,
14647 &quot;revenue&quot;: 18847.58
14648 }
14649]
14650</pre></div></div>
14651</li>
14652</ul></div>
14653<div class="section">
14654<h3><a name="percent_rank"></a>percent_rank</h3>
14655<ul>
14656
14657<li>
14658
14659<p>Syntax:</p>
14660
14661<div>
14662<div>
14663<pre class="source">PERCENT_RANK() OVER ([window-partition-clause] [window-order-clause])
14664</pre></div></div>
14665</li>
14666<li>
14667
14668<p>Returns the percentile rank of the current tuple &#x2013; that is, the rank of the tuples minus one, divided by the total number of tuples in the window partition minus one.</p>
14669<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the function returns the same result (0) for each tuple.</p>
14670</li>
14671<li>
14672
14673<p>Arguments:</p>
14674<ul>
14675
14676<li>None.</li>
14677</ul>
14678</li>
14679<li>
14680
14681<p>Clauses:</p>
14682<ul>
14683
14684<li>
14685
14686<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14687</li>
14688<li>
14689
14690<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14691</li>
14692</ul>
14693</li>
14694<li>
14695
14696<p>Return Value:</p>
14697<ul>
14698
14699<li>A number between 0 and 1. The higher the value, the higher the ranking.</li>
14700</ul>
14701</li>
14702<li>
14703
14704<p>Example:</p>
14705<p>For each customer, find the percentile rank of all orders by order number.</p>
14706
14707<div>
14708<div>
14709<pre class="source">FROM orders AS o
14710SELECT o.custid, o.orderno, PERCENT_RANK() OVER (
14711 PARTITION BY o.custid
14712 ORDER BY o.orderno
14713) AS `rank`;
14714</pre></div></div>
14715</li>
14716<li>
14717
14718<p>The expected result is:</p>
14719
14720<div>
14721<div>
14722<pre class="source">[
14723 {
14724 &quot;rank&quot;: 0,
14725 &quot;custid&quot;: &quot;C13&quot;,
14726 &quot;orderno&quot;: 1002
14727 },
14728 {
14729 &quot;rank&quot;: 0.3333333333333333,
14730 &quot;custid&quot;: &quot;C13&quot;,
14731 &quot;orderno&quot;: 1007
14732 },
14733 {
14734 &quot;rank&quot;: 0.6666666666666666,
14735 &quot;custid&quot;: &quot;C13&quot;,
14736 &quot;orderno&quot;: 1008
14737 },
14738 {
14739 &quot;rank&quot;: 1,
14740 &quot;custid&quot;: &quot;C13&quot;,
14741 &quot;orderno&quot;: 1009
14742 },
14743 {
14744 &quot;rank&quot;: 0,
14745 &quot;custid&quot;: &quot;C31&quot;,
14746 &quot;orderno&quot;: 1003
14747 },
14748 {
14749 &quot;rank&quot;: 0,
14750 &quot;custid&quot;: &quot;C35&quot;,
14751 &quot;orderno&quot;: 1004
14752 },
14753 {
14754 &quot;rank&quot;: 0,
14755 &quot;custid&quot;: &quot;C37&quot;,
14756 &quot;orderno&quot;: 1005
14757 },
14758 {
14759 &quot;rank&quot;: 0,
14760 &quot;custid&quot;: &quot;C41&quot;,
14761 &quot;orderno&quot;: 1001
14762 },
14763 {
14764 &quot;rank&quot;: 1,
14765 &quot;custid&quot;: &quot;C41&quot;,
14766 &quot;orderno&quot;: 1006
14767 }
14768]
14769</pre></div></div>
14770</li>
14771</ul></div>
14772<div class="section">
14773<h3><a name="rank"></a>rank</h3>
14774<ul>
14775
14776<li>
14777
14778<p>Syntax:</p>
14779
14780<div>
14781<div>
14782<pre class="source">RANK() OVER ([window-partition-clause] [window-order-clause])
14783</pre></div></div>
14784</li>
14785<li>
14786
14787<p>Returns the rank of the current tuple &#x2013; that is, the number of distinct tuples preceding this tuple in the current window partition, plus one.</p>
14788<p>The tuples are ordered by the window order clause. If any tuples are tied, they will have the same rank. If the window order clause is omitted, the function returns the same result (1) for each tuple.</p>
14789<p>When any tuples have the same rank, the rank of the next tuple will include all preceding tuples, so there may be a gap in the sequence of returned values. For example, if there are five tuples ranked 3, the next rank is 8.</p>
14790<p>To avoid gaps in the returned values, use the DENSE_RANK() function instead.</p>
14791</li>
14792<li>
14793
14794<p>Arguments:</p>
14795<ul>
14796
14797<li>None.</li>
14798</ul>
14799</li>
14800<li>
14801
14802<p>Clauses:</p>
14803<ul>
14804
14805<li>
14806
14807<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14808</li>
14809<li>
14810
14811<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14812</li>
14813</ul>
14814</li>
14815<li>
14816
14817<p>Return Value:</p>
14818<ul>
14819
14820<li>An integer, greater than or equal to 1.</li>
14821</ul>
14822</li>
14823<li>
14824
14825<p>Example:</p>
14826<p>Find the rank of all orders by number of items.</p>
14827
14828<div>
14829<div>
14830<pre class="source">FROM orders AS o
14831SELECT o.orderno, LEN(o.items) AS items,
14832RANK() OVER (
14833 ORDER BY LEN(o.items)
14834) AS `rank`;
14835</pre></div></div>
14836</li>
14837<li>
14838
14839<p>The expected result is:</p>
14840
14841<div>
14842<div>
14843<pre class="source">[
14844 {
14845 &quot;items&quot;: 0,
14846 &quot;rank&quot;: 1,
14847 &quot;orderno&quot;: 1009
14848 },
14849 {
14850 &quot;items&quot;: 1,
14851 &quot;rank&quot;: 2,
14852 &quot;orderno&quot;: 1008
14853 },
14854 {
14855 &quot;items&quot;: 2,
14856 &quot;rank&quot;: 3,
14857 &quot;orderno&quot;: 1004
14858 },
14859 {
14860 &quot;items&quot;: 2,
14861 &quot;rank&quot;: 3,
14862 &quot;orderno&quot;: 1007
14863 },
14864 {
14865 &quot;items&quot;: 2,
14866 &quot;rank&quot;: 3,
14867 &quot;orderno&quot;: 1002
14868 },
14869 {
14870 &quot;items&quot;: 2,
14871 &quot;rank&quot;: 3,
14872 &quot;orderno&quot;: 1001
14873 },
14874 {
14875 &quot;items&quot;: 2,
14876 &quot;rank&quot;: 3,
14877 &quot;orderno&quot;: 1003
14878 },
14879 {
14880 &quot;items&quot;: 3,
14881 &quot;rank&quot;: 8,
14882 &quot;orderno&quot;: 1006
14883 },
14884 {
14885 &quot;items&quot;: 4,
14886 &quot;rank&quot;: 9,
14887 &quot;orderno&quot;: 1005
14888 }
14889]
14890</pre></div></div>
14891</li>
14892</ul></div>
14893<div class="section">
14894<h3><a name="ratio_to_report"></a>ratio_to_report</h3>
14895<ul>
14896
14897<li>
14898
14899<p>Syntax:</p>
14900
14901<div>
14902<div>
14903<pre class="source">RATIO_TO_REPORT(expr) OVER (window-definition)
14904</pre></div></div>
14905</li>
14906<li>
14907
14908<p>Returns the fractional ratio of the specified value for each tuple to the sum of values for all tuples in the window frame.</p>
14909</li>
14910<li>
14911
14912<p>Arguments:</p>
14913<ul>
14914
14915<li><tt>expr</tt>: The value for which you want to calculate the fractional ratio. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
14916</ul>
14917</li>
14918<li>
14919
14920<p>Clauses:</p>
14921<ul>
14922
14923<li>
14924
14925<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14926</li>
14927<li>
14928
14929<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14930</li>
14931<li>
14932
14933<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
14934</li>
14935</ul>
14936</li>
14937<li>
14938
14939<p>Return Value:</p>
14940<ul>
14941
14942<li>
14943
14944<p>A number between 0 and 1, representing the fractional ratio of the value for the current tuple to the sum of values for all tuples in the current window frame. The sum of returned values for all tuples in the current window frame is 1.</p>
14945</li>
14946<li>
14947
14948<p>If the input expression does not evaluate to a number, or the sum of values for all tuples is zero, it returns NULL.</p>
14949</li>
14950</ul>
14951</li>
14952<li>
14953
14954<p>Example:</p>
14955<p>For each customer, calculate the value of each order as a fraction of the total value of all orders.</p>
14956
14957<div>
14958<div>
14959<pre class="source">FROM orders AS o
14960LET revenue = ROUND((
14961 FROM o.items
14962 SELECT VALUE SUM(qty * price)
14963)[0], 2)
14964SELECT o.custid, o.orderno,
14965RATIO_TO_REPORT(revenue) OVER (
14966 PARTITION BY o.custid
14967) AS fractional_ratio;
14968</pre></div></div>
14969</li>
14970<li>
14971
14972<p>The expected result is:</p>
14973
14974<div>
14975<div>
14976<pre class="source">[
14977 {
14978 &quot;custid&quot;: &quot;C13&quot;,
14979 &quot;orderno&quot;: 1007,
14980 &quot;fractional_ratio&quot;: 0.010006289887088855
14981 },
14982 {
14983 &quot;custid&quot;: &quot;C13&quot;,
14984 &quot;orderno&quot;: 1002,
14985 &quot;fractional_ratio&quot;: 0.8365971710849288
14986 },
14987 {
14988 &quot;custid&quot;: &quot;C13&quot;,
14989 &quot;orderno&quot;: 1009,
14990 &quot;fractional_ratio&quot;: null
14991 },
14992 {
14993 &quot;custid&quot;: &quot;C13&quot;,
14994 &quot;orderno&quot;: 1008,
14995 &quot;fractional_ratio&quot;: 0.15339653902798234
14996 },
14997 {
14998 &quot;custid&quot;: &quot;C31&quot;,
14999 &quot;orderno&quot;: 1003,
15000 &quot;fractional_ratio&quot;: 1
15001 },
15002 {
15003 &quot;custid&quot;: &quot;C35&quot;,
15004 &quot;orderno&quot;: 1004,
15005 &quot;fractional_ratio&quot;: 1
15006 },
15007 {
15008 &quot;custid&quot;: &quot;C37&quot;,
15009 &quot;orderno&quot;: 1005,
15010 &quot;fractional_ratio&quot;: 1
15011 },
15012 {
15013 &quot;custid&quot;: &quot;C41&quot;,
15014 &quot;orderno&quot;: 1006,
15015 &quot;fractional_ratio&quot;: 0.9917007404772666
15016 },
15017 {
15018 &quot;custid&quot;: &quot;C41&quot;,
15019 &quot;orderno&quot;: 1001,
15020 &quot;fractional_ratio&quot;: 0.008299259522733382
15021 }
15022]
15023</pre></div></div>
15024</li>
15025</ul></div>
15026<div class="section">
15027<h3><a name="row_number"></a>row_number</h3>
15028<ul>
15029
15030<li>
15031
15032<p>Syntax:</p>
15033
15034<div>
15035<div>
15036<pre class="source">ROW_NUMBER() OVER ([window-partition-clause] [window-order-clause])
15037</pre></div></div>
15038</li>
15039<li>
15040
15041<p>Returns a unique row number for every tuple in every window partition. In each window partition, the row numbering starts at 1.</p>
15042<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
15043</li>
15044<li>
15045
15046<p>Arguments:</p>
15047<ul>
15048
15049<li>None.</li>
15050</ul>
15051</li>
15052<li>
15053
15054<p>Clauses:</p>
15055<ul>
15056
15057<li>
15058
15059<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
15060</li>
15061<li>
15062
15063<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
15064</li>
15065</ul>
15066</li>
15067<li>
15068
15069<p>Return Value:</p>
15070<ul>
15071
15072<li>An integer, greater than or equal to 1.</li>
15073</ul>
15074</li>
15075<li>
15076
15077<p>Example:</p>
15078<p>For each customer, number all orders by value.</p>
15079
15080<div>
15081<div>
15082<pre class="source">FROM orders AS o
15083LET revenue = ROUND((
15084 FROM o.items
15085 SELECT VALUE SUM(qty * price)
15086)[0], 2)
15087SELECT o.custid, o.orderno,
15088ROW_NUMBER() OVER (
15089 PARTITION BY o.custid
15090 ORDER BY revenue
15091) AS `row`;
15092</pre></div></div>
15093</li>
15094<li>
15095
15096<p>The expected result is:</p>
15097
15098<div>
15099<div>
15100<pre class="source">[
15101 {
15102 &quot;row&quot;: 1,
15103 &quot;custid&quot;: &quot;C13&quot;,
15104 &quot;orderno&quot;: 1009
15105 },
15106 {
15107 &quot;row&quot;: 2,
15108 &quot;custid&quot;: &quot;C13&quot;,
15109 &quot;orderno&quot;: 1007
15110 },
15111 {
15112 &quot;row&quot;: 3,
15113 &quot;custid&quot;: &quot;C13&quot;,
15114 &quot;orderno&quot;: 1008
15115 },
15116 {
15117 &quot;row&quot;: 4,
15118 &quot;custid&quot;: &quot;C13&quot;,
15119 &quot;orderno&quot;: 1002
15120 },
15121 {
15122 &quot;row&quot;: 1,
15123 &quot;custid&quot;: &quot;C31&quot;,
15124 &quot;orderno&quot;: 1003
15125 },
15126 {
15127 &quot;row&quot;: 1,
15128 &quot;custid&quot;: &quot;C35&quot;,
15129 &quot;orderno&quot;: 1004
15130 },
15131 {
15132 &quot;row&quot;: 1,
15133 &quot;custid&quot;: &quot;C37&quot;,
15134 &quot;orderno&quot;: 1005
15135 },
15136 {
15137 &quot;row&quot;: 1,
15138 &quot;custid&quot;: &quot;C41&quot;,
15139 &quot;orderno&quot;: 1001
15140 },
15141 {
15142 &quot;row&quot;: 2,
15143 &quot;custid&quot;: &quot;C41&quot;,
15144 &quot;orderno&quot;: 1006
15145 }
15146]
15147</pre></div></div>
15148</li>
15149</ul><hr />
15150<p><a name="fn_1" id="fn_1">1</a>. If the query contains the GROUP BY clause or any <a href="#AggregateFunctions">aggregate functions</a>, this expression must only depend on GROUP BY expressions or aggregate functions.</p></div></div>
15151 </div>
15152 </div>
15153 </div>
15154 <hr/>
15155 <footer>
15156 <div class="container-fluid">
15157 <div class="row-fluid">
15158<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
15159 feather logo, and the Apache AsterixDB project logo are either
15160 registered trademarks or trademarks of The Apache Software
15161 Foundation in the United States and other countries.
15162 All other marks mentioned may be trademarks or registered
15163 trademarks of their respective owners.
15164 </div>
15165 </div>
15166 </div>
15167 </footer>
15168 </body>
15169</html>