blob: b88f43481f796d5ac9813d7d84e9c9a22011f97f [file] [log] [blame]
Ian Maxona1cc51b2020-08-07 13:11:35 -07001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from target/generated-site/markdown/sqlpp/builtins.md at 2020-08-07
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="20200807" />
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: 2020-08-07</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.5</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 class="active"><a href="#"><span class="none"></span>Builtin Functions</a></li>
49 <li class="nav-header">API/SDK</li>
50 <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
51 <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
52 <li class="nav-header">Advanced Features</li>
53 <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
54 <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
55 <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
56 <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
57 <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
58 <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
59 <li class="nav-header">Deprecated</li>
60 <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
61 <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>
62 <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
63</ul>
64 <hr />
65 <div id="poweredBy">
66 <div class="clear"></div>
67 <div class="clear"></div>
68 <div class="clear"></div>
69 <div class="clear"></div>
70<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
71 </div>
72 </div>
73 </div>
74 <div id="bodyColumn" class="span10" >
75<!--
76 ! Licensed to the Apache Software Foundation (ASF) under one
77 ! or more contributor license agreements. See the NOTICE file
78 ! distributed with this work for additional information
79 ! regarding copyright ownership. The ASF licenses this file
80 ! to you under the Apache License, Version 2.0 (the
81 ! "License"); you may not use this file except in compliance
82 ! with the License. You may obtain a copy of the License at
83 !
84 ! http://www.apache.org/licenses/LICENSE-2.0
85 !
86 ! Unless required by applicable law or agreed to in writing,
87 ! software distributed under the License is distributed on an
88 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
89 ! KIND, either express or implied. See the License for the
90 ! specific language governing permissions and limitations
91 ! under the License.
92 !-->
93<h1>Builtin Functions</h1><!--
94 ! Licensed to the Apache Software Foundation (ASF) under one
95 ! or more contributor license agreements. See the NOTICE file
96 ! distributed with this work for additional information
97 ! regarding copyright ownership. The ASF licenses this file
98 ! to you under the Apache License, Version 2.0 (the
99 ! "License"); you may not use this file except in compliance
100 ! with the License. You may obtain a copy of the License at
101 !
102 ! http://www.apache.org/licenses/LICENSE-2.0
103 !
104 ! Unless required by applicable law or agreed to in writing,
105 ! software distributed under the License is distributed on an
106 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
107 ! KIND, either express or implied. See the License for the
108 ! specific language governing permissions and limitations
109 ! under the License.
110 !-->
111
112<div class="section">
113<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
114<ul>
115
116<li><a href="#NumericFunctions">Numeric Functions</a></li>
117<li><a href="#StringFunctions">String Functions</a></li>
118<li><a href="#BinaryFunctions">Binary Functions</a></li>
119<li><a href="#SpatialFunctions">Spatial Functions</a></li>
120<li><a href="#SimilarityFunctions">Similarity Functions</a></li>
121<li><a href="#TokenizingFunctions">Tokenizing Functions</a></li>
122<li><a href="#TemporalFunctions">Temporal Functions</a></li>
123<li><a href="#ObjectFunctions">Object Functions</a></li>
124<li><a href="#AggregateFunctions">Aggregate Functions (Array Functions)</a></li>
125<li><a href="#ComparisonFunctions">Comparison Functions</a></li>
126<li><a href="#TypeFunctions">Type Functions</a></li>
127<li><a href="#ConditionalFunctions">Conditional Functions</a></li>
128<li><a href="#MiscFunctions">Miscellaneous Functions</a></li>
129<li><a href="#BitwiseFunctions">Bitwise Functions</a></li>
130<li><a href="#WindowFunctions">Window Functions</a></li>
131</ul><!--
132 ! Licensed to the Apache Software Foundation (ASF) under one
133 ! or more contributor license agreements. See the NOTICE file
134 ! distributed with this work for additional information
135 ! regarding copyright ownership. The ASF licenses this file
136 ! to you under the Apache License, Version 2.0 (the
137 ! "License"); you may not use this file except in compliance
138 ! with the License. You may obtain a copy of the License at
139 !
140 ! http://www.apache.org/licenses/LICENSE-2.0
141 !
142 ! Unless required by applicable law or agreed to in writing,
143 ! software distributed under the License is distributed on an
144 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
145 ! KIND, either express or implied. See the License for the
146 ! specific language governing permissions and limitations
147 ! under the License.
148 !-->
149
150<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><!--
151 ! Licensed to the Apache Software Foundation (ASF) under one
152 ! or more contributor license agreements. See the NOTICE file
153 ! distributed with this work for additional information
154 ! regarding copyright ownership. The ASF licenses this file
155 ! to you under the Apache License, Version 2.0 (the
156 ! "License"); you may not use this file except in compliance
157 ! with the License. You may obtain a copy of the License at
158 !
159 ! http://www.apache.org/licenses/LICENSE-2.0
160 !
161 ! Unless required by applicable law or agreed to in writing,
162 ! software distributed under the License is distributed on an
163 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
164 ! KIND, either express or implied. See the License for the
165 ! specific language governing permissions and limitations
166 ! under the License.
167 !-->
168</div>
169<div class="section">
170<h2><a name="Numeric_Functions"></a><a name="NumericFunctions" id="NumericFunctions">Numeric Functions</a></h2>
171<div class="section">
172<h3><a name="abs"></a>abs</h3>
173<ul>
174
175<li>
176
177<p>Syntax:</p>
178
179<div>
180<div>
181<pre class="source">abs(numeric_value)
182</pre></div></div>
183</li>
184<li>
185
186<p>Computes the absolute value of the argument.</p>
187</li>
188<li>Arguments:
189<ul>
190
191<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>
192</ul>
193</li>
194<li>Return Value:
195<ul>
196
197<li>The absolute value of the argument with the same type as the input argument,</li>
198<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
199<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
200<li>any other non-numeric input value will cause a type error.</li>
201</ul>
202</li>
203<li>
204
205<p>Example:</p>
206
207<div>
208<div>
209<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;)) };
210</pre></div></div>
211</li>
212<li>
213
214<p>The expected result is:</p>
215
216<div>
217<div>
218<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 }
219</pre></div></div>
220</li>
221</ul></div>
222<div class="section">
223<h3><a name="acos"></a>acos</h3>
224<ul>
225
226<li>
227
228<p>Syntax:</p>
229
230<div>
231<div>
232<pre class="source">acos(numeric_value)
233</pre></div></div>
234</li>
235<li>
236
237<p>Computes the arc cosine value of the argument.</p>
238</li>
239<li>Arguments:
240<ul>
241
242<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>
243</ul>
244</li>
245<li>Return Value:
246<ul>
247
248<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>
249<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
250<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
251<li>any other non-numeric input value will cause a type error,</li>
252<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
253</ul>
254</li>
255<li>
256
257<p>Example:</p>
258
259<div>
260<div>
261<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;)) };
262</pre></div></div>
263</li>
264<li>
265
266<p>The expected result is:</p>
267
268<div>
269<div>
270<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 }
271</pre></div></div>
272</li>
273</ul></div>
274<div class="section">
275<h3><a name="asin"></a>asin</h3>
276<ul>
277
278<li>
279
280<p>Syntax:</p>
281
282<div>
283<div>
284<pre class="source">asin(numeric_value)
285</pre></div></div>
286</li>
287<li>
288
289<p>Computes the arc sine value of the argument.</p>
290</li>
291<li>Arguments:
292<ul>
293
294<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>
295</ul>
296</li>
297<li>Return Value:
298<ul>
299
300<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>
301<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
302<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
303<li>any other non-numeric input value will cause a type error,</li>
304<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
305</ul>
306</li>
307<li>
308
309<p>Example:</p>
310
311<div>
312<div>
313<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;)) };
314</pre></div></div>
315</li>
316<li>
317
318<p>The expected result is:</p>
319
320<div>
321<div>
322<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 }
323</pre></div></div>
324</li>
325</ul></div>
326<div class="section">
327<h3><a name="atan"></a>atan</h3>
328<ul>
329
330<li>
331
332<p>Syntax:</p>
333
334<div>
335<div>
336<pre class="source">atan(numeric_value)
337</pre></div></div>
338</li>
339<li>
340
341<p>Computes the arc tangent value of the argument.</p>
342</li>
343<li>Arguments:
344<ul>
345
346<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>
347</ul>
348</li>
349<li>Return Value:
350<ul>
351
352<li>the <tt>double</tt> arc tangent in radians for the argument,</li>
353<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
354<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
355<li>any other non-numeric input value will cause a type error.</li>
356</ul>
357</li>
358<li>
359
360<p>Example:</p>
361
362<div>
363<div>
364<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;)) };
365</pre></div></div>
366</li>
367<li>
368
369<p>The expected result is:</p>
370
371<div>
372<div>
373<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 }
374</pre></div></div>
375</li>
376</ul></div>
377<div class="section">
378<h3><a name="atan2"></a>atan2</h3>
379<ul>
380
381<li>
382
383<p>Syntax:</p>
384
385<div>
386<div>
387<pre class="source">atan2(numeric_value1, numeric_value2)
388</pre></div></div>
389</li>
390<li>
391
392<p>Computes the arc tangent value of numeric_value2/numeric_value1.</p>
393</li>
394<li>Arguments:
395<ul>
396
397<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>
398<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>
399</ul>
400</li>
401<li>Return Value:
402<ul>
403
404<li>the <tt>double</tt> arc tangent in radians for <tt>numeric_value1</tt> and <tt>numeric_value2</tt>,</li>
405<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
406<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
407<li>any other non-numeric input value will cause a type error.</li>
408</ul>
409</li>
410<li>
411
412<p>Example:</p>
413
414<div>
415<div>
416<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;)) };
417</pre></div></div>
418</li>
419<li>
420
421<p>The expected result is:</p>
422
423<div>
424<div>
425<pre class="source">{ &quot;v1&quot;: 0.4636476090008061, &quot;v2&quot;: 0.0, &quot;v3&quot;: 2.356194490192345 }
426</pre></div></div>
427</li>
428</ul></div>
429<div class="section">
430<h3><a name="ceil"></a>ceil</h3>
431<ul>
432
433<li>
434
435<p>Syntax:</p>
436
437<div>
438<div>
439<pre class="source">ceil(numeric_value)
440</pre></div></div>
441</li>
442<li>
443
444<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>
445</li>
446<li>Arguments:
447<ul>
448
449<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>
450</ul>
451</li>
452<li>Return Value:
453<ul>
454
455<li>The ceiling value for the given number in the same type as the input argument,</li>
456<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
457<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
458<li>any other non-numeric input value will cause a type error.</li>
459</ul>
460</li>
461<li>
462
463<p>Example:</p>
464
465<div>
466<div>
467<pre class="source">{
468 &quot;v1&quot;: ceil(2013),
469 &quot;v2&quot;: ceil(-4036),
470 &quot;v3&quot;: ceil(0.3),
471 &quot;v4&quot;: ceil(float(&quot;-2013.2&quot;)),
472 &quot;v5&quot;: ceil(double(&quot;-2013.893823748327284&quot;))
473};
474</pre></div></div>
475</li>
476<li>
477
478<p>The expected result is:</p>
479
480<div>
481<div>
482<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 }
483</pre></div></div>
484</li>
485</ul></div>
486<div class="section">
487<h3><a name="cos"></a>cos</h3>
488<ul>
489
490<li>
491
492<p>Syntax:</p>
493
494<div>
495<div>
496<pre class="source">cos(numeric_value)
497</pre></div></div>
498</li>
499<li>
500
501<p>Computes the cosine value of the argument.</p>
502</li>
503<li>Arguments:
504<ul>
505
506<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>
507</ul>
508</li>
509<li>Return Value:
510<ul>
511
512<li>the <tt>double</tt> cosine value for the argument,</li>
513<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
514<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
515<li>any other non-numeric input value will cause a type error.</li>
516</ul>
517</li>
518<li>
519
520<p>Example:</p>
521
522<div>
523<div>
524<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;)) };
525</pre></div></div>
526</li>
527<li>
528
529<p>The expected result is:</p>
530
531<div>
532<div>
533<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 }
534</pre></div></div>
535</li>
536</ul></div>
537<div class="section">
538<h3><a name="cosh"></a>cosh</h3>
539<ul>
540
541<li>
542
543<p>Syntax:</p>
544
545<div>
546<div>
547<pre class="source">cosh(numeric_value)
548</pre></div></div>
549</li>
550<li>
551
552<p>Computes the hyperbolic cosine value of the argument.</p>
553</li>
554<li>Arguments:
555<ul>
556
557<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>
558</ul>
559</li>
560<li>Return Value:
561<ul>
562
563<li>the <tt>double</tt> hyperbolic cosine value for the argument,</li>
564<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
565<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
566<li>any other non-numeric input value will cause a type error.</li>
567</ul>
568</li>
569<li>
570
571<p>Example:</p>
572
573<div>
574<div>
575<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;)) };
576</pre></div></div>
577</li>
578<li>
579
580<p>The expected result is:</p>
581
582<div>
583<div>
584<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 }
585</pre></div></div>
586</li>
587</ul></div>
588<div class="section">
589<h3><a name="degrees"></a>degrees</h3>
590<ul>
591
592<li>
593
594<p>Syntax:</p>
595
596<div>
597<div>
598<pre class="source">degrees(numeric_value)
599</pre></div></div>
600</li>
601<li>
602
603<p>Converts radians to degrees</p>
604</li>
605<li>Arguments:
606<ul>
607
608<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>
609</ul>
610</li>
611<li>Return Value:
612<ul>
613
614<li>The degrees value for the given radians value. The returned value has type <tt>double</tt>,</li>
615<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
616<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
617<li>any other non-numeric input value will cause a type error.</li>
618</ul>
619</li>
620<li>
621
622<p>Example:</p>
623
624<div>
625<div>
626<pre class="source">{ &quot;v1&quot;: degrees(pi()) };
627</pre></div></div>
628</li>
629<li>
630
631<p>The expected result is:</p>
632
633<div>
634<div>
635<pre class="source">{ &quot;v1&quot;: 180.0 }
636</pre></div></div>
637</li>
638</ul></div>
639<div class="section">
640<h3><a name="e"></a>e</h3>
641<ul>
642
643<li>
644
645<p>Syntax:</p>
646
647<div>
648<div>
649<pre class="source">e()
650</pre></div></div>
651</li>
652<li>
653
654<p>Return Value:</p>
655<ul>
656
657<li>e (base of the natural logarithm)</li>
658</ul>
659</li>
660<li>
661
662<p>Example:</p>
663
664<div>
665<div>
666<pre class="source">{ &quot;v1&quot;: e() };
667</pre></div></div>
668</li>
669<li>
670
671<p>The expected result is:</p>
672
673<div>
674<div>
675<pre class="source">{ &quot;v1&quot;: 2.718281828459045 }
676</pre></div></div>
677</li>
678</ul></div>
679<div class="section">
680<h3><a name="exp"></a>exp</h3>
681<ul>
682
683<li>
684
685<p>Syntax:</p>
686
687<div>
688<div>
689<pre class="source">exp(numeric_value)
690</pre></div></div>
691</li>
692<li>
693
694<p>Computes e<sup>numeric_value</sup>.</p>
695</li>
696<li>Arguments:
697<ul>
698
699<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>
700</ul>
701</li>
702<li>Return Value:
703<ul>
704
705<li>e<sup>numeric_value</sup>,</li>
706<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
707<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
708<li>any other non-numeric input value will cause a type error.</li>
709</ul>
710</li>
711<li>
712
713<p>Example:</p>
714
715<div>
716<div>
717<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;)) };
718</pre></div></div>
719</li>
720<li>
721
722<p>The expected result is:</p>
723
724<div>
725<div>
726<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; }
727</pre></div></div>
728</li>
729</ul></div>
730<div class="section">
731<h3><a name="floor"></a>floor</h3>
732<ul>
733
734<li>
735
736<p>Syntax:</p>
737
738<div>
739<div>
740<pre class="source">floor(numeric_value)
741</pre></div></div>
742</li>
743<li>
744
745<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>
746</li>
747<li>Arguments:
748<ul>
749
750<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>
751</ul>
752</li>
753<li>Return Value:
754<ul>
755
756<li>The floor value for the given number in the same type as the input argument,</li>
757<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
758<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
759<li>any other non-numeric input value will cause a type error.</li>
760</ul>
761</li>
762<li>
763
764<p>Example:</p>
765
766<div>
767<div>
768<pre class="source">{
769 &quot;v1&quot;: floor(2013),
770 &quot;v2&quot;: floor(-4036),
771 &quot;v3&quot;: floor(0.8),
772 &quot;v4&quot;: floor(float(&quot;-2013.2&quot;)),
773 &quot;v5&quot;: floor(double(&quot;-2013.893823748327284&quot;))
774};
775</pre></div></div>
776</li>
777<li>
778
779<p>The expected result is:</p>
780
781<div>
782<div>
783<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 }
784</pre></div></div>
785</li>
786</ul></div>
787<div class="section">
788<h3><a name="ln"></a>ln</h3>
789<ul>
790
791<li>
792
793<p>Syntax:</p>
794
795<div>
796<div>
797<pre class="source">ln(numeric_value)
798</pre></div></div>
799</li>
800<li>
801
802<p>Computes log<sub>e</sub>numeric_value.</p>
803</li>
804<li>Arguments:
805<ul>
806
807<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>
808</ul>
809</li>
810<li>Return Value:
811<ul>
812
813<li>log<sub>e</sub>numeric_value,</li>
814<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
815<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
816<li>any other non-numeric input value will cause a type error.</li>
817</ul>
818</li>
819<li>
820
821<p>Example:</p>
822
823<div>
824<div>
825<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;)) };
826</pre></div></div>
827</li>
828<li>
829
830<p>The expected result is:</p>
831
832<div>
833<div>
834<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 }
835</pre></div></div>
836</li>
837</ul></div>
838<div class="section">
839<h3><a name="log"></a>log</h3>
840<ul>
841
842<li>
843
844<p>Syntax:</p>
845
846<div>
847<div>
848<pre class="source">log(numeric_value)
849</pre></div></div>
850</li>
851<li>
852
853<p>Computes log<sub>10</sub>numeric_value.</p>
854</li>
855<li>Arguments:
856<ul>
857
858<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>
859</ul>
860</li>
861<li>Return Value:
862<ul>
863
864<li>log<sub>10</sub>numeric_value,</li>
865<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
866<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
867<li>any other non-numeric input value will cause a type error.</li>
868</ul>
869</li>
870<li>
871
872<p>Example:</p>
873
874<div>
875<div>
876<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;)) };
877</pre></div></div>
878</li>
879<li>
880
881<p>The expected result is:</p>
882
883<div>
884<div>
885<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 }
886</pre></div></div>
887</li>
888</ul></div>
889<div class="section">
890<h3><a name="pi"></a>pi</h3>
891<ul>
892
893<li>
894
895<p>Syntax:</p>
896
897<div>
898<div>
899<pre class="source">pi()
900</pre></div></div>
901</li>
902<li>
903
904<p>Return Value:</p>
905<ul>
906
907<li>Pi</li>
908</ul>
909</li>
910<li>
911
912<p>Example:</p>
913
914<div>
915<div>
916<pre class="source">{ &quot;v1&quot;: pi() };
917</pre></div></div>
918</li>
919<li>
920
921<p>The expected result is:</p>
922
923<div>
924<div>
925<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
926</pre></div></div>
927</li>
928</ul></div>
929<div class="section">
930<h3><a name="power"></a>power</h3>
931<ul>
932
933<li>
934
935<p>Syntax:</p>
936
937<div>
938<div>
939<pre class="source">power(numeric_value1, numeric_value2)
940</pre></div></div>
941</li>
942<li>
943
944<p>Computes numeric_value1<sup>numeric_value2</sup>.</p>
945</li>
946<li>Arguments:
947<ul>
948
949<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>
950<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>
951</ul>
952</li>
953<li>Return Value:
954<ul>
955
956<li>numeric_value1<sup>numeric_value2</sup>,</li>
957<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
958<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
959<li>any other non-numeric input value will cause a type error.</li>
960</ul>
961</li>
962<li>
963
964<p>Example:</p>
965
966<div>
967<div>
968<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;)) };
969</pre></div></div>
970</li>
971<li>
972
973<p>The expected result is:</p>
974
975<div>
976<div>
977<pre class="source">{ &quot;v1&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1.4142135623730951 }
978</pre></div></div>
979</li>
980</ul></div>
981<div class="section">
982<h3><a name="radians"></a>radians</h3>
983<ul>
984
985<li>
986
987<p>Syntax:</p>
988
989<div>
990<div>
991<pre class="source">radians(numeric_value)
992</pre></div></div>
993</li>
994<li>
995
996<p>Converts degrees to radians</p>
997</li>
998<li>Arguments:
999<ul>
1000
1001<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>
1002</ul>
1003</li>
1004<li>Return Value:
1005<ul>
1006
1007<li>The radians value for the given degrees value. The returned value has type <tt>double</tt>,</li>
1008<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1009<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1010<li>any other non-numeric input value will cause a type error.</li>
1011</ul>
1012</li>
1013<li>
1014
1015<p>Example:</p>
1016
1017<div>
1018<div>
1019<pre class="source">{ &quot;v1&quot;: radians(180) };
1020</pre></div></div>
1021</li>
1022<li>
1023
1024<p>The expected result is:</p>
1025
1026<div>
1027<div>
1028<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
1029</pre></div></div>
1030</li>
1031</ul></div>
1032<div class="section">
1033<h3><a name="round"></a>round</h3>
1034<ul>
1035
1036<li>
1037
1038<p>Syntax:</p>
1039
1040<div>
1041<div>
1042<pre class="source">round(numeric_value[, round_digit])
1043</pre></div></div>
1044</li>
1045<li>
1046
1047<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>
1048</li>
1049<li>
1050
1051<p>Arguments:</p>
1052<ul>
1053
1054<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>
1055<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>
1056</ul>
1057</li>
1058<li>Return Value:
1059<ul>
1060
1061<li>The rounded value for the given number. The returned value has the following type:
1062<ul>
1063
1064<li><tt>bigint</tt> if the input value has type <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt> or <tt>bigint</tt>,</li>
1065<li><tt>float</tt> if the input value has type <tt>float</tt>,</li>
1066<li><tt>double</tt> if the input value has type <tt>double</tt>;</li>
1067</ul>
1068</li>
1069<li><tt>missing</tt> if the input value is a <tt>missing</tt> value,</li>
1070<li><tt>null</tt> if the input value is a <tt>null</tt> value,</li>
1071<li>any other non-numeric input value will return a <tt>null</tt> value.</li>
1072</ul>
1073</li>
1074<li>
1075
1076<p>Example:</p>
1077
1078<div>
1079<div>
1080<pre class="source">{
1081 &quot;v1&quot;: round(2013),
1082 &quot;v2&quot;: round(-4036),
1083 &quot;v3&quot;: round(0.8),
1084 &quot;v4&quot;: round(float(&quot;-2013.256&quot;)),
1085 &quot;v5&quot;: round(double(&quot;-2013.893823748327284&quot;))
1086 &quot;v6&quot;: round(123456, -1),
1087 &quot;v7&quot;: round(456.456, 2),
1088 &quot;v8&quot;: round(456.456, -1),
1089 &quot;v9&quot;: round(-456.456, -2)
1090};
1091</pre></div></div>
1092</li>
1093<li>
1094
1095<p>The expected result is:</p>
1096
1097<div>
1098<div>
1099<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 }
1100</pre></div></div>
1101</li>
1102</ul></div>
1103<div class="section">
1104<h3><a name="sign"></a>sign</h3>
1105<ul>
1106
1107<li>
1108
1109<p>Syntax:</p>
1110
1111<div>
1112<div>
1113<pre class="source">sign(numeric_value)
1114</pre></div></div>
1115</li>
1116<li>
1117
1118<p>Computes the sign of the argument.</p>
1119</li>
1120<li>Arguments:
1121<ul>
1122
1123<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>
1124</ul>
1125</li>
1126<li>Return Value:
1127<ul>
1128
1129<li>the sign (a <tt>tinyint</tt>) of the argument, -1 for negative values, 0 for 0, and 1 for positive values,</li>
1130<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1131<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1132<li>any other non-numeric input value will cause a type error.</li>
1133</ul>
1134</li>
1135<li>
1136
1137<p>Example:</p>
1138
1139<div>
1140<div>
1141<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;)) };
1142</pre></div></div>
1143</li>
1144<li>
1145
1146<p>The expected result is:</p>
1147
1148<div>
1149<div>
1150<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1, &quot;v5&quot;: -1 }
1151</pre></div></div>
1152</li>
1153</ul></div>
1154<div class="section">
1155<h3><a name="sin"></a>sin</h3>
1156<ul>
1157
1158<li>
1159
1160<p>Syntax:</p>
1161
1162<div>
1163<div>
1164<pre class="source">sin(numeric_value)
1165</pre></div></div>
1166</li>
1167<li>
1168
1169<p>Computes the sine value of the argument.</p>
1170</li>
1171<li>Arguments:
1172<ul>
1173
1174<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>
1175</ul>
1176</li>
1177<li>Return Value:
1178<ul>
1179
1180<li>the <tt>double</tt> sine value for the argument,</li>
1181<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1182<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1183<li>any other non-numeric input value will cause a type error.</li>
1184</ul>
1185</li>
1186<li>
1187
1188<p>Example:</p>
1189
1190<div>
1191<div>
1192<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;)) };
1193</pre></div></div>
1194</li>
1195<li>
1196
1197<p>The expected result is:</p>
1198
1199<div>
1200<div>
1201<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 }
1202</pre></div></div>
1203</li>
1204</ul></div>
1205<div class="section">
1206<h3><a name="sinh"></a>sinh</h3>
1207<ul>
1208
1209<li>
1210
1211<p>Syntax:</p>
1212
1213<div>
1214<div>
1215<pre class="source">sinh(numeric_value)
1216</pre></div></div>
1217</li>
1218<li>
1219
1220<p>Computes the hyperbolic sine value of the argument.</p>
1221</li>
1222<li>Arguments:
1223<ul>
1224
1225<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>
1226</ul>
1227</li>
1228<li>Return Value:
1229<ul>
1230
1231<li>the <tt>double</tt> hyperbolic sine value for the argument,</li>
1232<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1233<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1234<li>any other non-numeric input value will cause a type error.</li>
1235</ul>
1236</li>
1237<li>
1238
1239<p>Example:</p>
1240
1241<div>
1242<div>
1243<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;)) };
1244</pre></div></div>
1245</li>
1246<li>
1247
1248<p>The expected result is:</p>
1249
1250<div>
1251<div>
1252<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 }
1253</pre></div></div>
1254</li>
1255</ul></div>
1256<div class="section">
1257<h3><a name="sqrt"></a>sqrt</h3>
1258<ul>
1259
1260<li>
1261
1262<p>Syntax:</p>
1263
1264<div>
1265<div>
1266<pre class="source">sqrt(numeric_value)
1267</pre></div></div>
1268</li>
1269<li>
1270
1271<p>Computes the square root of the argument.</p>
1272</li>
1273<li>Arguments:
1274<ul>
1275
1276<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>
1277</ul>
1278</li>
1279<li>Return Value:
1280<ul>
1281
1282<li>the <tt>double</tt> square root value for the argument,</li>
1283<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1284<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1285<li>any other non-numeric input value will cause a type error.</li>
1286</ul>
1287</li>
1288<li>
1289
1290<p>Example:</p>
1291
1292<div>
1293<div>
1294<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;)) };
1295</pre></div></div>
1296</li>
1297<li>
1298
1299<p>The expected result is:</p>
1300
1301<div>
1302<div>
1303<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 }
1304</pre></div></div>
1305</li>
1306</ul></div>
1307<div class="section">
1308<h3><a name="tan"></a>tan</h3>
1309<ul>
1310
1311<li>
1312
1313<p>Syntax:</p>
1314
1315<div>
1316<div>
1317<pre class="source">tan(numeric_value)
1318</pre></div></div>
1319</li>
1320<li>
1321
1322<p>Computes the tangent value of the argument.</p>
1323</li>
1324<li>Arguments:
1325<ul>
1326
1327<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>
1328</ul>
1329</li>
1330<li>Return Value:
1331<ul>
1332
1333<li>the <tt>double</tt> tangent value for the argument,</li>
1334<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1335<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1336<li>any other non-numeric input value will cause a type error.</li>
1337</ul>
1338</li>
1339<li>
1340
1341<p>Example:</p>
1342
1343<div>
1344<div>
1345<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;)) };
1346</pre></div></div>
1347</li>
1348<li>
1349
1350<p>The expected result is:</p>
1351
1352<div>
1353<div>
1354<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 }
1355</pre></div></div>
1356</li>
1357</ul></div>
1358<div class="section">
1359<h3><a name="tanh"></a>tanh</h3>
1360<ul>
1361
1362<li>
1363
1364<p>Syntax:</p>
1365
1366<div>
1367<div>
1368<pre class="source">tanh(numeric_value)
1369</pre></div></div>
1370</li>
1371<li>
1372
1373<p>Computes the hyperbolic tangent value of the argument.</p>
1374</li>
1375<li>Arguments:
1376<ul>
1377
1378<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>
1379</ul>
1380</li>
1381<li>Return Value:
1382<ul>
1383
1384<li>the <tt>double</tt> hyperbolic tangent value for the argument,</li>
1385<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1386<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1387<li>any other non-numeric input value will cause a type error.</li>
1388</ul>
1389</li>
1390<li>
1391
1392<p>Example:</p>
1393
1394<div>
1395<div>
1396<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;)) };
1397</pre></div></div>
1398</li>
1399<li>
1400
1401<p>The expected result is:</p>
1402
1403<div>
1404<div>
1405<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 }
1406</pre></div></div>
1407</li>
1408</ul></div>
1409<div class="section">
1410<h3><a name="trunc"></a>trunc</h3>
1411<ul>
1412
1413<li>
1414
1415<p>Syntax:</p>
1416
1417<div>
1418<div>
1419<pre class="source">trunc(numeric_value, number_digits)
1420</pre></div></div>
1421</li>
1422<li>
1423
1424<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>
1425</li>
1426<li>Arguments:
1427<ul>
1428
1429<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>
1430<li><tt>number_digits</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value.</li>
1431</ul>
1432</li>
1433<li>Return Value:
1434<ul>
1435
1436<li>the <tt>double</tt> tangent value for the argument,</li>
1437<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1438<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is <tt>missing</tt>,</li>
1439<li>a type error will be raised if:
1440<ul>
1441
1442<li>the first argument is any other non-numeric value,</li>
1443<li>the second argument is any other non-tinyint, non-smallint, non-integer, and non-bigint value.</li>
1444</ul>
1445</li>
1446</ul>
1447</li>
1448<li>
1449
1450<p>Example:</p>
1451
1452<div>
1453<div>
1454<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) };
1455</pre></div></div>
1456</li>
1457<li>
1458
1459<p>The expected result is:</p>
1460
1461<div>
1462<div>
1463<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 }
1464</pre></div></div>
1465</li>
1466</ul><!--
1467 ! Licensed to the Apache Software Foundation (ASF) under one
1468 ! or more contributor license agreements. See the NOTICE file
1469 ! distributed with this work for additional information
1470 ! regarding copyright ownership. The ASF licenses this file
1471 ! to you under the Apache License, Version 2.0 (the
1472 ! "License"); you may not use this file except in compliance
1473 ! with the License. You may obtain a copy of the License at
1474 !
1475 ! http://www.apache.org/licenses/LICENSE-2.0
1476 !
1477 ! Unless required by applicable law or agreed to in writing,
1478 ! software distributed under the License is distributed on an
1479 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1480 ! KIND, either express or implied. See the License for the
1481 ! specific language governing permissions and limitations
1482 ! under the License.
1483 !-->
1484</div>
1485<div class="section">
1486<h3><a name="round_half_to_even"></a>round_half_to_even</h3>
1487<ul>
1488
1489<li>
1490
1491<p>Syntax:</p>
1492
1493<div>
1494<div>
1495<pre class="source">round_half_to_even(numeric_value, [precision])
1496</pre></div></div>
1497</li>
1498<li>
1499
1500<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>
1501</li>
1502<li>Arguments:
1503<ul>
1504
1505<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>
1506<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>
1507</ul>
1508</li>
1509<li>Return Value:
1510<ul>
1511
1512<li>The rounded value for the given number in the same type as the input argument,</li>
1513<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1514<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1515<li>a type error will be raised if:
1516<ul>
1517
1518<li>the first argument is any other non-numeric value,</li>
1519<li>or, the second argument is any other non-tinyint, non-smallint, non-integer, or non-bigint value.</li>
1520</ul>
1521</li>
1522</ul>
1523</li>
1524<li>
1525
1526<p>Example:</p>
1527
1528<div>
1529<div>
1530<pre class="source">{
1531 &quot;v1&quot;: round_half_to_even(2013),
1532 &quot;v2&quot;: round_half_to_even(-4036),
1533 &quot;v3&quot;: round_half_to_even(0.8),
1534 &quot;v4&quot;: round_half_to_even(float(&quot;-2013.256&quot;)),
1535 &quot;v5&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;)),
1536 &quot;v6&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;), 2),
1537 &quot;v7&quot;: round_half_to_even(2013, 4),
1538 &quot;v8&quot;: round_half_to_even(float(&quot;-2013.256&quot;), 5)
1539};
1540</pre></div></div>
1541</li>
1542<li>
1543
1544<p>The expected result is:</p>
1545
1546<div>
1547<div>
1548<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 }
1549</pre></div></div>
1550</li>
1551</ul><!--
1552 ! Licensed to the Apache Software Foundation (ASF) under one
1553 ! or more contributor license agreements. See the NOTICE file
1554 ! distributed with this work for additional information
1555 ! regarding copyright ownership. The ASF licenses this file
1556 ! to you under the Apache License, Version 2.0 (the
1557 ! "License"); you may not use this file except in compliance
1558 ! with the License. You may obtain a copy of the License at
1559 !
1560 ! http://www.apache.org/licenses/LICENSE-2.0
1561 !
1562 ! Unless required by applicable law or agreed to in writing,
1563 ! software distributed under the License is distributed on an
1564 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1565 ! KIND, either express or implied. See the License for the
1566 ! specific language governing permissions and limitations
1567 ! under the License.
1568 !-->
1569</div></div>
1570<div class="section">
1571<h2><a name="String_Functions"></a><a name="StringFunctions" id="StringFunctions">String Functions</a></h2>
1572<div class="section">
1573<h3><a name="concat"></a>concat</h3>
1574<ul>
1575
1576<li>
1577
1578<p>Syntax:</p>
1579
1580<div>
1581<div>
1582<pre class="source">concat(string1, string2, ...)
1583</pre></div></div>
1584</li>
1585<li>
1586
1587<p>Returns a concatenated string from arguments.</p>
1588</li>
1589<li>Arguments:
1590<ul>
1591
1592<li><tt>string1</tt>: a string value,</li>
1593<li><tt>string2</tt>: a string value,</li>
1594<li>&#x2026;.</li>
1595</ul>
1596</li>
1597<li>Return Value:
1598<ul>
1599
1600<li>a concatenated string from arguments,</li>
1601<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1602<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1603<li>any other non-string input value will cause a type error.</li>
1604</ul>
1605</li>
1606<li>
1607
1608<p>Example:</p>
1609
1610<div>
1611<div>
1612<pre class="source">concat(&quot;test &quot;, &quot;driven &quot;, &quot;development&quot;);
1613</pre></div></div>
1614</li>
1615<li>
1616
1617<p>The expected result is:</p>
1618
1619<div>
1620<div>
1621<pre class="source">&quot;test driven development&quot;
1622</pre></div></div>
1623</li>
1624</ul></div>
1625<div class="section">
1626<h3><a name="contains"></a>contains</h3>
1627<ul>
1628
1629<li>
1630
1631<p>Syntax:</p>
1632
1633<div>
1634<div>
1635<pre class="source">contains(string, substring_to_contain)
1636</pre></div></div>
1637</li>
1638<li>
1639
1640<p>Checks whether the string <tt>string</tt> contains the string <tt>substring_to_contain</tt></p>
1641</li>
1642<li>Arguments:
1643<ul>
1644
1645<li><tt>string</tt> : a <tt>string</tt> that might contain the given substring,</li>
1646<li><tt>substring_to_contain</tt> : a target <tt>string</tt> that might be contained.</li>
1647</ul>
1648</li>
1649<li>Return Value:
1650<ul>
1651
1652<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1653<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1654<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1655<li>any other non-string input value will cause a type error,</li>
1656<li><tt>false</tt> otherwise.</li>
1657</ul>
1658</li>
1659<li>
1660
1661<p>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</p>
1662</li>
1663<li>Example:
1664
1665<div>
1666<div>
1667<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;) };
1668</pre></div></div>
1669</li>
1670<li>
1671
1672<p>The expected result is:</p>
1673
1674<div>
1675<div>
1676<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1677</pre></div></div>
1678</li>
1679</ul></div>
1680<div class="section">
1681<h3><a name="ends_with"></a>ends_with</h3>
1682<ul>
1683
1684<li>
1685
1686<p>Syntax:</p>
1687
1688<div>
1689<div>
1690<pre class="source">ends_with(string, substring_to_end_with)
1691</pre></div></div>
1692</li>
1693<li>
1694
1695<p>Checks whether the string <tt>string</tt> ends with the string <tt>substring_to_end_with</tt>.</p>
1696</li>
1697<li>Arguments:
1698<ul>
1699
1700<li><tt>string</tt> : a <tt>string</tt> that might end with the given string,</li>
1701<li><tt>substring_to_end_with</tt> : a <tt>string</tt> that might be contained as the ending substring.</li>
1702</ul>
1703</li>
1704<li>Return Value:
1705<ul>
1706
1707<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1708<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1709<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1710<li>any other non-string input value will cause a type error,</li>
1711<li><tt>false</tt> otherwise.</li>
1712</ul>
1713</li>
1714<li>
1715
1716<p>Example:</p>
1717
1718<div>
1719<div>
1720<pre class="source">{
1721 &quot;v1&quot;: ends_with(&quot; love product-b its shortcut_menu is awesome:)&quot;, &quot;:)&quot;),
1722 &quot;v2&quot;: ends_with(&quot; awsome:)&quot;, &quot;:-)&quot;)
1723};
1724</pre></div></div>
1725</li>
1726<li>
1727
1728<p>The expected result is:</p>
1729
1730<div>
1731<div>
1732<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1733</pre></div></div>
1734</li>
1735</ul></div>
1736<div class="section">
1737<h3><a name="initcap_.28or_title.29"></a>initcap (or title)</h3>
1738<ul>
1739
1740<li>
1741
1742<p>Syntax:</p>
1743
1744<div>
1745<div>
1746<pre class="source">initcap(string)
1747</pre></div></div>
1748</li>
1749<li>
1750
1751<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>
1752</li>
1753<li>Arguments:
1754<ul>
1755
1756<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1757</ul>
1758</li>
1759<li>Return Value:
1760<ul>
1761
1762<li>a <tt>string</tt> as the title form of the given <tt>string</tt>,</li>
1763<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1764<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1765<li>any other non-string input value will cause a type error.</li>
1766</ul>
1767</li>
1768<li>
1769
1770<p>Example:</p>
1771
1772<div>
1773<div>
1774<pre class="source">{ &quot;v1&quot;: initcap(&quot;ASTERIXDB is here!&quot;), &quot;v2&quot;: title(&quot;ASTERIXDB is here!&quot;) };
1775</pre></div></div>
1776</li>
1777<li>
1778
1779<p>The expected result is:</p>
1780
1781<div>
1782<div>
1783<pre class="source">{ &quot;v1&quot;: &quot;Asterixdb Is Here!&quot;, &quot;v2&quot;: &quot;Asterixdb Is Here!&quot; }
1784</pre></div></div>
1785</li>
1786</ul></div>
1787<div class="section">
1788<h3><a name="length"></a>length</h3>
1789<ul>
1790
1791<li>
1792
1793<p>Syntax:</p>
1794
1795<div>
1796<div>
1797<pre class="source">length(string)
1798</pre></div></div>
1799</li>
1800<li>
1801
1802<p>Returns the length of the string <tt>string</tt>.</p>
1803</li>
1804<li>Arguments:
1805<ul>
1806
1807<li><tt>string</tt> : a <tt>string</tt> or <tt>null</tt> that represents the string to be checked.</li>
1808</ul>
1809</li>
1810<li>Return Value:
1811<ul>
1812
1813<li>an <tt>bigint</tt> that represents the length of <tt>string</tt>,</li>
1814<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1815<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1816<li>any other non-string input value will cause a type error.</li>
1817</ul>
1818</li>
1819<li>
1820
1821<p>Example:</p>
1822
1823<div>
1824<div>
1825<pre class="source">length(&quot;test string&quot;);
1826</pre></div></div>
1827</li>
1828<li>
1829
1830<p>The expected result is:</p>
1831
1832<div>
1833<div>
1834<pre class="source">11
1835</pre></div></div>
1836</li>
1837</ul></div>
1838<div class="section">
1839<h3><a name="lower"></a>lower</h3>
1840<ul>
1841
1842<li>
1843
1844<p>Syntax:</p>
1845
1846<div>
1847<div>
1848<pre class="source">lower(string)
1849</pre></div></div>
1850</li>
1851<li>
1852
1853<p>Converts a given string <tt>string</tt> to its lowercase form.</p>
1854</li>
1855<li>Arguments:
1856<ul>
1857
1858<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1859</ul>
1860</li>
1861<li>Return Value:
1862<ul>
1863
1864<li>a <tt>string</tt> as the lowercase form of the given <tt>string</tt>,</li>
1865<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1866<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1867<li>any other non-string input value will cause a type error.</li>
1868</ul>
1869</li>
1870<li>
1871
1872<p>Example:</p>
1873
1874<div>
1875<div>
1876<pre class="source">lower(&quot;ASTERIXDB&quot;);
1877</pre></div></div>
1878</li>
1879<li>
1880
1881<p>The expected result is:</p>
1882
1883<div>
1884<div>
1885<pre class="source">&quot;asterixdb&quot;
1886</pre></div></div>
1887</li>
1888</ul></div>
1889<div class="section">
1890<h3><a name="ltrim"></a>ltrim</h3>
1891<ul>
1892
1893<li>
1894
1895<p>Syntax:</p>
1896
1897<div>
1898<div>
1899<pre class="source">ltrim(string[, chars]);
1900</pre></div></div>
1901</li>
1902<li>
1903
1904<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.</p>
1905</li>
1906<li>Arguments:
1907<ul>
1908
1909<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
1910<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
1911</ul>
1912</li>
1913<li>Return Value:
1914<ul>
1915
1916<li>a trimmed, new <tt>string</tt>,</li>
1917<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1918<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1919<li>any other non-string input value will cause a type error.</li>
1920</ul>
1921</li>
1922<li>
1923
1924<p>Example:</p>
1925
1926<div>
1927<div>
1928<pre class="source">ltrim(&quot;me like x-phone&quot;, &quot;eml&quot;);
1929</pre></div></div>
1930</li>
1931<li>
1932
1933<p>The expected result is:</p>
1934
1935<div>
1936<div>
1937<pre class="source">&quot; like x-phone&quot;
1938</pre></div></div>
1939</li>
1940</ul></div>
1941<div class="section">
1942<h3><a name="position"></a>position</h3>
1943<ul>
1944
1945<li>
1946
1947<p>Syntax:</p>
1948
1949<div>
1950<div>
1951<pre class="source">position(string, string_pattern)
1952</pre></div></div>
1953</li>
1954<li>
1955
1956<p>Returns the first position of <tt>string_pattern</tt> 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>
1957</li>
1958<li>
1959
1960<p>Aliases:</p>
1961<ul>
1962
1963<li>0-based: <tt>position</tt>, <tt>pos</tt>, <tt>position0</tt>, <tt>pos0</tt>.</li>
1964<li>1-based: <tt>position1</tt>, <tt>pos1</tt>.</li>
1965</ul>
1966</li>
1967<li>
1968
1969<p>Arguments:</p>
1970<ul>
1971
1972<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
1973<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
1974</ul>
1975</li>
1976<li>Return Value:
1977<ul>
1978
1979<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>
1980<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1981<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1982<li>any other non-string input value will return a <tt>null</tt>.</li>
1983</ul>
1984</li>
1985<li>
1986
1987<p>Example:</p>
1988
1989<div>
1990<div>
1991<pre class="source">{
1992 &quot;v1&quot;: position(&quot;ppphonepp&quot;, &quot;phone&quot;),
1993 &quot;v2&quot;: position(&quot;hone&quot;, &quot;phone&quot;),
1994 &quot;v3&quot;: position1(&quot;ppphonepp&quot;, &quot;phone&quot;),
1995 &quot;v4&quot;: position1(&quot;hone&quot;, &quot;phone&quot;),
1996};
1997</pre></div></div>
1998</li>
1999<li>
2000
2001<p>The expected result is:</p>
2002
2003<div>
2004<div>
2005<pre class="source">{ &quot;v1&quot;: 2, &quot;v2&quot;: -1, v3&quot;: 3, &quot;v4&quot;: -1 }
2006</pre></div></div>
2007</li>
2008</ul></div>
2009<div class="section">
2010<h3><a name="regexp_contains"></a>regexp_contains</h3>
2011<ul>
2012
2013<li>
2014
2015<p>Syntax:</p>
2016
2017<div>
2018<div>
2019<pre class="source">regexp_contains(string, string_pattern[, string_flags])
2020</pre></div></div>
2021</li>
2022<li>
2023
2024<p>Checks whether the strings <tt>string</tt> contains the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2025</li>
2026<li>
2027
2028<p>Aliases:</p>
2029<ul>
2030
2031<li><tt>regexp_contains</tt>, <tt>regex_contains</tt>, <tt>contains_regexp</tt>, <tt>contains_regex</tt>.</li>
2032</ul>
2033</li>
2034<li>
2035
2036<p>Arguments:</p>
2037<ul>
2038
2039<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2040<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2041<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2042<ul>
2043
2044<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2045</ul>
2046</li>
2047</ul>
2048</li>
2049<li>Return Value:
2050<ul>
2051
2052<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>
2053<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2054<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2055<li>any other non-string input value will return a <tt>null</tt>.</li>
2056</ul>
2057</li>
2058<li>
2059
2060<p>Example:</p>
2061
2062<div>
2063<div>
2064<pre class="source">{
2065 &quot;v1&quot;: regexp_contains(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2066 &quot;v2&quot;: regexp_contains(&quot;hone&quot;, &quot;p+hone&quot;)
2067};
2068</pre></div></div>
2069</li>
2070<li>
2071
2072<p>The expected result is:</p>
2073
2074<div>
2075<div>
2076<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2077</pre></div></div>
2078</li>
2079</ul></div>
2080<div class="section">
2081<h3><a name="regexp_like"></a>regexp_like</h3>
2082<ul>
2083
2084<li>
2085
2086<p>Syntax:</p>
2087
2088<div>
2089<div>
2090<pre class="source">regexp_like(string, string_pattern[, string_flags])
2091</pre></div></div>
2092</li>
2093<li>
2094
2095<p>Checks whether the string <tt>string</tt> exactly matches the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2096</li>
2097<li>
2098
2099<p>Aliases:</p>
2100<ul>
2101
2102<li><tt>regexp_like</tt>, <tt>regex_like</tt>.</li>
2103</ul>
2104</li>
2105<li>
2106
2107<p>Arguments:</p>
2108<ul>
2109
2110<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2111<li><tt>string_pattern</tt> : a pattern <tt>string</tt> that might be contained.</li>
2112<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2113<ul>
2114
2115<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2116</ul>
2117</li>
2118</ul>
2119</li>
2120<li>Return Value:
2121<ul>
2122
2123<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>
2124<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2125<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2126<li>any other non-string input value will return a <tt>null</tt>.</li>
2127</ul>
2128</li>
2129<li>
2130
2131<p>Example:</p>
2132
2133<div>
2134<div>
2135<pre class="source">{
2136 &quot;v1&quot;: regexp_like(&quot; can't stand acast the network is horrible:(&quot;, &quot;.*acast.*&quot;),
2137 &quot;v2&quot;: regexp_like(&quot;acast&quot;, &quot;.*acst.*&quot;)
2138};
2139</pre></div></div>
2140</li>
2141<li>
2142
2143<p>The expected result is:</p>
2144
2145<div>
2146<div>
2147<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2148</pre></div></div>
2149</li>
2150</ul></div>
2151<div class="section">
2152<h3><a name="regexp_position"></a>regexp_position</h3>
2153<ul>
2154
2155<li>
2156
2157<p>Syntax:</p>
2158
2159<div>
2160<div>
2161<pre class="source">regexp_position(string, string_pattern[, string_flags])
2162</pre></div></div>
2163</li>
2164<li>
2165
2166<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>
2167</li>
2168<li>
2169
2170<p>Aliases:</p>
2171<ul>
2172
2173<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>
2174<li>1-Based: <tt>regexp_position1</tt>, <tt>regexp_pos1</tt>, <tt>regex_position1</tt> <tt>regex_pos1</tt>.</li>
2175</ul>
2176</li>
2177<li>
2178
2179<p>Arguments:</p>
2180<ul>
2181
2182<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2183<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2184<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2185<ul>
2186
2187<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2188</ul>
2189</li>
2190</ul>
2191</li>
2192<li>Return Value:
2193<ul>
2194
2195<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>
2196<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2197<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2198<li>any other non-string input value will return a <tt>null</tt>.</li>
2199</ul>
2200</li>
2201<li>
2202
2203<p>Example:</p>
2204
2205<div>
2206<div>
2207<pre class="source">{
2208 &quot;v1&quot;: regexp_position(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2209 &quot;v2&quot;: regexp_position(&quot;hone&quot;, &quot;p+hone&quot;),
2210 &quot;v3&quot;: regexp_position1(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2211 &quot;v4&quot;: regexp_position1(&quot;hone&quot;, &quot;p+hone&quot;)
2212};
2213</pre></div></div>
2214</li>
2215<li>
2216
2217<p>The expected result is:</p>
2218
2219<div>
2220<div>
2221<pre class="source">{ &quot;v1&quot;: 0, &quot;v2&quot;: -1, &quot;v3&quot;: 1, &quot;v4&quot;: -1 }
2222</pre></div></div>
2223</li>
2224</ul></div>
2225<div class="section">
2226<h3><a name="regexp_replace"></a>regexp_replace</h3>
2227<ul>
2228
2229<li>
2230
2231<p>Syntax:</p>
2232
2233<div>
2234<div>
2235<pre class="source">regexp_replace(string, string_pattern, string_replacement[, string_flags])
2236regexp_replace(string, string_pattern, string_replacement[, replacement_limit])
2237</pre></div></div>
2238</li>
2239<li>
2240
2241<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>
2242</li>
2243<li>
2244
2245<p>Aliases:</p>
2246<ul>
2247
2248<li><tt>regexp_replace</tt>, <tt>regex_replace</tt>.</li>
2249</ul>
2250</li>
2251<li>
2252
2253<p>Arguments:</p>
2254<ul>
2255
2256<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2257<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2258<li><tt>string_replacement</tt> : a pattern <tt>string</tt> to be used as the replacement.</li>
2259<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during replace.
2260<ul>
2261
2262<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2263</ul>
2264</li>
2265<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>
2266</ul>
2267</li>
2268<li>Return Value:
2269<ul>
2270
2271<li>Returns a <tt>string</tt> that is obtained after the replacements.</li>
2272<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2273<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2274<li>any other non-string input value will return a <tt>null</tt>.</li>
2275</ul>
2276</li>
2277<li>
2278
2279<p>Example:</p>
2280
2281<div>
2282<div>
2283<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;);
2284</pre></div></div>
2285</li>
2286<li>
2287
2288<p>The expected result is:</p>
2289
2290<div>
2291<div>
2292<pre class="source">&quot;like product-a the voicemail_service is awesome&quot;
2293</pre></div></div>
2294</li>
2295</ul></div>
2296<div class="section">
2297<h3><a name="repeat"></a>repeat</h3>
2298<ul>
2299
2300<li>
2301
2302<p>Syntax:</p>
2303
2304<div>
2305<div>
2306<pre class="source">repeat(string, n)
2307</pre></div></div>
2308</li>
2309<li>
2310
2311<p>Returns a string formed by repeating the input <tt>string</tt> <tt>n</tt> times.</p>
2312</li>
2313<li>Arguments:
2314<ul>
2315
2316<li><tt>string</tt> : a <tt>string</tt> to be repeated,</li>
2317<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>
2318</ul>
2319</li>
2320<li>Return Value:
2321<ul>
2322
2323<li>a string that repeats the input <tt>string</tt> <tt>n</tt> times,</li>
2324<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2325<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2326<li>a type error will be raised if:
2327<ul>
2328
2329<li>the first argument is any other non-string value,</li>
2330<li>or, the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2331</ul>
2332</li>
2333</ul>
2334</li>
2335<li>
2336
2337<p>Example:</p>
2338
2339<div>
2340<div>
2341<pre class="source">repeat(&quot;test&quot;, 3);
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;testtesttest&quot;
2351</pre></div></div>
2352</li>
2353</ul></div>
2354<div class="section">
2355<h3><a name="replace"></a>replace</h3>
2356<ul>
2357
2358<li>
2359
2360<p>Syntax:</p>
2361
2362<div>
2363<div>
2364<pre class="source">replace(string, search_string, replacement_string[, limit])
2365</pre></div></div>
2366</li>
2367<li>
2368
2369<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>
2370</li>
2371<li>Arguments:
2372<ul>
2373
2374<li><tt>string</tt> : an input <tt>string</tt>,</li>
2375<li><tt>search_string</tt> : a <tt>string</tt> substring to be searched for,</li>
2376<li><tt>replacement_string</tt> : a <tt>string</tt> to be used as the replacement,</li>
2377<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>
2378</ul>
2379</li>
2380<li>Return Value:
2381<ul>
2382
2383<li>Returns a <tt>string</tt> that is obtained after the replacements,</li>
2384<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2385<li>any other non-string input value or non-integer <tt>limit</tt> will cause a type error,</li>
2386<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2387</ul>
2388</li>
2389<li>
2390
2391<p>Example:</p>
2392
2393<div>
2394<div>
2395<pre class="source">{
2396 &quot;v1&quot;: replace(&quot; like x-phone the voicemail_service is awesome&quot;, &quot; like x-phone&quot;, &quot;like product-a&quot;),
2397 &quot;v2&quot;: replace(&quot;x-phone and x-phone&quot;, &quot;x-phone&quot;, &quot;product-a&quot;, 1)
2398};
2399</pre></div></div>
2400</li>
2401<li>
2402
2403<p>The expected result is:</p>
2404
2405<div>
2406<div>
2407<pre class="source">{
2408 &quot;v1&quot;: &quot;like product-a the voicemail_service is awesome&quot;,
2409 &quot;v2&quot;: &quot;product-a and x-phone&quot;
2410}
2411</pre></div></div>
2412</li>
2413</ul></div>
2414<div class="section">
2415<h3><a name="reverse"></a>reverse</h3>
2416<ul>
2417
2418<li>
2419
2420<p>Syntax:</p>
2421
2422<div>
2423<div>
2424<pre class="source">reverse(string)
2425</pre></div></div>
2426</li>
2427<li>
2428
2429<p>Returns a string formed by reversing characters in the input <tt>string</tt>.</p>
2430</li>
2431<li>Arguments:
2432<ul>
2433
2434<li><tt>string</tt> : a <tt>string</tt> to be reversed</li>
2435</ul>
2436</li>
2437<li>Return Value:
2438<ul>
2439
2440<li>a string containing characters from the the input <tt>string</tt> in the reverse order,</li>
2441<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2442<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2443<li>a type error will be raised if:
2444<ul>
2445
2446<li>the first argument is any other non-string value</li>
2447</ul>
2448</li>
2449</ul>
2450</li>
2451<li>
2452
2453<p>Example:</p>
2454
2455<div>
2456<div>
2457<pre class="source">reverse(&quot;hello&quot;);
2458</pre></div></div>
2459</li>
2460<li>
2461
2462<p>The expected result is:</p>
2463
2464<div>
2465<div>
2466<pre class="source">&quot;olleh&quot;
2467</pre></div></div>
2468</li>
2469</ul></div>
2470<div class="section">
2471<h3><a name="rtrim"></a>rtrim</h3>
2472<ul>
2473
2474<li>
2475
2476<p>Syntax:</p>
2477
2478<div>
2479<div>
2480<pre class="source">rtrim(string[, chars]);
2481</pre></div></div>
2482</li>
2483<li>
2484
2485<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.</p>
2486</li>
2487<li>Arguments:
2488<ul>
2489
2490<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2491<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2492</ul>
2493</li>
2494<li>Return Value:
2495<ul>
2496
2497<li>a trimmed, new <tt>string</tt>,</li>
2498<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2499<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2500<li>any other non-string input value will cause a type error.</li>
2501</ul>
2502</li>
2503<li>
2504
2505<p>Example:</p>
2506
2507<div>
2508<div>
2509<pre class="source">{
2510 &quot;v1&quot;: rtrim(&quot;i like x-phone&quot;, &quot;x-phone&quot;),
2511 &quot;v2&quot;: rtrim(&quot;i like x-phone&quot;, &quot;onexph&quot;)
2512};
2513</pre></div></div>
2514</li>
2515<li>
2516
2517<p>The expected result is:</p>
2518
2519<div>
2520<div>
2521<pre class="source">{ &quot;v1&quot;: &quot;i like &quot;, &quot;v2&quot;: &quot;i like &quot; }
2522</pre></div></div>
2523</li>
2524</ul></div>
2525<div class="section">
2526<h3><a name="split"></a>split</h3>
2527<ul>
2528
2529<li>
2530
2531<p>Syntax:</p>
2532
2533<div>
2534<div>
2535<pre class="source">split(string, sep)
2536</pre></div></div>
2537</li>
2538<li>
2539
2540<p>Splits the input <tt>string</tt> into an array of substrings separated by the string <tt>sep</tt>.</p>
2541</li>
2542<li>Arguments:
2543<ul>
2544
2545<li><tt>string</tt> : a <tt>string</tt> to be split.</li>
2546</ul>
2547</li>
2548<li>Return Value:
2549<ul>
2550
2551<li>an array of substrings by splitting the input <tt>string</tt> by <tt>sep</tt>,</li>
2552<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2553<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2554<li>any other non-string input value will cause a type error.</li>
2555</ul>
2556</li>
2557<li>
2558
2559<p>Example:</p>
2560
2561<div>
2562<div>
2563<pre class="source">split(&quot;test driven development&quot;, &quot; &quot;);
2564</pre></div></div>
2565</li>
2566<li>
2567
2568<p>The expected result is:</p>
2569
2570<div>
2571<div>
2572<pre class="source">[ &quot;test&quot;, &quot;driven&quot;, &quot;development&quot; ]
2573</pre></div></div>
2574</li>
2575</ul></div>
2576<div class="section">
2577<h3><a name="starts_with"></a>starts_with</h3>
2578<ul>
2579
2580<li>
2581
2582<p>Syntax:</p>
2583
2584<div>
2585<div>
2586<pre class="source">starts_with(string, substring_to_start_with)
2587</pre></div></div>
2588</li>
2589<li>
2590
2591<p>Checks whether the string <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>.</p>
2592</li>
2593<li>Arguments:
2594<ul>
2595
2596<li><tt>string</tt> : a <tt>string</tt> that might start with the given string.</li>
2597<li><tt>substring_to_start_with</tt> : a <tt>string</tt> that might be contained as the starting substring.</li>
2598</ul>
2599</li>
2600<li>Return Value:
2601<ul>
2602
2603<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>,</li>
2604<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2605<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2606<li>any other non-string input value will cause a type error,</li>
2607<li><tt>false</tt> otherwise.</li>
2608</ul>
2609</li>
2610<li>
2611
2612<p>Example:</p>
2613
2614<div>
2615<div>
2616<pre class="source">{
2617 &quot;v1&quot; : starts_with(&quot; like the plan, amazing&quot;, &quot; like&quot;),
2618 &quot;v2&quot; : starts_with(&quot;I like the plan, amazing&quot;, &quot; like&quot;)
2619};
2620</pre></div></div>
2621</li>
2622<li>
2623
2624<p>The expected result is:</p>
2625
2626<div>
2627<div>
2628<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2629</pre></div></div>
2630</li>
2631</ul></div>
2632<div class="section">
2633<h3><a name="substr"></a>substr</h3>
2634<ul>
2635
2636<li>
2637
2638<p>Syntax:</p>
2639
2640<div>
2641<div>
2642<pre class="source">substr(string, offset[, length])
2643</pre></div></div>
2644</li>
2645<li>
2646
2647<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>. 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>
2648</li>
2649<li>
2650
2651<p>Aliases:</p>
2652<ul>
2653
2654<li>0-Based: <tt>substring</tt>, <tt>substr</tt>, <tt>substring0</tt>, <tt>substr0</tt>.</li>
2655<li>1-Based: <tt>substring1</tt>, <tt>substr1</tt>.</li>
2656</ul>
2657</li>
2658<li>
2659
2660<p>Arguments:</p>
2661<ul>
2662
2663<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
2664<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>
2665<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>
2666</ul>
2667</li>
2668<li>Return Value:
2669<ul>
2670
2671<li>a <tt>string</tt> that represents the substring,</li>
2672<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2673<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>
2674<li>a <tt>null</tt> will be returned if:
2675<ul>
2676
2677<li>the first argument is any other non-string value.</li>
2678<li>the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2679<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>
2680</ul>
2681</li>
2682</ul>
2683</li>
2684<li>
2685
2686<p>Example:</p>
2687
2688<div>
2689<div>
2690<pre class="source">{ &quot;v1&quot;: substr(&quot;test string&quot;, 6, 3), &quot;v2&quot;: substr1(&quot;test string&quot;, 6, 3) };
2691</pre></div></div>
2692</li>
2693<li>
2694
2695<p>The expected result is:</p>
2696
2697<div>
2698<div>
2699<pre class="source">{ &quot;v1&quot;: &quot;tri&quot;, &quot;v2&quot;: &quot;str&quot; }
2700</pre></div></div>
2701</li>
2702</ul>
2703<p>The function has an alias <tt>substring</tt>.</p></div>
2704<div class="section">
2705<h3><a name="trim"></a>trim</h3>
2706<ul>
2707
2708<li>
2709
2710<p>Syntax:</p>
2711
2712<div>
2713<div>
2714<pre class="source">trim(string[, chars]);
2715</pre></div></div>
2716</li>
2717<li>
2718
2719<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.</p>
2720</li>
2721<li>Arguments:
2722<ul>
2723
2724<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2725<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2726</ul>
2727</li>
2728<li>Return Value:
2729<ul>
2730
2731<li>a trimmed, new <tt>string</tt>,</li>
2732<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2733<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2734<li>any other non-string input value will cause a type error.</li>
2735</ul>
2736</li>
2737<li>
2738
2739<p>Example:</p>
2740
2741<div>
2742<div>
2743<pre class="source">trim(&quot;i like x-phone&quot;, &quot;xphoen&quot;);
2744</pre></div></div>
2745</li>
2746<li>
2747
2748<p>The expected result is:</p>
2749
2750<div>
2751<div>
2752<pre class="source">&quot; like &quot;
2753</pre></div></div>
2754</li>
2755</ul></div>
2756<div class="section">
2757<h3><a name="upper"></a>upper</h3>
2758<ul>
2759
2760<li>
2761
2762<p>Syntax:</p>
2763
2764<div>
2765<div>
2766<pre class="source">upper(string)
2767</pre></div></div>
2768</li>
2769<li>
2770
2771<p>Converts a given string <tt>string</tt> to its uppercase form.</p>
2772</li>
2773<li>Arguments:
2774<ul>
2775
2776<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
2777</ul>
2778</li>
2779<li>Return Value:
2780<ul>
2781
2782<li>a <tt>string</tt> as the uppercase form of the given <tt>string</tt>,</li>
2783<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2784<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2785<li>any other non-string input value will cause a type error.</li>
2786</ul>
2787</li>
2788<li>
2789
2790<p>Example:</p>
2791
2792<div>
2793<div>
2794<pre class="source">upper(&quot;hello&quot;)
2795</pre></div></div>
2796</li>
2797<li>
2798
2799<p>The expected result is:</p>
2800
2801<div>
2802<div>
2803<pre class="source">&quot;HELLO&quot;
2804</pre></div></div>
2805</li>
2806</ul><!--
2807 ! Licensed to the Apache Software Foundation (ASF) under one
2808 ! or more contributor license agreements. See the NOTICE file
2809 ! distributed with this work for additional information
2810 ! regarding copyright ownership. The ASF licenses this file
2811 ! to you under the Apache License, Version 2.0 (the
2812 ! "License"); you may not use this file except in compliance
2813 ! with the License. You may obtain a copy of the License at
2814 !
2815 ! http://www.apache.org/licenses/LICENSE-2.0
2816 !
2817 ! Unless required by applicable law or agreed to in writing,
2818 ! software distributed under the License is distributed on an
2819 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2820 ! KIND, either express or implied. See the License for the
2821 ! specific language governing permissions and limitations
2822 ! under the License.
2823 !-->
2824</div>
2825<div class="section">
2826<h3><a name="string_concat"></a>string_concat</h3>
2827<ul>
2828
2829<li>
2830
2831<p>Syntax:</p>
2832
2833<div>
2834<div>
2835<pre class="source">string_concat(array)
2836</pre></div></div>
2837</li>
2838<li>
2839
2840<p>Concatenates an array of strings <tt>array</tt> into a single string.</p>
2841</li>
2842<li>Arguments:
2843<ul>
2844
2845<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>
2846</ul>
2847</li>
2848<li>Return Value:
2849<ul>
2850
2851<li>the concatenated <tt>string</tt> value,</li>
2852<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2853<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2854<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
2855<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>
2856<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
2857</ul>
2858</li>
2859<li>
2860
2861<p>Example:</p>
2862
2863<div>
2864<div>
2865<pre class="source">string_concat([&quot;ASTERIX&quot;, &quot; &quot;, &quot;ROCKS!&quot;]);
2866</pre></div></div>
2867</li>
2868<li>
2869
2870<p>The expected result is:</p>
2871
2872<div>
2873<div>
2874<pre class="source">&quot;ASTERIX ROCKS!&quot;
2875</pre></div></div>
2876</li>
2877</ul></div>
2878<div class="section">
2879<h3><a name="string_join"></a>string_join</h3>
2880<ul>
2881
2882<li>
2883
2884<p>Syntax:</p>
2885
2886<div>
2887<div>
2888<pre class="source">string_join(array, string)
2889</pre></div></div>
2890</li>
2891<li>
2892
2893<p>Joins an array or multiset of strings <tt>array</tt> with the given separator <tt>string</tt> into a single string.</p>
2894</li>
2895<li>Arguments:
2896<ul>
2897
2898<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of strings (could be <tt>null</tt>) to be joined.</li>
2899<li><tt>string</tt> : a <tt>string</tt> to serve as the separator.</li>
2900</ul>
2901</li>
2902<li>Return Value:
2903<ul>
2904
2905<li>the joined <tt>string</tt>,</li>
2906<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2907<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2908<li><tt>missing</tt> if the first argument array contains a <tt>missing</tt>,</li>
2909<li><tt>null</tt> if the first argument array contains a <tt>null</tt> but does not contain a <tt>missing</tt>,</li>
2910<li>a type error will be raised if:
2911<ul>
2912
2913<li>the first argument is any other non-array value, or contains any other non-string value,</li>
2914<li>or, the second argument is any other non-string value.</li>
2915</ul>
2916</li>
2917</ul>
2918</li>
2919<li>
2920
2921<p>Example:</p>
2922
2923<div>
2924<div>
2925<pre class="source">string_join([&quot;ASTERIX&quot;, &quot;ROCKS~&quot;], &quot;!! &quot;);
2926</pre></div></div>
2927</li>
2928<li>
2929
2930<p>The expected result is:</p>
2931
2932<div>
2933<div>
2934<pre class="source">&quot;ASTERIX!! ROCKS~&quot;
2935</pre></div></div>
2936</li>
2937</ul></div>
2938<div class="section">
2939<h3><a name="string_to_codepoint"></a>string_to_codepoint</h3>
2940<ul>
2941
2942<li>
2943
2944<p>Syntax:</p>
2945
2946<div>
2947<div>
2948<pre class="source">string_to_codepoint(string)
2949</pre></div></div>
2950</li>
2951<li>
2952
2953<p>Converts the string <tt>string</tt> to its code_based representation.</p>
2954</li>
2955<li>Arguments:
2956<ul>
2957
2958<li><tt>string</tt> : a <tt>string</tt> that will be converted.</li>
2959</ul>
2960</li>
2961<li>Return Value:
2962<ul>
2963
2964<li>an <tt>array</tt> of the code points for the string <tt>string</tt>,</li>
2965<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2966<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2967<li>any other non-string input value will cause a type error.</li>
2968</ul>
2969</li>
2970<li>
2971
2972<p>Example:</p>
2973
2974<div>
2975<div>
2976<pre class="source">string_to_codepoint(&quot;Hello ASTERIX!&quot;);
2977</pre></div></div>
2978</li>
2979<li>
2980
2981<p>The expected result is:</p>
2982
2983<div>
2984<div>
2985<pre class="source">[ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ]
2986</pre></div></div>
2987</li>
2988</ul></div>
2989<div class="section">
2990<h3><a name="codepoint_to_string"></a>codepoint_to_string</h3>
2991<ul>
2992
2993<li>
2994
2995<p>Syntax:</p>
2996
2997<div>
2998<div>
2999<pre class="source">codepoint_to_string(array)
3000</pre></div></div>
3001</li>
3002<li>
3003
3004<p>Converts the ordered code_based representation <tt>array</tt> to the corresponding string.</p>
3005</li>
3006<li>Arguments:
3007<ul>
3008
3009<li><tt>array</tt> : an <tt>array</tt> of integer code_points.</li>
3010</ul>
3011</li>
3012<li>Return Value:
3013<ul>
3014
3015<li>a <tt>string</tt> representation of <tt>array</tt>.</li>
3016<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3017<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3018<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3019<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>
3020<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
3021</ul>
3022</li>
3023<li>
3024
3025<p>Example:</p>
3026
3027<div>
3028<div>
3029<pre class="source">codepoint_to_string([72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33]);
3030</pre></div></div>
3031</li>
3032<li>
3033
3034<p>The expected result is:</p>
3035
3036<div>
3037<div>
3038<pre class="source">&quot;Hello ASTERIX!&quot;
3039</pre></div></div>
3040</li>
3041</ul></div>
3042<div class="section">
3043<h3><a name="substring_before"></a>substring_before</h3>
3044<ul>
3045
3046<li>
3047
3048<p>Syntax:</p>
3049
3050<div>
3051<div>
3052<pre class="source">substring_before(string, string_pattern)
3053</pre></div></div>
3054</li>
3055<li>
3056
3057<p>Returns the substring from the given string <tt>string</tt> before the given pattern <tt>string_pattern</tt>.</p>
3058</li>
3059<li>Arguments:
3060<ul>
3061
3062<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3063<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3064</ul>
3065</li>
3066<li>Return Value:
3067<ul>
3068
3069<li>a <tt>string</tt> that represents the substring,</li>
3070<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3071<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3072<li>any other non-string input value will cause a type error.</li>
3073</ul>
3074</li>
3075<li>
3076
3077<p>Example:</p>
3078
3079<div>
3080<div>
3081<pre class="source">substring_before(&quot; like x-phone&quot;, &quot;x-phone&quot;);
3082</pre></div></div>
3083</li>
3084<li>
3085
3086<p>The expected result is:</p>
3087
3088<div>
3089<div>
3090<pre class="source">&quot; like &quot;
3091</pre></div></div>
3092</li>
3093</ul></div>
3094<div class="section">
3095<h3><a name="substring_after"></a>substring_after</h3>
3096<ul>
3097
3098<li>
3099
3100<p>Syntax:</p>
3101<p>substring_after(string, string_pattern);</p>
3102</li>
3103<li>
3104
3105<p>Returns the substring from the given string <tt>string</tt> after the given pattern <tt>string_pattern</tt>.</p>
3106</li>
3107<li>Arguments:
3108<ul>
3109
3110<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3111<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3112</ul>
3113</li>
3114<li>Return Value:
3115<ul>
3116
3117<li>a <tt>string</tt> that represents the substring,</li>
3118<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3119<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3120<li>any other non-string input value will cause a type error.</li>
3121</ul>
3122</li>
3123<li>
3124
3125<p>Example:</p>
3126
3127<div>
3128<div>
3129<pre class="source">substring_after(&quot; like x-phone&quot;, &quot;xph&quot;);
3130</pre></div></div>
3131</li>
3132<li>
3133
3134<p>The expected result is:</p>
3135
3136<div>
3137<div>
3138<pre class="source">&quot;one&quot;
3139</pre></div></div>
3140</li>
3141</ul><!--
3142 ! Licensed to the Apache Software Foundation (ASF) under one
3143 ! or more contributor license agreements. See the NOTICE file
3144 ! distributed with this work for additional information
3145 ! regarding copyright ownership. The ASF licenses this file
3146 ! to you under the Apache License, Version 2.0 (the
3147 ! "License"); you may not use this file except in compliance
3148 ! with the License. You may obtain a copy of the License at
3149 !
3150 ! http://www.apache.org/licenses/LICENSE-2.0
3151 !
3152 ! Unless required by applicable law or agreed to in writing,
3153 ! software distributed under the License is distributed on an
3154 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3155 ! KIND, either express or implied. See the License for the
3156 ! specific language governing permissions and limitations
3157 ! under the License.
3158 !-->
3159</div></div>
3160<div class="section">
3161<h2><a name="Binary_Functions"></a><a name="BinaryFunctions" id="BinaryFunctions">Binary Functions</a></h2>
3162<div class="section">
3163<h3><a name="parse_binary"></a>parse_binary</h3>
3164<ul>
3165
3166<li>
3167
3168<p>Syntax:</p>
3169<p>parse_binary(string, encoding)</p>
3170</li>
3171<li>
3172
3173<p>Creates a <tt>binary</tt> from an string encoded in <tt>encoding</tt> format.</p>
3174</li>
3175<li>Arguments:
3176<ul>
3177
3178<li><tt>string</tt> : an encoded <tt>string</tt>,</li>
3179<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>
3180</ul>
3181</li>
3182<li>Return Value:
3183<ul>
3184
3185<li>a <tt>binary</tt> that is decoded from the given <tt>string</tt>,</li>
3186<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3187<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3188<li>any other non-string input value will cause a type error.</li>
3189</ul>
3190</li>
3191<li>
3192
3193<p>Example:</p>
3194<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>
3195</li>
3196<li>
3197
3198<p>The expected result is:</p>
3199<p>[ hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;4173746572697801&#x201d;) ]</p>
3200</li>
3201</ul></div>
3202<div class="section">
3203<h3><a name="print_binary"></a>print_binary</h3>
3204<ul>
3205
3206<li>
3207
3208<p>Syntax:</p>
3209<p>print_binary(binary, encoding)</p>
3210</li>
3211<li>
3212
3213<p>Prints a <tt>binary</tt> to the required encoding <tt>string</tt> format.</p>
3214</li>
3215<li>Arguments:
3216<ul>
3217
3218<li><tt>binary</tt> : a <tt>binary</tt> data need to be printed.</li>
3219<li><tt>encoding</tt> : a string notation specifies the expected encoding type. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
3220</ul>
3221</li>
3222<li>Return Value:
3223<ul>
3224
3225<li>a <tt>string</tt> that represents the encoded format of a <tt>binary</tt>,</li>
3226<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3227<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3228<li>any other non-string input value will cause a type error.</li>
3229</ul>
3230</li>
3231<li>
3232
3233<p>Example:</p>
3234
3235<div>
3236<div>
3237<pre class="source">[ print_binary(hex(&quot;ABCDEF0123456789&quot;), &quot;base64&quot;), print_binary(base64(&quot;q83vASNFZ4k=&quot;), &quot;hex&quot;) ]
3238</pre></div></div>
3239</li>
3240<li>
3241
3242<p>The expected result are:</p>
3243
3244<div>
3245<div>
3246<pre class="source">[ &quot;q83vASNFZ4k=&quot;, &quot;ABCDEF0123456789&quot; ]
3247</pre></div></div>
3248</li>
3249</ul></div>
3250<div class="section">
3251<h3><a name="binary_length"></a>binary_length</h3>
3252<ul>
3253
3254<li>
3255
3256<p>Syntax:</p>
3257<p>binary_length(binary)</p>
3258</li>
3259<li>
3260
3261<p>Returns the number of bytes storing the binary data.</p>
3262</li>
3263<li>Arguments:
3264<ul>
3265
3266<li><tt>binary</tt> : a <tt>binary</tt> value to be checked.</li>
3267</ul>
3268</li>
3269<li>Return Value:
3270<ul>
3271
3272<li>an <tt>bigint</tt> that represents the number of bytes,</li>
3273<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3274<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3275<li>any other non-binary input value will cause a type error.</li>
3276</ul>
3277</li>
3278<li>
3279
3280<p>Example:</p>
3281
3282<div>
3283<div>
3284<pre class="source">binary_length(hex(&quot;00AA&quot;))
3285</pre></div></div>
3286</li>
3287<li>
3288
3289<p>The expected result is:</p>
3290<p>2</p>
3291</li>
3292</ul></div>
3293<div class="section">
3294<h3><a name="sub_binary"></a>sub_binary</h3>
3295<ul>
3296
3297<li>
3298
3299<p>Syntax:</p>
3300<p>sub_binary(binary, offset[, length])</p>
3301</li>
3302<li>
3303
3304<p>Returns the sub binary from the given <tt>binary</tt> based on the given start offset with the optional <tt>length</tt>.</p>
3305</li>
3306<li>Arguments:
3307<ul>
3308
3309<li><tt>binary</tt> : a <tt>binary</tt> to be extracted,</li>
3310<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>
3311<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>
3312</ul>
3313</li>
3314<li>Return Value:
3315<ul>
3316
3317<li>a <tt>binary</tt> that represents the sub binary,</li>
3318<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3319<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3320<li>a type error will be raised if:
3321<ul>
3322
3323<li>the first argument is any other non-binary value,</li>
3324<li>or, the second argument is any other non-integer value,</li>
3325<li>or, the third argument is any other non-integer value, if it is present.</li>
3326</ul>
3327</li>
3328</ul>
3329</li>
3330<li>
3331
3332<p>Example:</p>
3333
3334<div>
3335<div>
3336<pre class="source">sub_binary(hex(&quot;AABBCCDD&quot;), 4);
3337</pre></div></div>
3338</li>
3339<li>
3340
3341<p>The expected result is</p>
3342
3343<div>
3344<div>
3345<pre class="source">hex(&quot;DD&quot;)
3346</pre></div></div>
3347</li>
3348</ul></div>
3349<div class="section">
3350<h3><a name="binary_concat"></a>binary_concat</h3>
3351<ul>
3352
3353<li>
3354
3355<p>Syntax:</p>
3356<p>binary_concat(array)</p>
3357</li>
3358<li>
3359
3360<p>Concatenates a binary <tt>array</tt> or <tt>multiset</tt> into a single binary.</p>
3361</li>
3362<li>Arguments:
3363<ul>
3364
3365<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>
3366</ul>
3367</li>
3368<li>Return Value :
3369<ul>
3370
3371<li>the concatenated <tt>binary</tt> value,</li>
3372<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3373<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3374<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3375<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>
3376<li>any other non-array input value or non-binary element in the input array will cause a type error.</li>
3377</ul>
3378</li>
3379<li>
3380
3381<p>Example:</p>
3382<p>binary_concat([hex(&#x201c;42&#x201d;), hex(&quot;&quot;), hex(&#x2018;42&#x2019;)]);</p>
3383</li>
3384<li>
3385
3386<p>The expected result is</p>
3387<p>hex(&#x201c;4242&#x201d;)</p>
3388</li>
3389</ul><!--
3390 ! Licensed to the Apache Software Foundation (ASF) under one
3391 ! or more contributor license agreements. See the NOTICE file
3392 ! distributed with this work for additional information
3393 ! regarding copyright ownership. The ASF licenses this file
3394 ! to you under the Apache License, Version 2.0 (the
3395 ! "License"); you may not use this file except in compliance
3396 ! with the License. You may obtain a copy of the License at
3397 !
3398 ! http://www.apache.org/licenses/LICENSE-2.0
3399 !
3400 ! Unless required by applicable law or agreed to in writing,
3401 ! software distributed under the License is distributed on an
3402 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3403 ! KIND, either express or implied. See the License for the
3404 ! specific language governing permissions and limitations
3405 ! under the License.
3406 !-->
3407</div></div>
3408<div class="section">
3409<h2><a name="Spatial_Functions"></a><a name="SpatialFunctions" id="SpatialFunctions">Spatial Functions</a></h2>
3410<div class="section">
3411<h3><a name="create_point"></a>create_point</h3>
3412<ul>
3413
3414<li>
3415
3416<p>Syntax:</p>
3417
3418<div>
3419<div>
3420<pre class="source">create_point(x, y)
3421</pre></div></div>
3422</li>
3423<li>
3424
3425<p>Creates the primitive type <tt>point</tt> using an <tt>x</tt> and <tt>y</tt> value.</p>
3426</li>
3427<li>Arguments:</li>
3428<li><tt>x</tt> : a <tt>double</tt> that represents the x-coordinate,</li>
3429<li><tt>y</tt> : a <tt>double</tt> that represents the y-coordinate.</li>
3430<li>Return Value:</li>
3431<li>a <tt>point</tt> representing the ordered pair (<tt>x</tt>, <tt>y</tt>),</li>
3432<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3433<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3434<li>any other non-double input value will cause a type error.</li>
3435<li>
3436
3437<p>Example:</p>
3438
3439<div>
3440<div>
3441<pre class="source">{ &quot;point&quot;: create_point(30.0,70.0) };
3442</pre></div></div>
3443</li>
3444<li>
3445
3446<p>The expected result is:</p>
3447
3448<div>
3449<div>
3450<pre class="source">{ &quot;point&quot;: point(&quot;30.0,70.0&quot;) }
3451</pre></div></div>
3452</li>
3453</ul></div>
3454<div class="section">
3455<h3><a name="create_line"></a>create_line</h3>
3456<ul>
3457
3458<li>
3459
3460<p>Syntax:</p>
3461
3462<div>
3463<div>
3464<pre class="source">create_line(point1, point2)
3465</pre></div></div>
3466</li>
3467<li>
3468
3469<p>Creates the primitive type <tt>line</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3470</li>
3471<li>Arguments:
3472<ul>
3473
3474<li><tt>point1</tt> : a <tt>point</tt> that represents the start point of the line.</li>
3475<li><tt>point2</tt> : a <tt>point</tt> that represents the end point of the line.</li>
3476</ul>
3477</li>
3478<li>Return Value:
3479<ul>
3480
3481<li>a spatial <tt>line</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3482<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3483<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3484<li>any other non-point input value will cause a type error.</li>
3485</ul>
3486</li>
3487<li>
3488
3489<p>Example:</p>
3490
3491<div>
3492<div>
3493<pre class="source">{ &quot;line&quot;: create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
3494</pre></div></div>
3495</li>
3496<li>
3497
3498<p>The expected result is:</p>
3499
3500<div>
3501<div>
3502<pre class="source">{ &quot;line&quot;: line(&quot;30.0,70.0 50.0,90.0&quot;) }
3503</pre></div></div>
3504</li>
3505</ul></div>
3506<div class="section">
3507<h3><a name="create_rectangle"></a>create_rectangle</h3>
3508<ul>
3509
3510<li>
3511
3512<p>Syntax:</p>
3513
3514<div>
3515<div>
3516<pre class="source">create_rectangle(point1, point2)
3517</pre></div></div>
3518</li>
3519<li>
3520
3521<p>Creates the primitive type <tt>rectangle</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3522</li>
3523<li>Arguments:
3524<ul>
3525
3526<li><tt>point1</tt> : a <tt>point</tt> that represents the lower_left point of the rectangle.</li>
3527<li><tt>point2</tt> : a <tt>point</tt> that represents the upper_right point of the rectangle.</li>
3528</ul>
3529</li>
3530<li>Return Value:
3531<ul>
3532
3533<li>a spatial <tt>rectangle</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3534<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3535<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3536<li>any other non-point input value will cause a type error.</li>
3537</ul>
3538</li>
3539<li>
3540
3541<p>Example:</p>
3542
3543<div>
3544<div>
3545<pre class="source">{ &quot;rectangle&quot;: create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
3546</pre></div></div>
3547</li>
3548<li>
3549
3550<p>The expected result is:</p>
3551
3552<div>
3553<div>
3554<pre class="source">{ &quot;rectangle&quot;: rectangle(&quot;30.0,70.0 50.0,90.0&quot;) }
3555</pre></div></div>
3556</li>
3557</ul></div>
3558<div class="section">
3559<h3><a name="create_circle"></a>create_circle</h3>
3560<ul>
3561
3562<li>
3563
3564<p>Syntax:</p>
3565
3566<div>
3567<div>
3568<pre class="source">create_circle(point, radius)
3569</pre></div></div>
3570</li>
3571<li>
3572
3573<p>Creates the primitive type <tt>circle</tt> using <tt>point</tt> and <tt>radius</tt>.</p>
3574</li>
3575<li>Arguments:
3576<ul>
3577
3578<li><tt>point</tt> : a <tt>point</tt> that represents the center of the circle.</li>
3579<li><tt>radius</tt> : a <tt>double</tt> that represents the radius of the circle.</li>
3580</ul>
3581</li>
3582<li>Return Value:
3583<ul>
3584
3585<li>a spatial <tt>circle</tt> created using the center point and the radius provided in <tt>point</tt> and <tt>radius</tt>.</li>
3586<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3587<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3588<li>a type error will be raised if:
3589<ul>
3590
3591<li>the first argument is any other non-point value,</li>
3592<li>or, the second argument is any other non-double value.</li>
3593</ul>
3594</li>
3595</ul>
3596</li>
3597<li>
3598
3599<p>Example:</p>
3600
3601<div>
3602<div>
3603<pre class="source">{ &quot;circle&quot;: create_circle(create_point(30.0,70.0), 5.0) }
3604</pre></div></div>
3605</li>
3606<li>
3607
3608<p>The expected result is:</p>
3609
3610<div>
3611<div>
3612<pre class="source">{ &quot;circle&quot;: circle(&quot;30.0,70.0 5.0&quot;) }
3613</pre></div></div>
3614</li>
3615</ul></div>
3616<div class="section">
3617<h3><a name="create_polygon"></a>create_polygon</h3>
3618<ul>
3619
3620<li>
3621
3622<p>Syntax:</p>
3623
3624<div>
3625<div>
3626<pre class="source">create_polygon(array)
3627</pre></div></div>
3628</li>
3629<li>
3630
3631<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>
3632</li>
3633<li>Arguments:
3634<ul>
3635
3636<li><tt>array</tt> : an array of doubles representing the points of the polygon.</li>
3637</ul>
3638</li>
3639<li>Return Value:
3640<ul>
3641
3642<li>a <tt>polygon</tt>, represents a spatial simple polygon created using the points provided in <tt>array</tt>.</li>
3643<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3644<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3645<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3646<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>
3647<li>any other non-array input value or non-double element in the input array will cause a type error.</li>
3648</ul>
3649</li>
3650<li>
3651
3652<p>Example:</p>
3653
3654<div>
3655<div>
3656<pre class="source">{ &quot;polygon&quot;: create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
3657</pre></div></div>
3658</li>
3659<li>
3660
3661<p>The expected result is:</p>
3662
3663<div>
3664<div>
3665<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;) }
3666</pre></div></div>
3667</li>
3668</ul></div>
3669<div class="section">
3670<h3><a name="get_x.2Fget_y"></a>get_x/get_y</h3>
3671<ul>
3672
3673<li>
3674
3675<p>Syntax:</p>
3676
3677<div>
3678<div>
3679<pre class="source">get_x(point) or get_y(point)
3680</pre></div></div>
3681</li>
3682<li>
3683
3684<p>Returns the x or y coordinates of a point <tt>point</tt>.</p>
3685</li>
3686<li>Arguments:
3687<ul>
3688
3689<li><tt>point</tt> : a <tt>point</tt>.</li>
3690</ul>
3691</li>
3692<li>Return Value:
3693<ul>
3694
3695<li>a <tt>double</tt> representing the x or y coordinates of the point <tt>point</tt>,</li>
3696<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3697<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3698<li>any other non-point input value will cause a type error.</li>
3699</ul>
3700</li>
3701<li>
3702
3703<p>Example:</p>
3704
3705<div>
3706<div>
3707<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)) };
3708</pre></div></div>
3709</li>
3710<li>
3711
3712<p>The expected result is:</p>
3713
3714<div>
3715<div>
3716<pre class="source">{ &quot;x_coordinate&quot;: 2.3, &quot;y_coordinate&quot;: 5.0 }
3717</pre></div></div>
3718</li>
3719</ul></div>
3720<div class="section">
3721<h3><a name="get_points"></a>get_points</h3>
3722<ul>
3723
3724<li>
3725
3726<p>Syntax:</p>
3727
3728<div>
3729<div>
3730<pre class="source">get_points(spatial_object)
3731</pre></div></div>
3732</li>
3733<li>
3734
3735<p>Returns an ordered array of the points forming the spatial object <tt>spatial_object</tt>.</p>
3736</li>
3737<li>Arguments:
3738<ul>
3739
3740<li><tt>spatial_object</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3741</ul>
3742</li>
3743<li>Return Value:
3744<ul>
3745
3746<li>an <tt>array</tt> of the points forming the spatial object <tt>spatial_object</tt>,</li>
3747<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3748<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3749<li>any other non-spatial-object input value will cause a type error.</li>
3750</ul>
3751</li>
3752<li>
3753
3754<p>Example:</p>
3755
3756<div>
3757<div>
3758<pre class="source">get_points(create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]))
3759</pre></div></div>
3760</li>
3761<li>
3762
3763<p>The expected result is:</p>
3764
3765<div>
3766<div>
3767<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;) ]
3768</pre></div></div>
3769</li>
3770</ul></div>
3771<div class="section">
3772<h3><a name="get_center.2Fget_radius"></a>get_center/get_radius</h3>
3773<ul>
3774
3775<li>
3776
3777<p>Syntax:</p>
3778
3779<div>
3780<div>
3781<pre class="source">get_center(circle_expression) or get_radius(circle_expression)
3782</pre></div></div>
3783</li>
3784<li>
3785
3786<p>Returns the center and the radius of a circle <tt>circle_expression</tt>, respectively.</p>
3787</li>
3788<li>Arguments:
3789<ul>
3790
3791<li><tt>circle_expression</tt> : a <tt>circle</tt>.</li>
3792</ul>
3793</li>
3794<li>Return Value:
3795<ul>
3796
3797<li>a <tt>point</tt> or <tt>double</tt>, represent the center or radius of the circle <tt>circle_expression</tt>.</li>
3798<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3799<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3800<li>any other non-circle input value will cause a type error.</li>
3801</ul>
3802</li>
3803<li>
3804
3805<p>Example:</p>
3806
3807<div>
3808<div>
3809<pre class="source">{
3810 &quot;circle_radius&quot;: get_radius(create_circle(create_point(6.0,3.0), 1.0)),
3811 &quot;circle_center&quot;: get_center(create_circle(create_point(6.0,3.0), 1.0))
3812};
3813</pre></div></div>
3814</li>
3815<li>
3816
3817<p>The expected result is:</p>
3818
3819<div>
3820<div>
3821<pre class="source">{ &quot;circle_radius&quot;: 1.0, &quot;circle_center&quot;: point(&quot;6.0,3.0&quot;) }
3822</pre></div></div>
3823</li>
3824</ul></div>
3825<div class="section">
3826<h3><a name="spatial_distance"></a>spatial_distance</h3>
3827<ul>
3828
3829<li>
3830
3831<p>Syntax:</p>
3832
3833<div>
3834<div>
3835<pre class="source">spatial_distance(point1, point2)
3836</pre></div></div>
3837</li>
3838<li>
3839
3840<p>Returns the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</p>
3841</li>
3842<li>Arguments:
3843<ul>
3844
3845<li><tt>point1</tt> : a <tt>point</tt>.</li>
3846<li><tt>point2</tt> : a <tt>point</tt>.</li>
3847</ul>
3848</li>
3849<li>Return Value:
3850<ul>
3851
3852<li>a <tt>double</tt> as the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</li>
3853<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3854<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3855<li>any other non-point input value will cause a type error.</li>
3856</ul>
3857</li>
3858<li>
3859
3860<p>Example:</p>
3861
3862<div>
3863<div>
3864<pre class="source">spatial_distance(point(&quot;47.44,80.65&quot;), create_point(30.0,70.0));
3865</pre></div></div>
3866</li>
3867<li>
3868
3869<p>The expected result is:</p>
3870
3871<div>
3872<div>
3873<pre class="source">20.434678857275934
3874</pre></div></div>
3875</li>
3876</ul></div>
3877<div class="section">
3878<h3><a name="spatial_area"></a>spatial_area</h3>
3879<ul>
3880
3881<li>
3882
3883<p>Syntax:</p>
3884
3885<div>
3886<div>
3887<pre class="source">spatial_area(spatial_2d_expression)
3888</pre></div></div>
3889</li>
3890<li>
3891
3892<p>Returns the spatial area of <tt>spatial_2d_expression</tt>.</p>
3893</li>
3894<li>Arguments:
3895<ul>
3896
3897<li><tt>spatial_2d_expression</tt> : a <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3898</ul>
3899</li>
3900<li>Return Value:
3901<ul>
3902
3903<li>a <tt>double</tt> representing the area of <tt>spatial_2d_expression</tt>.</li>
3904<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3905<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3906<li>any other non-2d-spatial-object will cause a type error.</li>
3907</ul>
3908</li>
3909<li>
3910
3911<p>Example:</p>
3912
3913<div>
3914<div>
3915<pre class="source">spatial_area(create_circle(create_point(0.0,0.0), 5.0));
3916</pre></div></div>
3917</li>
3918<li>
3919
3920<p>The expected result is:</p>
3921
3922<div>
3923<div>
3924<pre class="source">78.53981625
3925</pre></div></div>
3926</li>
3927</ul></div>
3928<div class="section">
3929<h3><a name="spatial_intersect"></a>spatial_intersect</h3>
3930<ul>
3931
3932<li>
3933
3934<p>Syntax:</p>
3935
3936<div>
3937<div>
3938<pre class="source">spatial_intersect(spatial_object1, spatial_object2)
3939</pre></div></div>
3940</li>
3941<li>
3942
3943<p>Checks whether <tt>@arg1</tt> and <tt>@arg2</tt> spatially intersect each other.</p>
3944</li>
3945<li>Arguments:
3946<ul>
3947
3948<li><tt>spatial_object1</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3949<li><tt>spatial_object2</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3950</ul>
3951</li>
3952<li>Return Value:
3953<ul>
3954
3955<li>a <tt>boolean</tt> representing whether <tt>spatial_object1</tt> and <tt>spatial_object2</tt> spatially overlap with each other,</li>
3956<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3957<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3958<li>any other non-spatial-object input value will cause a type error.</li>
3959</ul>
3960</li>
3961<li>
3962
3963<p>Example:</p>
3964
3965<div>
3966<div>
3967<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)));
3968</pre></div></div>
3969</li>
3970<li>
3971
3972<p>The expected result is:</p>
3973
3974<div>
3975<div>
3976<pre class="source">true
3977</pre></div></div>
3978</li>
3979</ul></div>
3980<div class="section">
3981<h3><a name="spatial_cell"></a>spatial_cell</h3>
3982<ul>
3983
3984<li>
3985
3986<p>Syntax:</p>
3987
3988<div>
3989<div>
3990<pre class="source">spatial_cell(point1, point2, x_increment, y_increment)
3991</pre></div></div>
3992</li>
3993<li>
3994
3995<p>Returns the grid cell that <tt>point1</tt> belongs to.</p>
3996</li>
3997<li>Arguments:
3998<ul>
3999
4000<li><tt>point1</tt> : a <tt>point</tt> representing the point of interest that its grid cell will be returned.</li>
4001<li><tt>point2</tt> : a <tt>point</tt> representing the origin of the grid.</li>
4002<li><tt>x_increment</tt> : a <tt>double</tt>, represents X increments.</li>
4003<li><tt>y_increment</tt> : a <tt>double</tt>, represents Y increments.</li>
4004</ul>
4005</li>
4006<li>Return Value:
4007<ul>
4008
4009<li>a <tt>rectangle</tt> representing the grid cell that <tt>point1</tt> belongs to,</li>
4010<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4011<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4012<li>a type error will be raised if:
4013<ul>
4014
4015<li>the first or second argument is any other non-point value,</li>
4016<li>or, the second or third argument is any other non-double value.</li>
4017</ul>
4018</li>
4019</ul>
4020</li>
4021<li>
4022
4023<p>Example:</p>
4024
4025<div>
4026<div>
4027<pre class="source">spatial_cell(point(&quot;39.28,70.48&quot;), create_point(20.0,50.0), 5.5, 6.0);
4028</pre></div></div>
4029</li>
4030<li>
4031
4032<p>The expected result is:</p>
4033
4034<div>
4035<div>
4036<pre class="source">rectangle(&quot;36.5,68.0 42.0,74.0&quot;);
4037</pre></div></div>
4038</li>
4039</ul><!--
4040 ! Licensed to the Apache Software Foundation (ASF) under one
4041 ! or more contributor license agreements. See the NOTICE file
4042 ! distributed with this work for additional information
4043 ! regarding copyright ownership. The ASF licenses this file
4044 ! to you under the Apache License, Version 2.0 (the
4045 ! "License"); you may not use this file except in compliance
4046 ! with the License. You may obtain a copy of the License at
4047 !
4048 ! http://www.apache.org/licenses/LICENSE-2.0
4049 !
4050 ! Unless required by applicable law or agreed to in writing,
4051 ! software distributed under the License is distributed on an
4052 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4053 ! KIND, either express or implied. See the License for the
4054 ! specific language governing permissions and limitations
4055 ! under the License.
4056 !-->
4057</div></div>
4058<div class="section">
4059<h2><a name="Similarity_Functions"></a><a name="SimilarityFunctions" id="SimilarityFunctions">Similarity Functions</a></h2>
4060<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>
4061<div class="section">
4062<h3><a name="edit_distance"></a>edit_distance</h3>
4063<ul>
4064
4065<li>
4066
4067<p>Syntax:</p>
4068
4069<div>
4070<div>
4071<pre class="source">edit_distance(expression1, expression2)
4072</pre></div></div>
4073</li>
4074<li>
4075
4076<p>Returns the edit distance of <tt>expression1</tt> and <tt>expression2</tt>.</p>
4077</li>
4078<li>Arguments:
4079<ul>
4080
4081<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4082<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4083</ul>
4084</li>
4085<li>Return Value:
4086<ul>
4087
4088<li>an <tt>bigint</tt> that represents the edit distance between <tt>expression1</tt> and <tt>expression2</tt>,</li>
4089<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4090<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4091<li>any other non-string input value will cause a type error.</li>
4092</ul>
4093</li>
4094<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4095<li>Example:
4096
4097<div>
4098<div>
4099<pre class="source">edit_distance(&quot;SuzannaTillson&quot;, &quot;Suzanna Tilson&quot;);
4100</pre></div></div>
4101</li>
4102<li>
4103
4104<p>The expected result is:</p>
4105
4106<div>
4107<div>
4108<pre class="source">2
4109</pre></div></div>
4110</li>
4111</ul></div>
4112<div class="section">
4113<h3><a name="edit_distance_check"></a>edit_distance_check</h3>
4114<ul>
4115
4116<li>
4117
4118<p>Syntax:</p>
4119
4120<div>
4121<div>
4122<pre class="source">edit_distance_check(expression1, expression2, threshold)
4123</pre></div></div>
4124</li>
4125<li>
4126
4127<p>Checks whether the edit distance of <tt>expression1</tt> and <tt>expression2</tt> is within a given threshold.</p>
4128</li>
4129<li>
4130
4131<p>Arguments:</p>
4132<ul>
4133
4134<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4135<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4136<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4137</ul>
4138</li>
4139<li>Return Value:
4140<ul>
4141
4142<li>an <tt>array</tt> with two items:
4143<ul>
4144
4145<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>
4146<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>
4147<li>If the first item is false, then the second item is set to 2147483647.</li>
4148</ul>
4149</li>
4150<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4151<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4152<li>a type error will be raised if:
4153<ul>
4154
4155<li>the first or second argument is any other non-string value,</li>
4156<li>or, the third argument is any other non-bigint value.</li>
4157</ul>
4158</li>
4159</ul>
4160</li>
4161<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4162<li>Example:
4163
4164<div>
4165<div>
4166<pre class="source">edit_distance_check(&quot;happy&quot;,&quot;hapr&quot;,2);
4167</pre></div></div>
4168</li>
4169<li>
4170
4171<p>The expected result is:</p>
4172
4173<div>
4174<div>
4175<pre class="source">[ true, 2 ]
4176</pre></div></div>
4177</li>
4178</ul></div>
4179<div class="section">
4180<h3><a name="edit_distance_contains"></a>edit_distance_contains</h3>
4181<ul>
4182
4183<li>
4184
4185<p>Syntax:</p>
4186
4187<div>
4188<div>
4189<pre class="source">edit_distance_contains(expression1, expression2, threshold)
4190</pre></div></div>
4191</li>
4192<li>
4193
4194<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>
4195</li>
4196<li>
4197
4198<p>Arguments:</p>
4199<ul>
4200
4201<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4202<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4203<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4204</ul>
4205</li>
4206<li>Return Value:
4207<ul>
4208
4209<li>an <tt>array</tt> with two items:
4210<ul>
4211
4212<li>The first item contains a <tt>boolean</tt> value representing whether <tt>expression1</tt> can contain <tt>expression2</tt>.</li>
4213<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>
4214</ul>
4215</li>
4216<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4217<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4218<li>a type error will be raised if:
4219<ul>
4220
4221<li>the first or second argument is any other non-string value,</li>
4222<li>or, the third argument is any other non-bigint value.</li>
4223</ul>
4224</li>
4225</ul>
4226</li>
4227<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4228<li>Example:
4229
4230<div>
4231<div>
4232<pre class="source">edit_distance_contains(&quot;happy&quot;,&quot;hapr&quot;,2);
4233</pre></div></div>
4234</li>
4235<li>
4236
4237<p>The expected result is:</p>
4238
4239<div>
4240<div>
4241<pre class="source">[ true, 1 ]
4242</pre></div></div>
4243</li>
4244</ul></div>
4245<div class="section">
4246<h3><a name="similarity_jaccard"></a>similarity_jaccard</h3>
4247<ul>
4248
4249<li>
4250
4251<p>Syntax:</p>
4252
4253<div>
4254<div>
4255<pre class="source">similarity_jaccard(array1, array2)
4256</pre></div></div>
4257</li>
4258<li>
4259
4260<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>
4261</li>
4262<li>Arguments:
4263<ul>
4264
4265<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4266<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4267</ul>
4268</li>
4269<li>Return Value:
4270<ul>
4271
4272<li>a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt>,</li>
4273<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4274<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4275<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4276<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>
4277<li>any other non-array input value or non-integer element in any input array will cause a type error.</li>
4278</ul>
4279</li>
4280<li>
4281
4282<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4283</li>
4284<li>Example:
4285
4286<div>
4287<div>
4288<pre class="source">similarity_jaccard([1,5,8,9], [1,5,9,10]);
4289</pre></div></div>
4290</li>
4291<li>
4292
4293<p>The expected result is:</p>
4294
4295<div>
4296<div>
4297<pre class="source">0.6
4298</pre></div></div>
4299</li>
4300</ul></div>
4301<div class="section">
4302<h3><a name="similarity_jaccard_check"></a>similarity_jaccard_check</h3>
4303<ul>
4304
4305<li>
4306
4307<p>Syntax:</p>
4308
4309<div>
4310<div>
4311<pre class="source">similarity_jaccard_check(array1, array2, threshold)
4312</pre></div></div>
4313</li>
4314<li>
4315
4316<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>
4317</li>
4318<li>
4319
4320<p>Arguments:</p>
4321<ul>
4322
4323<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4324<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4325<li><tt>threshold</tt> : a <tt>double</tt> that represents the similarity threshold.</li>
4326</ul>
4327</li>
4328<li>Return Value:
4329<ul>
4330
4331<li>an <tt>array</tt> with two items:
4332<ul>
4333
4334<li>The first item contains a <tt>boolean</tt> value representing whether <tt>array1</tt> and <tt>array2</tt> are similar.</li>
4335<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>
4336</ul>
4337</li>
4338<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4339<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4340<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4341<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>
4342<li>a type error will be raised if:
4343<ul>
4344
4345<li>the first or second argument is any other non-array value,
4346<ul>
4347
4348<li>or, the third argument is any other non-double value.</li>
4349</ul>
4350</li>
4351</ul>
4352</li>
4353</ul>
4354</li>
4355<li>
4356
4357<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4358</li>
4359<li>Example:
4360
4361<div>
4362<div>
4363<pre class="source">similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
4364</pre></div></div>
4365</li>
4366<li>
4367
4368<p>The expected result is:</p>
4369
4370<div>
4371<div>
4372<pre class="source">[ false, 0.0 ]
4373</pre></div></div>
4374</li>
4375</ul><!--
4376 ! Licensed to the Apache Software Foundation (ASF) under one
4377 ! or more contributor license agreements. See the NOTICE file
4378 ! distributed with this work for additional information
4379 ! regarding copyright ownership. The ASF licenses this file
4380 ! to you under the Apache License, Version 2.0 (the
4381 ! "License"); you may not use this file except in compliance
4382 ! with the License. You may obtain a copy of the License at
4383 !
4384 ! http://www.apache.org/licenses/LICENSE-2.0
4385 !
4386 ! Unless required by applicable law or agreed to in writing,
4387 ! software distributed under the License is distributed on an
4388 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4389 ! KIND, either express or implied. See the License for the
4390 ! specific language governing permissions and limitations
4391 ! under the License.
4392 !-->
4393</div></div>
4394<div class="section">
4395<h2><a name="Tokenizing_Functions"></a><a name="TokenizingFunctions" id="TokenizingFunctions">Tokenizing Functions</a></h2>
4396<div class="section">
4397<h3><a name="word_tokens"></a>word_tokens</h3>
4398<ul>
4399
4400<li>
4401
4402<p>Syntax:</p>
4403
4404<div>
4405<div>
4406<pre class="source">word_tokens(string)
4407</pre></div></div>
4408</li>
4409<li>
4410
4411<p>Returns an array of word tokens of <tt>string</tt> using non_alphanumeric characters as delimiters.</p>
4412</li>
4413<li>Arguments:
4414<ul>
4415
4416<li><tt>string</tt> : a <tt>string</tt> that will be tokenized.</li>
4417</ul>
4418</li>
4419<li>Return Value:
4420<ul>
4421
4422<li>an <tt>array</tt> of <tt>string</tt> word tokens,</li>
4423<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4424<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4425<li>any other non-string input value will cause a type error.</li>
4426</ul>
4427</li>
4428<li>
4429
4430<p>Example:</p>
4431
4432<div>
4433<div>
4434<pre class="source">word_tokens(&quot;I like the phone, awesome!&quot;);
4435</pre></div></div>
4436</li>
4437<li>
4438
4439<p>The expected result is:</p>
4440
4441<div>
4442<div>
4443<pre class="source">[ &quot;i&quot;, &quot;like&quot;, &quot;the&quot;, &quot;phone&quot;, &quot;awesome&quot; ]
4444</pre></div></div>
4445</li>
4446</ul><!--
4447 ! Licensed to the Apache Software Foundation (ASF) under one
4448 ! or more contributor license agreements. See the NOTICE file
4449 ! distributed with this work for additional information
4450 ! regarding copyright ownership. The ASF licenses this file
4451 ! to you under the Apache License, Version 2.0 (the
4452 ! "License"); you may not use this file except in compliance
4453 ! with the License. You may obtain a copy of the License at
4454 !
4455 ! http://www.apache.org/licenses/LICENSE-2.0
4456 !
4457 ! Unless required by applicable law or agreed to in writing,
4458 ! software distributed under the License is distributed on an
4459 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4460 ! KIND, either express or implied. See the License for the
4461 ! specific language governing permissions and limitations
4462 ! under the License.
4463 !-->
4464</div></div>
4465<div class="section">
4466<h2><a name="Temporal_Functions"></a><a name="TemporalFunctions" id="TemporalFunctions">Temporal Functions</a></h2>
4467<div class="section">
4468<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>
4469<ul>
4470
4471<li>
4472
4473<p>Syntax:</p>
4474
4475<div>
4476<div>
4477<pre class="source">get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond(temporal_value)
4478</pre></div></div>
4479</li>
4480<li>
4481
4482<p>Accessors for accessing fields in a temporal value</p>
4483</li>
4484<li>Arguments:
4485<ul>
4486
4487<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>
4488</ul>
4489</li>
4490<li>Return Value:
4491<ul>
4492
4493<li>an <tt>bigint</tt> value representing the field to be extracted,</li>
4494<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4495<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4496<li>any other non-interval input value will cause a type error.</li>
4497</ul>
4498</li>
4499<li>
4500
4501<p>Example:</p>
4502
4503<div>
4504<div>
4505<pre class="source">{
4506 &quot;year&quot;: get_year(date(&quot;2010-10-30&quot;)),
4507 &quot;month&quot;: get_month(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4508 &quot;day&quot;: get_day(date(&quot;2010-10-30&quot;)),
4509 &quot;hour&quot;: get_hour(time(&quot;12:23:34.930+07:00&quot;)),
4510 &quot;min&quot;: get_minute(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;)),
4511 &quot;second&quot;: get_second(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4512 &quot;ms&quot;: get_millisecond(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;))
4513};
4514</pre></div></div>
4515</li>
4516<li>
4517
4518<p>The expected result is:</p>
4519
4520<div>
4521<div>
4522<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 }
4523</pre></div></div>
4524</li>
4525</ul></div>
4526<div class="section">
4527<h3><a name="adjust_datetime_for_timezone"></a>adjust_datetime_for_timezone</h3>
4528<ul>
4529
4530<li>
4531
4532<p>Syntax:</p>
4533
4534<div>
4535<div>
4536<pre class="source">adjust_datetime_for_timezone(datetime, string)
4537</pre></div></div>
4538</li>
4539<li>
4540
4541<p>Adjusts the given datetime <tt>datetime</tt> by applying the timezone information <tt>string</tt>.</p>
4542</li>
4543<li>Arguments:
4544<ul>
4545
4546<li><tt>datetime</tt> : a <tt>datetime</tt> value to be adjusted.</li>
4547<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4548</ul>
4549</li>
4550<li>Return Value:
4551<ul>
4552
4553<li>a <tt>string</tt> value representing the new datetime after being adjusted by the timezone information,</li>
4554<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4555<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4556<li>a type error will be raised if:
4557<ul>
4558
4559<li>the first argument is any other non-datetime value,</li>
4560<li>or, the second argument is any other non-string value.</li>
4561</ul>
4562</li>
4563</ul>
4564</li>
4565<li>
4566
4567<p>Example:</p>
4568
4569<div>
4570<div>
4571<pre class="source">adjust_datetime_for_timezone(datetime(&quot;2008-04-26T10:10:00&quot;), &quot;+08:00&quot;);
4572</pre></div></div>
4573</li>
4574<li>
4575
4576<p>The expected result is:</p>
4577
4578<div>
4579<div>
4580<pre class="source">&quot;2008-04-26T18:10:00.000+08:00&quot;
4581</pre></div></div>
4582</li>
4583</ul></div>
4584<div class="section">
4585<h3><a name="adjust_time_for_timezone"></a>adjust_time_for_timezone</h3>
4586<ul>
4587
4588<li>
4589
4590<p>Syntax:</p>
4591
4592<div>
4593<div>
4594<pre class="source">adjust_time_for_timezone(time, string)
4595</pre></div></div>
4596</li>
4597<li>
4598
4599<p>Adjusts the given time <tt>time</tt> by applying the timezone information <tt>string</tt>.</p>
4600</li>
4601<li>Arguments:
4602<ul>
4603
4604<li><tt>time</tt> : a <tt>time</tt> value to be adjusted.</li>
4605<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4606</ul>
4607</li>
4608<li>Return Value:
4609<ul>
4610
4611<li>a <tt>string</tt> value representing the new time after being adjusted by the timezone information,</li>
4612<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4613<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4614<li>a type error will be raised if:
4615<ul>
4616
4617<li>the first argument is any other non-time value,</li>
4618<li>or, the second argument is any other non-string value.</li>
4619</ul>
4620</li>
4621</ul>
4622</li>
4623<li>
4624
4625<p>Example:</p>
4626
4627<div>
4628<div>
4629<pre class="source">adjust_time_for_timezone(get_time_from_datetime(datetime(&quot;2008-04-26T10:10:00&quot;)), &quot;+08:00&quot;);
4630</pre></div></div>
4631</li>
4632<li>
4633
4634<p>The expected result is:</p>
4635
4636<div>
4637<div>
4638<pre class="source">&quot;18:10:00.000+08:00&quot;
4639</pre></div></div>
4640</li>
4641</ul></div>
4642<div class="section">
4643<h3><a name="calendar_duration_from_datetime"></a>calendar_duration_from_datetime</h3>
4644<ul>
4645
4646<li>
4647
4648<p>Syntax:</p>
4649
4650<div>
4651<div>
4652<pre class="source">calendar_duration_from_datetime(datetime, duration_value)
4653</pre></div></div>
4654</li>
4655<li>
4656
4657<p>Gets a user_friendly representation of the duration <tt>duration_value</tt> based on the given datetime <tt>datetime</tt>.</p>
4658</li>
4659<li>Arguments:
4660<ul>
4661
4662<li><tt>datetime</tt> : a <tt>datetime</tt> value to be used as the reference time point.</li>
4663<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4664</ul>
4665</li>
4666<li>Return Value:
4667<ul>
4668
4669<li>a <tt>duration</tt> value with the duration as <tt>duration_value</tt> but with a user_friendly representation,</li>
4670<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4671<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4672<li>a type error will be raised if:
4673<ul>
4674
4675<li>the first argument is any other non-datetime value,</li>
4676<li>or, the second argument is any other non-duration input value.</li>
4677</ul>
4678</li>
4679</ul>
4680</li>
4681<li>
4682
4683<p>Example:</p>
4684
4685<div>
4686<div>
4687<pre class="source">calendar_duration_from_datetime(
4688 datetime(&quot;2016-03-26T10:10:00&quot;),
4689 datetime(&quot;2016-03-26T10:10:00&quot;) - datetime(&quot;2011-01-01T00:00:00&quot;)
4690);
4691</pre></div></div>
4692</li>
4693<li>
4694
4695<p>The expected result is:</p>
4696
4697<div>
4698<div>
4699<pre class="source">duration(&quot;P5Y2M24DT10H10M&quot;)
4700</pre></div></div>
4701</li>
4702</ul></div>
4703<div class="section">
4704<h3><a name="get_year_month_duration.2Fget_day_time_duration"></a>get_year_month_duration/get_day_time_duration</h3>
4705<ul>
4706
4707<li>
4708
4709<p>Syntax:</p>
4710
4711<div>
4712<div>
4713<pre class="source">get_year_month_duration/get_day_time_duration(duration_value)
4714</pre></div></div>
4715</li>
4716<li>
4717
4718<p>Extracts the correct <tt>duration</tt> subtype from <tt>duration_value</tt>.</p>
4719</li>
4720<li>Arguments:
4721<ul>
4722
4723<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4724</ul>
4725</li>
4726<li>Return Value:
4727<ul>
4728
4729<li>a <tt>year_month_duration</tt> value or a <tt>day_time_duration</tt> value,</li>
4730<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4731<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4732<li>any other non-duration input value will cause a type error.</li>
4733</ul>
4734</li>
4735<li>
4736
4737<p>Example:</p>
4738
4739<div>
4740<div>
4741<pre class="source">get_year_month_duration(duration(&quot;P12M50DT10H&quot;));
4742</pre></div></div>
4743</li>
4744<li>
4745
4746<p>The expected result is:</p>
4747
4748<div>
4749<div>
4750<pre class="source">year_month_duration(&quot;P1Y&quot;)
4751</pre></div></div>
4752</li>
4753</ul></div>
4754<div class="section">
4755<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>
4756<ul>
4757
4758<li>
4759
4760<p>Syntax:</p>
4761
4762<div>
4763<div>
4764<pre class="source">months_from_year_month_duration/ms_from_day_time_duration(duration_value)
4765</pre></div></div>
4766</li>
4767<li>
4768
4769<p>Extracts the number of months or the number of milliseconds from the <tt>duration</tt> subtype.</p>
4770</li>
4771<li>Arguments:
4772<ul>
4773
4774<li><tt>duration_value</tt> : a <tt>duration</tt> of the correct subtype.</li>
4775</ul>
4776</li>
4777<li>Return Value:
4778<ul>
4779
4780<li>a <tt>bigint</tt> representing the number of months/milliseconds,</li>
4781<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4782<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4783<li>any other non-duration input value will cause a type error.</li>
4784</ul>
4785</li>
4786<li>
4787
4788<p>Example:</p>
4789
4790<div>
4791<div>
4792<pre class="source">{
4793 &quot;months&quot;: months_from_year_month_duration(get_year_month_duration(duration(&quot;P5Y7MT50M&quot;))),
4794 &quot;milliseconds&quot;: ms_from_day_time_duration(get_day_time_duration(duration(&quot;P5Y7MT50M&quot;)))
4795};
4796</pre></div></div>
4797</li>
4798<li>
4799
4800<p>The expected result is:</p>
4801
4802<div>
4803<div>
4804<pre class="source">{&quot;months&quot;: 67, &quot;milliseconds&quot;: 3000000}
4805</pre></div></div>
4806</li>
4807</ul></div>
4808<div class="section">
4809<h3><a name="duration_from_months.2Fduration_from_ms"></a>duration_from_months/duration_from_ms</h3>
4810<ul>
4811
4812<li>
4813
4814<p>Syntax:</p>
4815
4816<div>
4817<div>
4818<pre class="source">duration_from_months/duration_from_ms(number_value)
4819</pre></div></div>
4820</li>
4821<li>
4822
4823<p>Creates a <tt>duration</tt> from <tt>number_value</tt>.</p>
4824</li>
4825<li>Arguments:
4826<ul>
4827
4828<li><tt>number_value</tt> : a <tt>bigint</tt> representing the number of months/milliseconds</li>
4829</ul>
4830</li>
4831<li>Return Value:
4832<ul>
4833
4834<li>a <tt>duration</tt> containing <tt>number_value</tt> value for months/milliseconds,</li>
4835<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4836<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4837<li>any other non-duration input value will cause a type error.</li>
4838</ul>
4839</li>
4840<li>
4841
4842<p>Example:</p>
4843
4844<div>
4845<div>
4846<pre class="source">duration_from_months(8);
4847</pre></div></div>
4848</li>
4849<li>
4850
4851<p>The expected result is:</p>
4852
4853<div>
4854<div>
4855<pre class="source">duration(&quot;P8M&quot;)
4856</pre></div></div>
4857</li>
4858</ul></div>
4859<div class="section">
4860<h3><a name="duration_from_interval"></a>duration_from_interval</h3>
4861<ul>
4862
4863<li>
4864
4865<p>Syntax:</p>
4866
4867<div>
4868<div>
4869<pre class="source">duration_from_interval(interval_value)
4870</pre></div></div>
4871</li>
4872<li>
4873
4874<p>Creates a <tt>duration</tt> from <tt>interval_value</tt>.</p>
4875</li>
4876<li>Arguments:
4877<ul>
4878
4879<li><tt>interval_value</tt> : an <tt>interval</tt> value</li>
4880</ul>
4881</li>
4882<li>Return Value:
4883<ul>
4884
4885<li>a <tt>duration</tt> representing the time in the <tt>interval_value</tt></li>
4886<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4887<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4888<li>any other non-duration input value will cause a type error.</li>
4889</ul>
4890</li>
4891<li>
4892
4893<p>Example:</p>
4894
4895<div>
4896<div>
4897<pre class="source">{
4898 &quot;dr1&quot; : duration_from_interval(interval(date(&quot;2010-10-30&quot;), date(&quot;2010-12-21&quot;))),
4899 &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;))),
4900 &quot;dr3&quot; : duration_from_interval(interval(time(&quot;12:32:38&quot;), time(&quot;20:29:20&quot;))),
4901 &quot;dr4&quot; : duration_from_interval(null)
4902};
4903</pre></div></div>
4904</li>
4905<li>
4906
4907<p>The expected result is:</p>
4908
4909<div>
4910<div>
4911<pre class="source">{
4912 &quot;dr1&quot;: day_time_duration(&quot;P52D&quot;),
4913 &quot;dr2&quot;: day_time_duration(&quot;P31DT1H1M1.111S&quot;),
4914 &quot;dr3&quot;: day_time_duration(&quot;PT7H56M42S&quot;),
4915 &quot;dr4&quot;: null
4916}
4917</pre></div></div>
4918</li>
4919</ul></div>
4920<div class="section">
4921<h3><a name="current_date"></a>current_date</h3>
4922<ul>
4923
4924<li>
4925
4926<p>Syntax:</p>
4927
4928<div>
4929<div>
4930<pre class="source">current_date()
4931</pre></div></div>
4932</li>
4933<li>
4934
4935<p>Gets the current date.</p>
4936</li>
4937<li>Arguments: None</li>
4938<li>Return Value:
4939<ul>
4940
4941<li>a <tt>date</tt> value of the date when the function is called.</li>
4942</ul>
4943</li>
4944</ul></div>
4945<div class="section">
4946<h3><a name="current_time"></a>current_time</h3>
4947<ul>
4948
4949<li>
4950
4951<p>Syntax:</p>
4952
4953<div>
4954<div>
4955<pre class="source">current_time()
4956</pre></div></div>
4957</li>
4958<li>
4959
4960<p>Get the current time</p>
4961</li>
4962<li>Arguments: None</li>
4963<li>Return Value:
4964<ul>
4965
4966<li>a <tt>time</tt> value of the time when the function is called.</li>
4967</ul>
4968</li>
4969</ul></div>
4970<div class="section">
4971<h3><a name="current_datetime"></a>current_datetime</h3>
4972<ul>
4973
4974<li>
4975
4976<p>Syntax:</p>
4977
4978<div>
4979<div>
4980<pre class="source">current_datetime()
4981</pre></div></div>
4982</li>
4983<li>
4984
4985<p>Get the current datetime</p>
4986</li>
4987<li>Arguments: None</li>
4988<li>Return Value:
4989<ul>
4990
4991<li>a <tt>datetime</tt> value of the datetime when the function is called.</li>
4992</ul>
4993</li>
4994</ul></div>
4995<div class="section">
4996<h3><a name="get_date_from_datetime"></a>get_date_from_datetime</h3>
4997<ul>
4998
4999<li>
5000
5001<p>Syntax:</p>
5002
5003<div>
5004<div>
5005<pre class="source">get_date_from_datetime(datetime)
5006</pre></div></div>
5007</li>
5008<li>
5009
5010<p>Gets the date value from the given datetime value <tt>datetime</tt>.</p>
5011</li>
5012<li>Arguments:
5013<ul>
5014
5015<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5016</ul>
5017</li>
5018<li>Return Value:
5019<ul>
5020
5021<li>a <tt>date</tt> value from the datetime,</li>
5022<li>any other non-datetime input value will cause a type error.</li>
5023</ul>
5024</li>
5025</ul></div>
5026<div class="section">
5027<h3><a name="get_time_from_datetime"></a>get_time_from_datetime</h3>
5028<ul>
5029
5030<li>
5031
5032<p>Syntax:</p>
5033
5034<div>
5035<div>
5036<pre class="source">get_time_from_datetime(datetime)
5037</pre></div></div>
5038</li>
5039<li>
5040
5041<p>Get the time value from the given datetime value <tt>datetime</tt></p>
5042</li>
5043<li>Arguments:
5044<ul>
5045
5046<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5047</ul>
5048</li>
5049<li>Return Value:
5050<ul>
5051
5052<li>a <tt>time</tt> value from the datetime.</li>
5053<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5054<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5055<li>any other non-datetime input value will cause a type error.</li>
5056</ul>
5057</li>
5058<li>
5059
5060<p>Example:</p>
5061
5062<div>
5063<div>
5064<pre class="source">get_time_from_datetime(datetime(&quot;2016-03-26T10:10:00&quot;));
5065</pre></div></div>
5066</li>
5067<li>
5068
5069<p>The expected result is:</p>
5070
5071<div>
5072<div>
5073<pre class="source">time(&quot;10:10:00.000Z&quot;)
5074</pre></div></div>
5075</li>
5076</ul></div>
5077<div class="section">
5078<h3><a name="day_of_week"></a>day_of_week</h3>
5079<ul>
5080
5081<li>
5082
5083<p>Syntax:</p>
5084
5085<div>
5086<div>
5087<pre class="source">day_of_week(date)
5088</pre></div></div>
5089</li>
5090<li>
5091
5092<p>Finds the day of the week for a given date (1_7)</p>
5093</li>
5094<li>Arguments:
5095<ul>
5096
5097<li><tt>date</tt>: a <tt>date</tt> value (Can also be a <tt>datetime</tt>)</li>
5098</ul>
5099</li>
5100<li>Return Value:
5101<ul>
5102
5103<li>an <tt>tinyint</tt> representing the day of the week (1_7),</li>
5104<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5105<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5106<li>any other non-date input value will cause a type error.</li>
5107</ul>
5108</li>
5109<li>
5110
5111<p>Example:</p>
5112
5113<div>
5114<div>
5115<pre class="source">day_of_week(datetime(&quot;2012-12-30T12:12:12.039Z&quot;));
5116</pre></div></div>
5117</li>
5118<li>
5119
5120<p>The expected result is:</p>
5121
5122<div>
5123<div>
5124<pre class="source">7
5125</pre></div></div>
5126</li>
5127</ul></div>
5128<div class="section">
5129<h3><a name="date_from_unix_time_in_days"></a>date_from_unix_time_in_days</h3>
5130<ul>
5131
5132<li>
5133
5134<p>Syntax:</p>
5135
5136<div>
5137<div>
5138<pre class="source">date_from_unix_time_in_days(numeric_value)
5139</pre></div></div>
5140</li>
5141<li>
5142
5143<p>Gets a date representing the time after <tt>numeric_value</tt> days since 1970_01_01.</p>
5144</li>
5145<li>Arguments:
5146<ul>
5147
5148<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>
5149</ul>
5150</li>
5151<li>Return Value:
5152<ul>
5153
5154<li>a <tt>date</tt> value as the time after <tt>numeric_value</tt> days since 1970-01-01,</li>
5155<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5156<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5157<li>any other non-numeric input value will cause a type error.</li>
5158</ul>
5159</li>
5160</ul></div>
5161<div class="section">
5162<h3><a name="datetime_from_unix_time_in_ms"></a>datetime_from_unix_time_in_ms</h3>
5163<ul>
5164
5165<li>
5166
5167<p>Syntax:</p>
5168
5169<div>
5170<div>
5171<pre class="source">datetime_from_unix_time_in_ms(numeric_value)
5172</pre></div></div>
5173</li>
5174<li>
5175
5176<p>Gets a datetime representing the time after <tt>numeric_value</tt> milliseconds since 1970_01_01T00:00:00Z.</p>
5177</li>
5178<li>Arguments:
5179<ul>
5180
5181<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>
5182</ul>
5183</li>
5184<li>Return Value:
5185<ul>
5186
5187<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> milliseconds since 1970-01-01T00:00:00Z,</li>
5188<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5189<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5190<li>any other non-numeric input value will cause a type error.</li>
5191</ul>
5192</li>
5193</ul></div>
5194<div class="section">
5195<h3><a name="datetime_from_unix_time_in_secs"></a>datetime_from_unix_time_in_secs</h3>
5196<ul>
5197
5198<li>
5199
5200<p>Syntax:</p>
5201
5202<div>
5203<div>
5204<pre class="source">datetime_from_unix_time_in_secs(numeric_value)
5205</pre></div></div>
5206</li>
5207<li>
5208
5209<p>Gets a datetime representing the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z.</p>
5210</li>
5211<li>Arguments:
5212<ul>
5213
5214<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>
5215</ul>
5216</li>
5217<li>Return Value:
5218<ul>
5219
5220<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z,</li>
5221<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5222<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5223<li>any other non-numeric input value will cause a type error.</li>
5224</ul>
5225</li>
5226</ul></div>
5227<div class="section">
5228<h3><a name="datetime_from_date_time"></a>datetime_from_date_time</h3>
5229<ul>
5230
5231<li>Syntax:</li>
5232</ul>
5233<p>datetime_from_date_time(date,time)</p>
5234<ul>
5235
5236<li>Gets a datetime representing the combination of <tt>date</tt> and <tt>time</tt>
5237<ul>
5238
5239<li>Arguments:</li>
5240<li><tt>date</tt>: a <tt>date</tt> value</li>
5241<li><tt>time</tt> a <tt>time</tt> value</li>
5242</ul>
5243</li>
5244<li>Return Value:
5245<ul>
5246
5247<li>a <tt>datetime</tt> value by combining <tt>date</tt> and <tt>time</tt>,</li>
5248<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5249<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5250<li>a type error will be raised if
5251<ul>
5252
5253<li>the first argument is any other non-date value,</li>
5254<li>or, the second argument is any other non-time value.</li>
5255</ul>
5256</li>
5257</ul>
5258</li>
5259</ul></div>
5260<div class="section">
5261<h3><a name="time_from_unix_time_in_ms"></a>time_from_unix_time_in_ms</h3>
5262<ul>
5263
5264<li>
5265
5266<p>Syntax:</p>
5267
5268<div>
5269<div>
5270<pre class="source">time_from_unix_time_in_ms(numeric_value)
5271</pre></div></div>
5272</li>
5273<li>
5274
5275<p>Gets a time representing the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z.</p>
5276</li>
5277<li>Arguments:
5278<ul>
5279
5280<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>
5281</ul>
5282</li>
5283<li>Return Value:
5284<ul>
5285
5286<li>a <tt>time</tt> value as the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z,</li>
5287<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5288<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5289<li>any other non-numeric input value will cause a type error.</li>
5290</ul>
5291</li>
5292<li>
5293
5294<p>Example:</p>
5295
5296<div>
5297<div>
5298<pre class="source">{
5299 &quot;date&quot;: date_from_unix_time_in_days(15800),
5300 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5301 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5302};
5303</pre></div></div>
5304</li>
5305<li>
5306
5307<p>The expected result is:</p>
5308
5309<div>
5310<div>
5311<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;) }
5312</pre></div></div>
5313</li>
5314</ul></div>
5315<div class="section">
5316<h3><a name="unix_time_from_date_in_days"></a>unix_time_from_date_in_days</h3>
5317<ul>
5318
5319<li>
5320
5321<p>Syntax:</p>
5322
5323<div>
5324<div>
5325<pre class="source">unix_time_from_date_in_days(date_value)
5326</pre></div></div>
5327</li>
5328<li>
5329
5330<p>Gets an integer value representing the number of days since 1970_01_01 for <tt>date_value</tt>.</p>
5331</li>
5332<li>Arguments:
5333<ul>
5334
5335<li><tt>date_value</tt>: a <tt>date</tt> value.</li>
5336</ul>
5337</li>
5338<li>Return Value:
5339<ul>
5340
5341<li>a <tt>bigint</tt> value representing the number of days,</li>
5342<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5343<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5344<li>any other non-date input value will cause a type error.</li>
5345</ul>
5346</li>
5347</ul></div>
5348<div class="section">
5349<h3><a name="unix_time_from_datetime_in_ms"></a>unix_time_from_datetime_in_ms</h3>
5350<ul>
5351
5352<li>
5353
5354<p>Syntax:</p>
5355
5356<div>
5357<div>
5358<pre class="source">unix_time_from_datetime_in_ms(datetime_value)
5359</pre></div></div>
5360</li>
5361<li>
5362
5363<p>Gets an integer value representing the time in milliseconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5364</li>
5365<li>Arguments:
5366<ul>
5367
5368<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5369</ul>
5370</li>
5371<li>Return Value:
5372<ul>
5373
5374<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5375<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5376<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5377<li>any other non-datetime input value will cause a type error.</li>
5378</ul>
5379</li>
5380</ul></div>
5381<div class="section">
5382<h3><a name="unix_time_from_datetime_in_secs"></a>unix_time_from_datetime_in_secs</h3>
5383<ul>
5384
5385<li>
5386
5387<p>Syntax:</p>
5388
5389<div>
5390<div>
5391<pre class="source">unix_time_from_datetime_in_secs(datetime_value)
5392</pre></div></div>
5393</li>
5394<li>
5395
5396<p>Gets an integer value representing the time in seconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5397</li>
5398<li>Arguments:
5399<ul>
5400
5401<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5402</ul>
5403</li>
5404<li>Return Value:
5405<ul>
5406
5407<li>a <tt>bigint</tt> value representing the number of seconds,</li>
5408<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5409<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5410<li>any other non-datetime input value will cause a type error.</li>
5411</ul>
5412</li>
5413</ul></div>
5414<div class="section">
5415<h3><a name="unix_time_from_time_in_ms"></a>unix_time_from_time_in_ms</h3>
5416<ul>
5417
5418<li>
5419
5420<p>Syntax:</p>
5421
5422<div>
5423<div>
5424<pre class="source">unix_time_from_time_in_ms(time_value)
5425</pre></div></div>
5426</li>
5427<li>
5428
5429<p>Gets an integer value representing the time the milliseconds since 00:00:00.000Z for <tt>time_value</tt>.</p>
5430</li>
5431<li>Arguments:
5432<ul>
5433
5434<li><tt>time_value</tt> : a <tt>time</tt> value.</li>
5435</ul>
5436</li>
5437<li>Return Value:
5438<ul>
5439
5440<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5441<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5442<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5443<li>any other non-datetime input value will cause a type error.</li>
5444</ul>
5445</li>
5446<li>
5447
5448<p>Example:</p>
5449
5450<div>
5451<div>
5452<pre class="source">{
5453 &quot;date&quot;: date_from_unix_time_in_days(15800),
5454 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5455 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5456}
5457</pre></div></div>
5458</li>
5459<li>
5460
5461<p>The expected result is:</p>
5462
5463<div>
5464<div>
5465<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;) }
5466</pre></div></div>
5467</li>
5468</ul></div>
5469<div class="section">
5470<h3><a name="parse_date.2Fparse_time.2Fparse_datetime"></a>parse_date/parse_time/parse_datetime</h3>
5471<ul>
5472
5473<li>Syntax:</li>
5474</ul>
5475<p>parse_date/parse_time/parse_datetime(date,formatting_expression)</p>
5476<ul>
5477
5478<li>Creates a <tt>date/time/date_time</tt> value by treating <tt>date</tt> with formatting <tt>formatting_expression</tt></li>
5479<li>Arguments:
5480<ul>
5481
5482<li><tt>date</tt>: a <tt>string</tt> value representing the <tt>date/time/datetime</tt>.</li>
5483<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>
5484<li><tt>h</tt> hours</li>
5485<li><tt>m</tt> minutes</li>
5486<li><tt>s</tt> seconds</li>
5487<li><tt>n</tt> milliseconds</li>
5488<li><tt>a</tt> am/pm</li>
5489<li><tt>z</tt> timezone</li>
5490<li><tt>Y</tt> year</li>
5491<li><tt>M</tt> month</li>
5492<li><tt>D</tt> day</li>
5493<li><tt>W</tt> weekday</li>
5494<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5495</ul>
5496</li>
5497<li>Return Value:
5498<ul>
5499
5500<li>a <tt>date/time/date_time</tt> value corresponding to <tt>date</tt>,</li>
5501<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5502<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5503<li>a type error will be raised if:</li>
5504<li>the first argument is any other non-date value,</li>
5505<li>the second argument is any other non-string value.</li>
5506</ul>
5507</li>
5508<li>
5509
5510<p>Example:</p>
5511
5512<div>
5513<div>
5514<pre class="source">parse_time(&quot;30:30&quot;,&quot;m:s&quot;);
5515</pre></div></div>
5516</li>
5517<li>
5518
5519<p>The expected result is:</p>
5520
5521<div>
5522<div>
5523<pre class="source">time(&quot;00:30:30.000Z&quot;)
5524</pre></div></div>
5525</li>
5526</ul></div>
5527<div class="section">
5528<h3><a name="print_date.2Fprint_time.2Fprint_datetime"></a>print_date/print_time/print_datetime</h3>
5529<ul>
5530
5531<li>
5532
5533<p>Syntax:</p>
5534
5535<div>
5536<div>
5537<pre class="source">print_date/print_time/print_datetime(date,formatting_expression)
5538</pre></div></div>
5539</li>
5540<li>
5541
5542<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>
5543</li>
5544<li>Arguments:
5545<ul>
5546
5547<li><tt>date</tt>: a <tt>date/time/datetime</tt> value.</li>
5548<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>
5549<li><tt>h</tt> hours</li>
5550<li><tt>m</tt> minutes</li>
5551<li><tt>s</tt> seconds</li>
5552<li><tt>n</tt> milliseconds</li>
5553<li><tt>a</tt> am/pm</li>
5554<li><tt>z</tt> timezone</li>
5555<li><tt>Y</tt> year</li>
5556<li><tt>M</tt> month</li>
5557<li><tt>D</tt> day</li>
5558<li><tt>W</tt> weekday</li>
5559<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5560</ul>
5561</li>
5562<li>Return Value:
5563<ul>
5564
5565<li>a <tt>string</tt> value corresponding to <tt>date</tt>,</li>
5566<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5567<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5568<li>a type error will be raised if:
5569<ul>
5570
5571<li>the first argument is any other non-date value,</li>
5572<li>the second argument is any other non-string value.</li>
5573</ul>
5574</li>
5575</ul>
5576</li>
5577<li>
5578
5579<p>Example:</p>
5580
5581<div>
5582<div>
5583<pre class="source">print_time(time(&quot;00:30:30.000Z&quot;),&quot;m:s&quot;);
5584</pre></div></div>
5585</li>
5586<li>
5587
5588<p>The expected result is:</p>
5589
5590<div>
5591<div>
5592<pre class="source">&quot;30:30&quot;
5593</pre></div></div>
5594</li>
5595</ul></div>
5596<div class="section">
5597<h3><a name="get_interval_start.2C_get_interval_end"></a>get_interval_start, get_interval_end</h3>
5598<ul>
5599
5600<li>
5601
5602<p>Syntax:</p>
5603
5604<div>
5605<div>
5606<pre class="source">get_interval_start/get_interval_end(interval)
5607</pre></div></div>
5608</li>
5609<li>
5610
5611<p>Gets the start/end of the given interval.</p>
5612</li>
5613<li>Arguments:
5614<ul>
5615
5616<li><tt>interval</tt>: the interval to be accessed.</li>
5617</ul>
5618</li>
5619<li>Return Value:
5620<ul>
5621
5622<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>
5623<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5624<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5625<li>any other non-interval value will cause a type error.</li>
5626</ul>
5627</li>
5628<li>
5629
5630<p>Example:</p>
5631
5632<div>
5633<div>
5634<pre class="source">{
5635 &quot;start&quot;: get_interval_start(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5636 &quot;end&quot;: get_interval_end(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;))
5637};
5638</pre></div></div>
5639</li>
5640<li>
5641
5642<p>The expected result is:</p>
5643
5644<div>
5645<div>
5646<pre class="source">{ &quot;start&quot;: date(&quot;1984_01_01&quot;), &quot;end&quot;: date(&quot;1985_01_01&quot;) }
5647</pre></div></div>
5648</li>
5649</ul></div>
5650<div class="section">
5651<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>
5652<ul>
5653
5654<li>
5655
5656<p>Syntax:</p>
5657
5658<div>
5659<div>
5660<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)
5661</pre></div></div>
5662</li>
5663<li>
5664
5665<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5666</li>
5667<li>Arguments:
5668<ul>
5669
5670<li><tt>interval</tt>: the interval to be accessed.</li>
5671</ul>
5672</li>
5673<li>Return Value:
5674<ul>
5675
5676<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the function) representing the starting or ending time,</li>
5677<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5678<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5679<li>any other non-interval value will cause a type error.</li>
5680</ul>
5681</li>
5682<li>
5683
5684<p>Example:</p>
5685
5686<div>
5687<div>
5688<pre class="source">{
5689 &quot;start1&quot;: get_interval_start_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5690 &quot;end1&quot;: get_interval_end_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5691 &quot;start2&quot;: get_interval_start_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5692 &quot;end2&quot;: get_interval_end_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5693 &quot;start3&quot;: get_interval_start_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;)),
5694 &quot;end3&quot;: get_interval_end_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;))
5695};
5696</pre></div></div>
5697</li>
5698<li>
5699
5700<p>The expected result is:</p>
5701
5702<div>
5703<div>
5704<pre class="source">{
5705 &quot;start1&quot;: date(&quot;1984-01-01&quot;),
5706 &quot;end1&quot;: date(&quot;1985-01-01&quot;),
5707 &quot;start2&quot;: datetime(&quot;1984-01-01T08:30:00.000Z&quot;),
5708 &quot;end2&quot;: datetime(&quot;1985-01-01T09:30:00.000Z&quot;),
5709 &quot;start3&quot;: time(&quot;08:30:00.000Z&quot;),
5710 &quot;end3&quot;: time(&quot;09:30:00.000Z&quot;)
5711}
5712</pre></div></div>
5713</li>
5714</ul></div>
5715<div class="section">
5716<h3><a name="get_overlapping_interval"></a>get_overlapping_interval</h3>
5717<ul>
5718
5719<li>
5720
5721<p>Syntax:</p>
5722
5723<div>
5724<div>
5725<pre class="source">get_overlapping_interval(interval1, interval2)
5726</pre></div></div>
5727</li>
5728<li>
5729
5730<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5731</li>
5732<li>Arguments:
5733<ul>
5734
5735<li><tt>interval1</tt>: an <tt>interval</tt> value</li>
5736<li><tt>interval2</tt>: an <tt>interval</tt> value</li>
5737</ul>
5738</li>
5739<li>Return Value:
5740<ul>
5741
5742<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>
5743<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5744<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5745<li>any other non-interval input value will cause a type error.</li>
5746</ul>
5747</li>
5748<li>
5749
5750<p>Example:</p>
5751
5752<div>
5753<div>
5754<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;))),
5755 &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;))),
5756 &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;))),
5757 &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;))),
5758 &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;))),
5759 &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;)))
5760};
5761</pre></div></div>
5762</li>
5763<li>
5764
5765<p>The expected result is:</p>
5766
5767<div>
5768<div>
5769<pre class="source">{ &quot;overlap1&quot;: interval(time(&quot;12:23:39.000Z&quot;), time(&quot;18:27:19.000Z&quot;)),
5770 &quot;overlap2&quot;: null,
5771 &quot;overlap3&quot;: null,
5772 &quot;overlap4&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2014_01_01&quot;)),
5773 &quot;overlap5&quot;: interval(datetime(&quot;1989-03-04T12:23:39.000Z&quot;), datetime(&quot;2000-10-30T18:27:19.000Z&quot;)),
5774 &quot;overlap6&quot;: null
5775}
5776</pre></div></div>
5777</li>
5778</ul></div>
5779<div class="section">
5780<h3><a name="interval_bin"></a>interval_bin</h3>
5781<ul>
5782
5783<li>
5784
5785<p>Syntax:</p>
5786
5787<div>
5788<div>
5789<pre class="source">interval_bin(time_to_bin, time_bin_anchor, duration_bin_size)
5790</pre></div></div>
5791</li>
5792<li>
5793
5794<p>Returns the <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value.</p>
5795</li>
5796<li>Arguments:
5797<ul>
5798
5799<li><tt>time_to_bin</tt>: a date/time/datetime value representing the time to be binned.</li>
5800<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>
5801<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:
5802<ul>
5803
5804<li>datetime +|_ year_month_duration</li>
5805<li>datetime +|_ day_time_duration</li>
5806<li>date +|_ year_month_duration</li>
5807<li>date +|_ day_time_duration</li>
5808<li>time +|_ day_time_duration</li>
5809</ul>
5810</li>
5811</ul>
5812</li>
5813<li>Return Value:
5814<ul>
5815
5816<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>
5817<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5818<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5819<li>a type error will be raised if:
5820<ul>
5821
5822<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5823<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5824</ul>
5825</li>
5826</ul>
5827</li>
5828<li>
5829
5830<p>Example:</p>
5831
5832<div>
5833<div>
5834<pre class="source">{
5835 &quot;bin1&quot;: interval_bin(date(&quot;2010-10-30&quot;), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P1Y&quot;)),
5836 &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;)),
5837 &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;)),
5838 &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;))
5839};
5840</pre></div></div>
5841</li>
5842<li>
5843
5844<p>The expected result is:</p>
5845
5846<div>
5847<div>
5848<pre class="source">{
5849 &quot;bin1&quot;: interval(date(&quot;2010-01-01&quot;),date(&quot;2011-01-01&quot;)),
5850 &quot;bin2&quot;: interval(datetime(&quot;1987-07-01T00:00:00.000Z&quot;), datetime(&quot;1988-01-01T00:00:00.000Z&quot;)),
5851 &quot;bin3&quot;: interval(time(&quot;05:23:00.000Z&quot;), time(&quot;05:24:00.000Z&quot;)),
5852 &quot;bin4&quot;: interval(datetime(&quot;1987-11-19T00:00:00.000Z&quot;), datetime(&quot;1987-11-20T00:00:00.000Z&quot;))
5853}
5854</pre></div></div>
5855</li>
5856</ul></div>
5857<div class="section">
5858<h3><a name="interval_start_from_date.2Ftime.2Fdatetime"></a>interval_start_from_date/time/datetime</h3>
5859<ul>
5860
5861<li>
5862
5863<p>Syntax:</p>
5864
5865<div>
5866<div>
5867<pre class="source">interval_start_from_date/time/datetime(date/time/datetime, duration)
5868</pre></div></div>
5869</li>
5870<li>
5871
5872<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>
5873</li>
5874<li>Arguments:
5875<ul>
5876
5877<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>
5878<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>
5879</ul>
5880</li>
5881<li>Return Value:
5882<ul>
5883
5884<li>an <tt>interval</tt> value representing the interval starting from the given time point with the length of duration,</li>
5885<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5886<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5887<li>a type error will be raised if:
5888<ul>
5889
5890<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5891<li>or, the second argument is any other non-duration value.</li>
5892</ul>
5893</li>
5894</ul>
5895</li>
5896<li>
5897
5898<p>Example:</p>
5899
5900<div>
5901<div>
5902<pre class="source">{
5903 &quot;interval1&quot;: interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;),
5904 &quot;interval2&quot;: interval_start_from_time(time(&quot;02:23:28.394&quot;), &quot;PT3H24M&quot;),
5905 &quot;interval3&quot;: interval_start_from_datetime(&quot;1999-09-09T09:09:09.999&quot;, duration(&quot;P2M30D&quot;))
5906};
5907</pre></div></div>
5908</li>
5909<li>
5910
5911<p>The expectecd result is:</p>
5912
5913<div>
5914<div>
5915<pre class="source">{
5916 &quot;interval1&quot;: interval(date(&quot;1984-01-01&quot;), date(&quot;1985-01-01&quot;)),
5917 &quot;interval2&quot;: interval(time(&quot;02:23:28.394Z&quot;), time(&quot;05:47:28.394Z&quot;)),
5918 &quot;interval3&quot;: interval(datetime(&quot;1999-09-09T09:09:09.999Z&quot;), datetime(&quot;1999-12-09T09:09:09.999Z&quot;))
5919}
5920</pre></div></div>
5921</li>
5922</ul></div>
5923<div class="section">
5924<h3><a name="overlap_bins"></a>overlap_bins</h3>
5925<ul>
5926
5927<li>
5928
5929<p>Return Value:</p>
5930<ul>
5931
5932<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>
5933</ul>
5934</li>
5935<li>
5936
5937<p>Syntax:</p>
5938
5939<div>
5940<div>
5941<pre class="source">overlap_bins(interval, time_bin_anchor, duration_bin_size)
5942</pre></div></div>
5943</li>
5944<li>
5945
5946<p>Returns an ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>.</p>
5947</li>
5948<li>Arguments:
5949<ul>
5950
5951<li><tt>interval</tt>: an <tt>interval</tt> value</li>
5952<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>
5953<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:
5954<ul>
5955
5956<li>datetime +|_ year_month_duration</li>
5957<li>datetime +|_ day_time_duration</li>
5958<li>date +|_ year_month_duration</li>
5959<li>date +|_ day_time_duration</li>
5960<li>time +|_ day_time_duration</li>
5961</ul>
5962</li>
5963</ul>
5964</li>
5965<li>Return Value:
5966<ul>
5967
5968<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>
5969<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5970<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5971<li>a type error will be raised if:
5972<ul>
5973
5974<li>the first arugment is any other non-interval value,</li>
5975<li>or, the second argument is any other non-date/non-time/non-datetime value,</li>
5976<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5977</ul>
5978</li>
5979</ul>
5980</li>
5981<li>
5982
5983<p>Example:</p>
5984
5985<div>
5986<div>
5987<pre class="source">{
5988 &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;)),
5989 &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;)),
5990 &quot;datetimebins&quot;: overlap_bins(interval(datetime(&quot;1800-01-01T23:59:48.938&quot;), datetime(&quot;2015-07-26T13:28:30.218&quot;)),
5991 datetime(&quot;1900-01-01T00:00:00.000&quot;), year_month_duration(&quot;P100Y&quot;))
5992};
5993</pre></div></div>
5994</li>
5995<li>
5996
5997<p>The expected result is:</p>
5998
5999<div>
6000<div>
6001<pre class="source">{
6002 &quot;timebins&quot;: [
6003 interval(time(&quot;17:00:00.000Z&quot;), time(&quot;17:30:00.000Z&quot;)),
6004 interval(time(&quot;17:30:00.000Z&quot;), time(&quot;18:00:00.000Z&quot;)),
6005 interval(time(&quot;18:00:00.000Z&quot;), time(&quot;18:30:00.000Z&quot;)),
6006 interval(time(&quot;18:30:00.000Z&quot;), time(&quot;19:00:00.000Z&quot;))
6007 ],
6008 &quot;datebins&quot;: [
6009 interval(date(&quot;1980-01-01&quot;), date(&quot;1990-01-01&quot;)),
6010 interval(date(&quot;1990-01-01&quot;), date(&quot;2000-01-01&quot;)),
6011 interval(date(&quot;2000-01-01&quot;), date(&quot;2010-01-01&quot;)),
6012 interval(date(&quot;2010-01-01&quot;), date(&quot;2020-01-01&quot;))
6013 ],
6014 &quot;datetimebins&quot;: [
6015 interval(datetime(&quot;1800-01-01T00:00:00.000Z&quot;), datetime(&quot;1900-01-01T00:00:00.000Z&quot;)),
6016 interval(datetime(&quot;1900-01-01T00:00:00.000Z&quot;), datetime(&quot;2000-01-01T00:00:00.000Z&quot;)),
6017 interval(datetime(&quot;2000-01-01T00:00:00.000Z&quot;), datetime(&quot;2100-01-01T00:00:00.000Z&quot;))
6018 ]
6019};
6020</pre></div></div>
6021</li>
6022</ul><!--
6023 ! Licensed to the Apache Software Foundation (ASF) under one
6024 ! or more contributor license agreements. See the NOTICE file
6025 ! distributed with this work for additional information
6026 ! regarding copyright ownership. The ASF licenses this file
6027 ! to you under the Apache License, Version 2.0 (the
6028 ! "License"); you may not use this file except in compliance
6029 ! with the License. You may obtain a copy of the License at
6030 !
6031 ! http://www.apache.org/licenses/LICENSE-2.0
6032 !
6033 ! Unless required by applicable law or agreed to in writing,
6034 ! software distributed under the License is distributed on an
6035 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6036 ! KIND, either express or implied. See the License for the
6037 ! specific language governing permissions and limitations
6038 ! under the License.
6039 !-->
6040</div>
6041<div class="section">
6042<h3><a name="interval_before.2C_interval_after"></a>interval_before, interval_after</h3>
6043<ul>
6044
6045<li>
6046
6047<p>Syntax:</p>
6048
6049<div>
6050<div>
6051<pre class="source">interval_before(interval1, interval2)
6052interval_after(interval1, interval2)
6053</pre></div></div>
6054</li>
6055<li>
6056
6057<p>These two functions check whether an interval happens before/after another interval.</p>
6058</li>
6059<li>Arguments:
6060<ul>
6061
6062<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6063</ul>
6064</li>
6065<li>Return Value:
6066<ul>
6067
6068<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>
6069<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6070<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6071<li>any other non-interval input value will cause a type error.</li>
6072</ul>
6073</li>
6074<li>
6075
6076<p>Examples:</p>
6077
6078<div>
6079<div>
6080<pre class="source">{
6081 &quot;interval_before&quot;: interval_before(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6082 interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;))),
6083 &quot;interval_after&quot;: interval_after(interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;)),
6084 interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)))
6085};
6086</pre></div></div>
6087</li>
6088<li>
6089
6090<p>The expected result is:</p>
6091
6092<div>
6093<div>
6094<pre class="source">{ &quot;interval_before&quot;: true, &quot;interval_after&quot;: true }
6095</pre></div></div>
6096</li>
6097</ul></div>
6098<div class="section">
6099<h3><a name="interval_covers.2C_interval_covered_by"></a>interval_covers, interval_covered_by</h3>
6100<ul>
6101
6102<li>
6103
6104<p>Syntax:</p>
6105
6106<div>
6107<div>
6108<pre class="source">interval_covers(interval1, interval2)
6109interval_covered_by(interval1, interval2)
6110</pre></div></div>
6111</li>
6112<li>
6113
6114<p>These two functions check whether one interval covers the other interval.</p>
6115</li>
6116<li>Arguments:
6117<ul>
6118
6119<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6120</ul>
6121</li>
6122<li>Return Value:
6123<ul>
6124
6125<li>
6126
6127<p>a <tt>boolean</tt> value. Specifically, <tt>interval_covers(interval1, interval2)</tt> is true if and only if</p>
6128<p>interval1.start &lt;= interval2.start AND interval1.end &gt;= interval2.end</p>
6129<p><tt>interval_covered_by(interval1, interval2)</tt> is true if and only if</p>
6130<p>interval2.start &lt;= interval1.start AND interval2.end &gt;= interval1.end</p>
6131</li>
6132<li>
6133
6134<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6135</li>
6136<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6137<li>any other non-interval input value will cause a type error.</li>
6138</ul>
6139</li>
6140<li>
6141
6142<p>Examples:</p>
6143
6144<div>
6145<div>
6146<pre class="source">{
6147 &quot;interval_covers&quot;: interval_covers(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6148 interval(date(&quot;2000-03-01&quot;), date(&quot;2004-09-09&quot;))),
6149 &quot;interval_covered_by&quot;: interval_covered_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6150 interval(date(&quot;2004-09-10&quot;), date(&quot;2012-08-01&quot;)))
6151};
6152</pre></div></div>
6153</li>
6154<li>
6155
6156<p>The expected result is:</p>
6157
6158<div>
6159<div>
6160<pre class="source">{ &quot;interval_covers&quot;: true, &quot;interval_covered_by&quot;: true }
6161</pre></div></div>
6162</li>
6163</ul></div>
6164<div class="section">
6165<h3><a name="interval_overlaps.2C_interval_overlapped_by"></a>interval_overlaps, interval_overlapped_by</h3>
6166<ul>
6167
6168<li>
6169
6170<p>Syntax:</p>
6171
6172<div>
6173<div>
6174<pre class="source">interval_overlaps(interval1, interval2)
6175interval_overlapped_by(interval1, interval2)
6176</pre></div></div>
6177</li>
6178<li>
6179
6180<p>These functions check whether two intervals overlap with each other.</p>
6181</li>
6182<li>Arguments:
6183<ul>
6184
6185<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6186</ul>
6187</li>
6188<li>Return Value:
6189<ul>
6190
6191<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlaps(interval1, interval2)</tt> is true if and only if
6192<p>interval1.start &lt; interval2.start AND interval2.end &gt; interval1.end AND interval1.end &gt; interval2.start</p></li>
6193</ul>
6194<p><tt>interval_overlapped_by(interval1, interval2)</tt> is true if and only if</p>
6195
6196<div>
6197<div>
6198<pre class="source">interval2.start &lt; interval1.start
6199AND interval1.end &gt; interval2.end
6200AND interval2.end &gt; interval1.start
6201</pre></div></div>
6202
6203<ul>
6204
6205<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6206<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6207<li>any other non-interval input value will cause a type error.</li>
6208</ul>
6209<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>
6210</li>
6211<li>
6212
6213<p>Examples:</p>
6214
6215<div>
6216<div>
6217<pre class="source">{
6218 &quot;overlaps&quot;: interval_overlaps(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6219 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6220 &quot;overlapped_by&quot;: interval_overlapped_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6221 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))))
6222};
6223</pre></div></div>
6224</li>
6225<li>
6226
6227<p>The expected result is:</p>
6228
6229<div>
6230<div>
6231<pre class="source">{ &quot;overlaps&quot;: true, &quot;overlapped_by&quot;: true }
6232</pre></div></div>
6233</li>
6234</ul></div>
6235<div class="section">
6236<h3><a name="interval_overlapping"></a>interval_overlapping</h3>
6237<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>
6238<ul>
6239
6240<li>
6241
6242<p>Syntax:</p>
6243
6244<div>
6245<div>
6246<pre class="source">interval_overlapping(interval1, interval2)
6247</pre></div></div>
6248</li>
6249<li>
6250
6251<p>This functions check whether two intervals share any points with each other.</p>
6252</li>
6253<li>Arguments:
6254<ul>
6255
6256<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6257</ul>
6258</li>
6259<li>Return Value:
6260<ul>
6261
6262<li>
6263
6264<p>a <tt>boolean</tt> value. Specifically, <tt>interval_overlapping(interval1, interval2)</tt> is true if</p>
6265<p>interval1.start &lt; interval2.end AND interval1.end &gt; interval2.start</p>
6266</li>
6267<li>
6268
6269<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6270</li>
6271<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6272<li>any other non-interval input value will cause a type error.</li>
6273</ul>
6274</li>
6275<li>
6276
6277<p>Examples:</p>
6278
6279<div>
6280<div>
6281<pre class="source">{
6282 &quot;overlapping1&quot;: interval_overlapping(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6283 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6284 &quot;overlapping2&quot;: interval_overlapping(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6285 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-12-31&quot;)))
6286};
6287</pre></div></div>
6288</li>
6289<li>
6290
6291<p>The expected result is:</p>
6292
6293<div>
6294<div>
6295<pre class="source">{ &quot;overlapping1&quot;: true, &quot;overlapping2&quot;: true }
6296</pre></div></div>
6297</li>
6298</ul></div>
6299<div class="section">
6300<h3><a name="interval_meets.2C_interval_met_by"></a>interval_meets, interval_met_by</h3>
6301<ul>
6302
6303<li>
6304
6305<p>Syntax:</p>
6306
6307<div>
6308<div>
6309<pre class="source">interval_meets(interval1, interval2)
6310interval_met_by(interval1, interval2)
6311</pre></div></div>
6312</li>
6313<li>
6314
6315<p>These two functions check whether an interval meets with another interval.</p>
6316</li>
6317<li>Arguments:
6318<ul>
6319
6320<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6321</ul>
6322</li>
6323<li>Return Value:
6324<ul>
6325
6326<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>
6327<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6328<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6329<li>any other non-interval input value will cause a type error.</li>
6330</ul>
6331</li>
6332<li>
6333
6334<p>Examples:</p>
6335
6336<div>
6337<div>
6338<pre class="source">{
6339 &quot;meets&quot;: interval_meets(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6340 interval(date(&quot;2005-01-01&quot;), date(&quot;2012-09-09&quot;))),
6341 &quot;metby&quot;: interval_met_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6342 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-08-01&quot;)))
6343};
6344</pre></div></div>
6345</li>
6346<li>
6347
6348<p>The expected result is:</p>
6349
6350<div>
6351<div>
6352<pre class="source">{ &quot;meets&quot;: true, &quot;metby&quot;: true }
6353</pre></div></div>
6354</li>
6355</ul></div>
6356<div class="section">
6357<h3><a name="interval_starts.2C_interval_started_by"></a>interval_starts, interval_started_by</h3>
6358<ul>
6359
6360<li>
6361
6362<p>Syntax:</p>
6363
6364<div>
6365<div>
6366<pre class="source">interval_starts(interval1, interval2)
6367interval_started_by(interval1, interval2)
6368</pre></div></div>
6369</li>
6370<li>
6371
6372<p>These two functions check whether one interval starts with the other interval.</p>
6373</li>
6374<li>Arguments:
6375<ul>
6376
6377<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6378</ul>
6379</li>
6380<li>Return Value:
6381<ul>
6382
6383<li>a <tt>boolean</tt> value. Specifically, <tt>interval_starts(interval1, interval2)</tt> returns true if and only if
6384<p>interval1.start = interval2.start AND interval1.end &lt;= interval2.end</p></li>
6385</ul>
6386<p><tt>interval_started_by(interval1, interval2)</tt> returns true if and only if</p>
6387
6388<div>
6389<div>
6390<pre class="source">interval1.start = interval2.start
6391AND interval2.end &lt;= interval1.end
6392</pre></div></div>
6393
6394<ul>
6395
6396<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6397<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6398<li>any other non-interval input value will cause a type error.</li>
6399</ul>
6400</li>
6401<li>
6402
6403<p>Examples:</p>
6404
6405<div>
6406<div>
6407<pre class="source">{
6408 &quot;interval_starts&quot;: interval_starts(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6409 interval(date(&quot;2000-01-01&quot;), date(&quot;2012-09-09&quot;))),
6410 &quot;interval_started_by&quot;: interval_started_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6411 interval(date(&quot;2006-08-01&quot;), date(&quot;2006-08-02&quot;)))
6412};
6413</pre></div></div>
6414</li>
6415<li>
6416
6417<p>The expected result is:</p>
6418
6419<div>
6420<div>
6421<pre class="source">{ &quot;interval_starts&quot;: true, &quot;interval_started_by&quot;: true }
6422</pre></div></div>
6423</li>
6424</ul></div>
6425<div class="section">
6426<h3><a name="interval_ends.2C_interval_ended_by"></a>interval_ends, interval_ended_by</h3>
6427<ul>
6428
6429<li>
6430
6431<p>Syntax:</p>
6432
6433<div>
6434<div>
6435<pre class="source">interval_ends(interval1, interval2)
6436interval_ended_by(interval1, interval2)
6437</pre></div></div>
6438</li>
6439<li>
6440
6441<p>These two functions check whether one interval ends with the other interval.</p>
6442</li>
6443<li>Arguments:
6444<ul>
6445
6446<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6447</ul>
6448</li>
6449<li>Return Value:
6450<ul>
6451
6452<li>
6453
6454<p>a <tt>boolean</tt> value. Specifically, <tt>interval_ends(interval1, interval2)</tt> returns true if and only if</p>
6455<p>interval1.end = interval2.end AND interval1.start &gt;= interval2.start</p>
6456<p><tt>interval_ended_by(interval1, interval2)</tt> returns true if and only if</p>
6457<p>interval2.end = interval1.end AND interval2.start &gt;= interval1.start</p>
6458</li>
6459<li>
6460
6461<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6462</li>
6463<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6464<li>any other non-interval input value will cause a type error.</li>
6465</ul>
6466</li>
6467<li>
6468
6469<p>Examples:</p>
6470
6471<div>
6472<div>
6473<pre class="source">{
6474 &quot;interval_ends&quot;: interval_ends(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6475 interval(date(&quot;1998-01-01&quot;), date(&quot;2005-01-01&quot;))),
6476 &quot;interval_ended_by&quot;: interval_ended_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6477 interval(date(&quot;2006-09-10&quot;), date(&quot;2007-03-01&quot;)))
6478};
6479</pre></div></div>
6480</li>
6481<li>
6482
6483<p>The expected result is:</p>
6484
6485<div>
6486<div>
6487<pre class="source">{ &quot;interval_ends&quot;: true, &quot;interval_ended_by&quot;: true }
6488</pre></div></div>
6489</li>
6490</ul><!--
6491 ! Licensed to the Apache Software Foundation (ASF) under one
6492 ! or more contributor license agreements. See the NOTICE file
6493 ! distributed with this work for additional information
6494 ! regarding copyright ownership. The ASF licenses this file
6495 ! to you under the Apache License, Version 2.0 (the
6496 ! "License"); you may not use this file except in compliance
6497 ! with the License. You may obtain a copy of the License at
6498 !
6499 ! http://www.apache.org/licenses/LICENSE-2.0
6500 !
6501 ! Unless required by applicable law or agreed to in writing,
6502 ! software distributed under the License is distributed on an
6503 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6504 ! KIND, either express or implied. See the License for the
6505 ! specific language governing permissions and limitations
6506 ! under the License.
6507 !-->
6508</div></div>
6509<div class="section">
6510<h2><a name="Object_Functions"></a><a name="ObjectFunctions" id="ObjectFunctions">Object Functions</a></h2>
6511<div class="section">
6512<h3><a name="get_object_fields"></a>get_object_fields</h3>
6513<ul>
6514
6515<li>
6516
6517<p>Syntax:</p>
6518
6519<div>
6520<div>
6521<pre class="source">get_object_fields(input_object)
6522</pre></div></div>
6523</li>
6524<li>
6525
6526<p>Access the object field names, type and open status for a given object.</p>
6527</li>
6528<li>Arguments:
6529<ul>
6530
6531<li><tt>input_object</tt> : a object value.</li>
6532</ul>
6533</li>
6534<li>Return Value:
6535<ul>
6536
6537<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>
6538<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6539<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
6540<li>any other non-object input value will cause a type error.</li>
6541</ul>
6542</li>
6543<li>
6544
6545<p>Example:</p>
6546
6547<div>
6548<div>
6549<pre class="source">get_object_fields(
6550 {
6551 &quot;id&quot;: 1,
6552 &quot;project&quot;: &quot;AsterixDB&quot;,
6553 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6554 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6555 }
6556 );
6557</pre></div></div>
6558</li>
6559<li>
6560
6561<p>The expected result is:</p>
6562
6563<div>
6564<div>
6565<pre class="source">[
6566 { &quot;field-name&quot;: &quot;id&quot;, &quot;field-type&quot;: &quot;INT64&quot;, &quot;is-open&quot;: false },
6567 { &quot;field-name&quot;: &quot;project&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6568 { &quot;field-name&quot;: &quot;address&quot;, &quot;field-type&quot;: &quot;RECORD&quot;, &quot;is-open&quot;: false,
6569 &quot;nested&quot;: [
6570 { &quot;field-name&quot;: &quot;city&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6571 { &quot;field-name&quot;: &quot;state&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false }
6572 ]
6573 },
6574 { &quot;field-name&quot;:
6575 &quot;related&quot;,
6576 &quot;field-type&quot;: &quot;ORDEREDLIST&quot;,
6577 &quot;is-open&quot;: false,
6578 &quot;list&quot;: [
6579 { &quot;field-type&quot;: &quot;STRING&quot; },
6580 { &quot;field-type&quot;: &quot;STRING&quot; },
6581 { &quot;field-type&quot;: &quot;STRING&quot; }
6582 ]
6583 }
6584]
6585</pre></div></div>
6586</li>
6587</ul>
6588<p>]</p></div>
6589<div class="section">
6590<h3><a name="get_object_field_value"></a>get_object_field_value</h3>
6591<ul>
6592
6593<li>
6594
6595<p>Syntax:</p>
6596
6597<div>
6598<div>
6599<pre class="source">get_object_field_value(input_object, string)
6600</pre></div></div>
6601</li>
6602<li>
6603
6604<p>Access the field name given in the <tt>string_expression</tt> from the <tt>object_expression</tt>.</p>
6605</li>
6606<li>Arguments:
6607<ul>
6608
6609<li><tt>input_object</tt> : a <tt>object</tt> value.</li>
6610<li><tt>string</tt> : a <tt>string</tt> representing the top level field name.</li>
6611</ul>
6612</li>
6613<li>Return Value:
6614<ul>
6615
6616<li>an <tt>any</tt> value saved in the designated field of the object,</li>
6617<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6618<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6619<li>a type error will be raised if:
6620<ul>
6621
6622<li>the first argument is any other non-object value,</li>
6623<li>or, the second argument is any other non-string value.</li>
6624</ul>
6625</li>
6626</ul>
6627</li>
6628<li>
6629
6630<p>Example:</p>
6631
6632<div>
6633<div>
6634<pre class="source">get_object_field_value({
6635 &quot;id&quot;: 1,
6636 &quot;project&quot;: &quot;AsterixDB&quot;,
6637 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6638 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6639 },
6640 &quot;project&quot;
6641 );
6642</pre></div></div>
6643</li>
6644<li>
6645
6646<p>The expected result is:</p>
6647
6648<div>
6649<div>
6650<pre class="source">&quot;AsterixDB&quot;
6651</pre></div></div>
6652</li>
6653</ul></div>
6654<div class="section">
6655<h3><a name="object_remove_fields"></a>object_remove_fields</h3>
6656<ul>
6657
6658<li>
6659
6660<p>Syntax:</p>
6661
6662<div>
6663<div>
6664<pre class="source">object_remove_fields(input_object, field_names)
6665</pre></div></div>
6666</li>
6667<li>
6668
6669<p>Remove indicated fields from a object given a list of field names.</p>
6670</li>
6671<li>Arguments:
6672<ul>
6673
6674<li><tt>input_object</tt>: a object value.</li>
6675<li><tt>field_names</tt>: an array of strings and/or array of array of strings.</li>
6676</ul>
6677</li>
6678<li>
6679
6680<p>Return Value:</p>
6681<ul>
6682
6683<li>a new object value without the fields listed in the second argument,</li>
6684<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6685<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6686<li>a type error will be raised if:
6687<ul>
6688
6689<li>the first argument is any other non-object value,</li>
6690<li>or, the second argument is any other non-array value or recursively contains non-string items.</li>
6691</ul>
6692</li>
6693</ul>
6694</li>
6695<li>
6696
6697<p>Example:</p>
6698
6699<div>
6700<div>
6701<pre class="source">object_remove_fields(
6702 {
6703 &quot;id&quot;:1,
6704 &quot;project&quot;:&quot;AsterixDB&quot;,
6705 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6706 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6707 },
6708 [[&quot;address&quot;, &quot;city&quot;], &quot;related&quot;]
6709 );
6710</pre></div></div>
6711</li>
6712<li>
6713
6714<p>The expected result is:</p>
6715
6716<div>
6717<div>
6718<pre class="source">{
6719 &quot;id&quot;:1,
6720 &quot;project&quot;:&quot;AsterixDB&quot;,
6721 &quot;address&quot;:{ &quot;state&quot;: &quot;CA&quot; }
6722}
6723</pre></div></div>
6724</li>
6725</ul></div>
6726<div class="section">
6727<h3><a name="object_add_fields"></a>object_add_fields</h3>
6728<ul>
6729
6730<li>
6731
6732<p>Syntax:</p>
6733
6734<div>
6735<div>
6736<pre class="source">object_add_fields(input_object, fields)
6737</pre></div></div>
6738</li>
6739<li>
6740
6741<p>Add fields to a object given a list of field names.</p>
6742</li>
6743<li>Arguments:
6744<ul>
6745
6746<li><tt>input_object</tt> : a object value.</li>
6747<li><tt>fields</tt>: an array of field descriptor objects where each object has field_name and field_value.</li>
6748</ul>
6749</li>
6750<li>Return Value:
6751<ul>
6752
6753<li>a new object value with the new fields included,</li>
6754<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6755<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6756<li>a type error will be raised if:
6757<ul>
6758
6759<li>the first argument is any other non-object value,</li>
6760<li>the second argument is any other non-array value, or contains non-object items.</li>
6761</ul>
6762</li>
6763</ul>
6764</li>
6765<li>
6766
6767<p>Example:</p>
6768
6769<div>
6770<div>
6771<pre class="source">object_add_fields(
6772 {
6773 &quot;id&quot;:1,
6774 &quot;project&quot;:&quot;AsterixDB&quot;,
6775 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6776 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6777 },
6778 [{&quot;field-name&quot;:&quot;employment_location&quot;, &quot;field-value&quot;:create_point(30.0,70.0)}]
6779 );
6780</pre></div></div>
6781</li>
6782<li>
6783
6784<p>The expected result is:</p>
6785
6786<div>
6787<div>
6788<pre class="source">{
6789 &quot;id&quot;:1,
6790 &quot;project&quot;:&quot;AsterixDB&quot;,
6791 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6792 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6793 &quot;employment_location&quot;: point(&quot;30.0,70.0&quot;)
6794 }
6795</pre></div></div>
6796</li>
6797</ul></div>
6798<div class="section">
6799<h3><a name="object_merge"></a>object_merge</h3>
6800<ul>
6801
6802<li>
6803
6804<p>Syntax:</p>
6805
6806<div>
6807<div>
6808<pre class="source">object_merge(object1, object2)
6809</pre></div></div>
6810</li>
6811<li>
6812
6813<p>Merge two different objects into a new object.</p>
6814</li>
6815<li>Arguments:
6816<ul>
6817
6818<li><tt>object1</tt> : a object value.</li>
6819<li><tt>object2</tt> : a object value.</li>
6820</ul>
6821</li>
6822<li>Return Value:
6823<ul>
6824
6825<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>
6826<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6827<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6828<li>any other non-object input value will cause a type error.</li>
6829</ul>
6830</li>
6831<li>
6832
6833<p>Example:</p>
6834
6835<div>
6836<div>
6837<pre class="source">object_merge(
6838 {
6839 &quot;id&quot;:1,
6840 &quot;project&quot;:&quot;AsterixDB&quot;,
6841 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6842 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6843 },
6844 {
6845 &quot;user_id&quot;: 22,
6846 &quot;employer&quot;: &quot;UC Irvine&quot;,
6847 &quot;employment_type&quot;: &quot;visitor&quot;
6848 }
6849 );
6850</pre></div></div>
6851</li>
6852<li>
6853
6854<p>The expected result is:</p>
6855
6856<div>
6857<div>
6858<pre class="source">{
6859 &quot;employment_type&quot;: &quot;visitor&quot;,
6860 &quot;address&quot;: {
6861 &quot;city&quot;: &quot;Irvine&quot;,
6862 &quot;state&quot;: &quot;CA&quot;
6863 },
6864 &quot;related&quot;: [
6865 &quot;Hivestrix&quot;,
6866 &quot;Preglix&quot;,
6867 &quot;Apache VXQuery&quot;
6868 ],
6869 &quot;user_id&quot;: 22,
6870 &quot;project&quot;: &quot;AsterixDB&quot;,
6871 &quot;employer&quot;: &quot;UC Irvine&quot;,
6872 &quot;id&quot;: 1
6873}
6874</pre></div></div>
6875</li>
6876</ul></div>
6877<div class="section">
6878<h3><a name="object_length"></a>object_length</h3>
6879<ul>
6880
6881<li>
6882
6883<p>Syntax:</p>
6884
6885<div>
6886<div>
6887<pre class="source">object_length(input_object)
6888</pre></div></div>
6889</li>
6890<li>
6891
6892<p>Returns number of top-level fields in the given object</p>
6893</li>
6894<li>Arguments:
6895<ul>
6896
6897<li><tt>input_object</tt> : an object value.</li>
6898</ul>
6899</li>
6900<li>Return Value:
6901<ul>
6902
6903<li>an integer that represents the number of top-level fields in the given object,</li>
6904<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6905<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
6906</ul>
6907</li>
6908<li>
6909
6910<p>Example:</p>
6911
6912<div>
6913<div>
6914<pre class="source">object_length(
6915 {
6916 &quot;id&quot;: 1,
6917 &quot;project&quot;: &quot;AsterixDB&quot;,
6918 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6919 }
6920 );
6921</pre></div></div>
6922</li>
6923<li>
6924
6925<p>The expected result is:</p>
6926
6927<div>
6928<div>
6929<pre class="source">3
6930</pre></div></div>
6931</li>
6932</ul></div>
6933<div class="section">
6934<h3><a name="object_names"></a>object_names</h3>
6935<ul>
6936
6937<li>
6938
6939<p>Syntax:</p>
6940
6941<div>
6942<div>
6943<pre class="source">object_names(input_object)
6944</pre></div></div>
6945</li>
6946<li>
6947
6948<p>Returns names of top-level fields in the given object</p>
6949</li>
6950<li>Arguments:
6951<ul>
6952
6953<li><tt>input_object</tt> : an object value.</li>
6954</ul>
6955</li>
6956<li>Return Value:
6957<ul>
6958
6959<li>an array with top-level field names of the given object,</li>
6960<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6961<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
6962</ul>
6963</li>
6964<li>
6965
6966<p>Example:</p>
6967
6968<div>
6969<div>
6970<pre class="source">object_names(
6971 {
6972 &quot;id&quot;: 1,
6973 &quot;project&quot;: &quot;AsterixDB&quot;,
6974 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6975 }
6976 );
6977</pre></div></div>
6978</li>
6979<li>
6980
6981<p>The expected result is:</p>
6982
6983<div>
6984<div>
6985<pre class="source">[ &quot;id&quot;, &quot;project&quot;, &quot;address&quot; ]
6986</pre></div></div>
6987</li>
6988</ul></div>
6989<div class="section">
6990<h3><a name="object_remove"></a>object_remove</h3>
6991<ul>
6992
6993<li>
6994
6995<p>Syntax:</p>
6996
6997<div>
6998<div>
6999<pre class="source">object_remove(input_object, field_name)
7000</pre></div></div>
7001</li>
7002<li>
7003
7004<p>Returns a new object that has the same fields as the input object except the field to be removed</p>
7005</li>
7006<li>Arguments:
7007<ul>
7008
7009<li><tt>input_object</tt> : an object value.</li>
7010<li><tt>field_name</tt> : a string field name.</li>
7011</ul>
7012</li>
7013<li>Return Value:
7014<ul>
7015
7016<li>A new object that has the same fields as <tt>input_object</tt> except the field <tt>field_name</tt>,</li>
7017<li><tt>missing</tt> if the argument <tt>input_object</tt> or <tt>field_name</tt> is missing,</li>
7018<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>
7019</ul>
7020</li>
7021<li>
7022
7023<p>Example:</p>
7024
7025<div>
7026<div>
7027<pre class="source">object_remove(
7028 {
7029 &quot;id&quot;: 1,
7030 &quot;project&quot;: &quot;AsterixDB&quot;,
7031 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7032 }
7033 , &quot;address&quot;
7034 );
7035</pre></div></div>
7036</li>
7037<li>
7038
7039<p>The expected result is:</p>
7040
7041<div>
7042<div>
7043<pre class="source">{
7044 &quot;id&quot;: 1,
7045 &quot;project&quot;: &quot;AsterixDB&quot;,
7046}
7047</pre></div></div>
7048</li>
7049</ul></div>
7050<div class="section">
7051<h3><a name="object_rename"></a>object_rename</h3>
7052<ul>
7053
7054<li>
7055
7056<p>Syntax:</p>
7057
7058<div>
7059<div>
7060<pre class="source">object_rename(input_object, old_field, new_field)
7061</pre></div></div>
7062</li>
7063<li>
7064
7065<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>
7066</li>
7067<li>Arguments:
7068<ul>
7069
7070<li><tt>input_object</tt> : an object value.</li>
7071<li><tt>old_field</tt> : a string representing the old (original) field name inside the object <tt>input_object</tt>.</li>
7072<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>
7073</ul>
7074</li>
7075<li>Return Value:
7076<ul>
7077
7078<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>
7079<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7080<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>
7081</ul>
7082</li>
7083<li>
7084
7085<p>Example:</p>
7086
7087<div>
7088<div>
7089<pre class="source">object_rename(
7090 {
7091 &quot;id&quot;: 1,
7092 &quot;project&quot;: &quot;AsterixDB&quot;,
7093 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7094 }
7095 , &quot;address&quot;
7096 , &quot;location&quot;
7097 );
7098</pre></div></div>
7099</li>
7100<li>
7101
7102<p>The expected result is:</p>
7103
7104<div>
7105<div>
7106<pre class="source">{
7107 &quot;id&quot;: 1,
7108 &quot;project&quot;: &quot;AsterixDB&quot;,
7109 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7110}
7111</pre></div></div>
7112</li>
7113</ul></div>
7114<div class="section">
7115<h3><a name="object_unwrap"></a>object_unwrap</h3>
7116<ul>
7117
7118<li>
7119
7120<p>Syntax:</p>
7121
7122<div>
7123<div>
7124<pre class="source">object_unwrap(input_object)
7125</pre></div></div>
7126</li>
7127<li>
7128
7129<p>Returns the value of the single name-value pair that appears in <tt>input_object</tt>.</p>
7130</li>
7131<li>Arguments:
7132<ul>
7133
7134<li><tt>input_object</tt> : an object value that consists of exactly one name-value pair.</li>
7135</ul>
7136</li>
7137<li>Return Value:
7138<ul>
7139
7140<li>The value of the single name-value pair that appears in <tt>input_object</tt>,</li>
7141<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7142<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>
7143</ul>
7144</li>
7145<li>
7146
7147<p>Example:</p>
7148
7149<div>
7150<div>
7151<pre class="source">object_unwrap(
7152 {
7153 &quot;id&quot;: 1
7154 }
7155 );
7156</pre></div></div>
7157</li>
7158<li>
7159
7160<p>The expected result is:</p>
7161
7162<div>
7163<div>
7164<pre class="source">{
7165 1
7166}
7167</pre></div></div>
7168</li>
7169</ul></div>
7170<div class="section">
7171<h3><a name="object_replace"></a>object_replace</h3>
7172<ul>
7173
7174<li>
7175
7176<p>Syntax:</p>
7177
7178<div>
7179<div>
7180<pre class="source">object_replace(input_object, old_value, new_value)
7181</pre></div></div>
7182</li>
7183<li>
7184
7185<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>
7186</li>
7187<li>Arguments:
7188<ul>
7189
7190<li><tt>input_object</tt> : an object value.</li>
7191<li><tt>old_value</tt> : a primitive type value to be replaced by <tt>new_value</tt>.</li>
7192<li><tt>new_value</tt> : a value to replace <tt>old_value</tt>.</li>
7193</ul>
7194</li>
7195<li>Return Value:
7196<ul>
7197
7198<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>
7199<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7200<li><tt>null</tt> if <tt>input_object</tt> or <tt>old_value</tt> is null,</li>
7201<li>a type error will be raised if:
7202<ul>
7203
7204<li><tt>old_value</tt> is not a primitive type value.</li>
7205</ul>
7206</li>
7207</ul>
7208</li>
7209<li>
7210
7211<p>Example:</p>
7212
7213<div>
7214<div>
7215<pre class="source">object_replace(
7216 {
7217 &quot;id&quot;: 1,
7218 &quot;project&quot;: &quot;AsterixDB&quot;,
7219 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7220 }
7221 , &quot;AsterixDB&quot;
7222 , &quot;Apache AsterixDB&quot;
7223 );
7224</pre></div></div>
7225</li>
7226<li>
7227
7228<p>The expected result is:</p>
7229
7230<div>
7231<div>
7232<pre class="source">{
7233 &quot;id&quot;: 1,
7234 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7235 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7236}
7237</pre></div></div>
7238</li>
7239</ul></div>
7240<div class="section">
7241<h3><a name="object_add"></a>object_add</h3>
7242<ul>
7243
7244<li>
7245
7246<p>Syntax:</p>
7247
7248<div>
7249<div>
7250<pre class="source">object_add(input_object, field_name, field_value)
7251</pre></div></div>
7252</li>
7253<li>
7254
7255<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>
7256</li>
7257<li>Arguments:
7258<ul>
7259
7260<li><tt>input_object</tt> : an object value.</li>
7261<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7262<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7263</ul>
7264</li>
7265<li>Return Value:
7266<ul>
7267
7268<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>
7269<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7270<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>
7271<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>
7272</ul>
7273</li>
7274<li>
7275
7276<p>Example:</p>
7277
7278<div>
7279<div>
7280<pre class="source">object_add(
7281 {
7282 &quot;id&quot;: 1,
7283 &quot;project&quot;: &quot;AsterixDB&quot;,
7284 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7285 }
7286 , &quot;company&quot;
7287 , &quot;Apache&quot;
7288 );
7289</pre></div></div>
7290</li>
7291<li>
7292
7293<p>The expected result is:</p>
7294
7295<div>
7296<div>
7297<pre class="source">{
7298 &quot;id&quot;: 1,
7299 &quot;project&quot;: &quot;AsterixDB&quot;,
7300 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7301 &quot;company&quot;: &quot;Apache&quot;
7302}
7303</pre></div></div>
7304</li>
7305</ul></div>
7306<div class="section">
7307<h3><a name="object_put"></a>object_put</h3>
7308<ul>
7309
7310<li>
7311
7312<p>Syntax:</p>
7313
7314<div>
7315<div>
7316<pre class="source">object_put(input_object, field_name, field_value)
7317</pre></div></div>
7318</li>
7319<li>
7320
7321<p>Adds, modifies, or removes a field of an object.</p>
7322</li>
7323<li>Arguments:
7324<ul>
7325
7326<li><tt>input_object</tt> : an object value.</li>
7327<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7328<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7329</ul>
7330</li>
7331<li>Return Value:
7332<ul>
7333
7334<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>
7335<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7336<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>
7337</ul>
7338</li>
7339<li>
7340
7341<p>Example:</p>
7342
7343<div>
7344<div>
7345<pre class="source">object_put(
7346 {
7347 &quot;id&quot;: 1,
7348 &quot;project&quot;: &quot;AsterixDB&quot;,
7349 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7350 }
7351 , &quot;project&quot;
7352 , &quot;Apache AsterixDB&quot;
7353 );
7354</pre></div></div>
7355</li>
7356<li>
7357
7358<p>The expected result is:</p>
7359
7360<div>
7361<div>
7362<pre class="source">{
7363 &quot;id&quot;: 1,
7364 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7365 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7366}
7367</pre></div></div>
7368</li>
7369</ul></div>
7370<div class="section">
7371<h3><a name="object_values"></a>object_values</h3>
7372<ul>
7373
7374<li>
7375
7376<p>Syntax:</p>
7377
7378<div>
7379<div>
7380<pre class="source">object_values(input_object)
7381</pre></div></div>
7382</li>
7383<li>
7384
7385<p>Returns an array of the values of the fields in <tt>input_object</tt>.</p>
7386</li>
7387<li>Arguments:
7388<ul>
7389
7390<li><tt>input_object</tt> : an object value.</li>
7391</ul>
7392</li>
7393<li>Return Value:
7394<ul>
7395
7396<li>An array of the values of the fields in <tt>input_object</tt>,</li>
7397<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7398<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7399</ul>
7400</li>
7401<li>
7402
7403<p>Example:</p>
7404
7405<div>
7406<div>
7407<pre class="source">object_values(
7408 {
7409 &quot;id&quot;: 1,
7410 &quot;project&quot;: &quot;AsterixDB&quot;,
7411 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7412 }
7413 );
7414</pre></div></div>
7415</li>
7416<li>
7417
7418<p>The expected result is:</p>
7419
7420<div>
7421<div>
7422<pre class="source">[
7423 1,
7424 &quot;AsterixDB&quot;,
7425 {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7426]
7427</pre></div></div>
7428</li>
7429</ul></div>
7430<div class="section">
7431<h3><a name="object_pairs"></a>object_pairs</h3>
7432<ul>
7433
7434<li>
7435
7436<p>Syntax:</p>
7437
7438<div>
7439<div>
7440<pre class="source">object_pairs(input_object)
7441</pre></div></div>
7442</li>
7443<li>
7444
7445<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>
7446</li>
7447<li>
7448
7449<p>Arguments:</p>
7450<ul>
7451
7452<li><tt>input_object</tt> : an object value.</li>
7453</ul>
7454</li>
7455<li>Return Value:
7456<ul>
7457
7458<li>An array of the <tt>name</tt>/<tt>value</tt> pairs of the fields in <tt>input_object</tt>,</li>
7459<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7460<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7461</ul>
7462</li>
7463<li>
7464
7465<p>Example:</p>
7466
7467<div>
7468<div>
7469<pre class="source">object_pairs(
7470 {
7471 &quot;id&quot;: 1,
7472 &quot;project&quot;: &quot;AsterixDB&quot;,
7473 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7474 }
7475 );
7476</pre></div></div>
7477</li>
7478<li>
7479
7480<p>The expected result is:</p>
7481
7482<div>
7483<div>
7484<pre class="source">[
7485 { &quot;name&quot;: &quot;id&quot;, &quot;value&quot;: 1 },
7486 { &quot;name&quot;: &quot;project&quot;, &quot;value&quot;: &quot;AsterixDB&quot; },
7487 { &quot;name&quot;: &quot;address&quot;, &quot;value&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;} }
7488]
7489</pre></div></div>
7490</li>
7491</ul></div>
7492<div class="section">
7493<h3><a name="pairs"></a>pairs</h3>
7494<ul>
7495
7496<li>
7497
7498<p>Syntax:</p>
7499
7500<div>
7501<div>
7502<pre class="source">pairs(input_object)
7503</pre></div></div>
7504</li>
7505<li>
7506
7507<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>
7508</li>
7509<li>
7510
7511<p>Arguments:</p>
7512<ul>
7513
7514<li><tt>input_object</tt> : an object value (or an array or a multiset)</li>
7515</ul>
7516</li>
7517<li>Return Value:
7518<ul>
7519
7520<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>
7521<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7522<li><tt>null</tt> if <tt>input_object</tt> is null or a value of a primitive data type.</li>
7523</ul>
7524</li>
7525<li>
7526
7527<p>Example:</p>
7528
7529<div>
7530<div>
7531<pre class="source">pairs(
7532 {
7533 &quot;id&quot;: 1,
7534 &quot;project&quot;: &quot;AsterixDB&quot;,
7535 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7536 }
7537 );
7538</pre></div></div>
7539</li>
7540<li>
7541
7542<p>The expected result is:</p>
7543
7544<div>
7545<div>
7546<pre class="source">[
7547 [ &quot;id&quot;, 1 ],
7548 [ &quot;project&quot;, &quot;AsterixDB&quot; ],
7549 [ &quot;address&quot;, { &quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot; } ],
7550 [ &quot;city&quot;, &quot;Irvine&quot; ],
7551 [ &quot;state&quot;, &quot;CA&quot; ]
7552]
7553</pre></div></div>
7554</li>
7555</ul><!--
7556 ! Licensed to the Apache Software Foundation (ASF) under one
7557 ! or more contributor license agreements. See the NOTICE file
7558 ! distributed with this work for additional information
7559 ! regarding copyright ownership. The ASF licenses this file
7560 ! to you under the Apache License, Version 2.0 (the
7561 ! "License"); you may not use this file except in compliance
7562 ! with the License. You may obtain a copy of the License at
7563 !
7564 ! http://www.apache.org/licenses/LICENSE-2.0
7565 !
7566 ! Unless required by applicable law or agreed to in writing,
7567 ! software distributed under the License is distributed on an
7568 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7569 ! KIND, either express or implied. See the License for the
7570 ! specific language governing permissions and limitations
7571 ! under the License.
7572 !-->
7573</div></div>
7574<div class="section">
7575<h2><a name="Aggregate_Functions_.28Array_Functions.29"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions (Array Functions) </a></h2>
7576<p>This section contains detailed descriptions of the built-in aggregate functions in the query language.</p>
7577<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#SQL-92_aggregation_functions">SQL-92 Aggregation Functions</a> for details.</p>
7578<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#Aggregation_functions">Aggregation Functions</a> for details.</p>
7579<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>
7580<div class="section">
7581<h3><a name="array_count"></a>array_count</h3>
7582<ul>
7583
7584<li>
7585
7586<p>Syntax:</p>
7587
7588<div>
7589<div>
7590<pre class="source">array_count(collection)
7591</pre></div></div>
7592</li>
7593<li>
7594
7595<p>Gets the number of non-null and non-missing items in the given collection.</p>
7596</li>
7597<li>Arguments:
7598<ul>
7599
7600<li><tt>collection</tt> could be:
7601<ul>
7602
7603<li>an <tt>array</tt> or <tt>multiset</tt> to be counted,</li>
7604<li>or, a <tt>null</tt> value,</li>
7605<li>or, a <tt>missing</tt> value.</li>
7606</ul>
7607</li>
7608</ul>
7609</li>
7610<li>Return Value:
7611<ul>
7612
7613<li>a <tt>bigint</tt> value representing the number of non-null and non-missing items in the given collection,</li>
7614<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7615<li>any other non-array and non-multiset input value will cause an error.</li>
7616</ul>
7617</li>
7618<li>
7619
7620<p>Example:</p>
7621
7622<div>
7623<div>
7624<pre class="source">array_count( ['hello', 'world', 1, 2, 3, null, missing] );
7625</pre></div></div>
7626</li>
7627<li>
7628
7629<p>The expected result is:</p>
7630
7631<div>
7632<div>
7633<pre class="source">5
7634</pre></div></div>
7635</li>
7636</ul></div>
7637<div class="section">
7638<h3><a name="array_avg"></a>array_avg</h3>
7639<ul>
7640
7641<li>
7642
7643<p>Syntax:</p>
7644
7645<div>
7646<div>
7647<pre class="source">array_avg(num_collection)
7648</pre></div></div>
7649</li>
7650<li>
7651
7652<p>Gets the average value of the non-null and non-missing numeric items in the given collection.</p>
7653</li>
7654<li>Arguments:
7655<ul>
7656
7657<li><tt>num_collection</tt> could be:
7658<ul>
7659
7660<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7661<li>or, a <tt>null</tt> value,</li>
7662<li>or, a <tt>missing</tt> value.</li>
7663</ul>
7664</li>
7665</ul>
7666</li>
7667<li>Return Value:
7668<ul>
7669
7670<li>a <tt>double</tt> value representing the average of the non-null and non-missing numbers in the given collection,</li>
7671<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7672<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7673<li>any other non-array and non-multiset input value will cause a type error,</li>
7674<li>any other non-numeric value in the input collection will cause a type error.</li>
7675</ul>
7676</li>
7677<li>
7678
7679<p>Example:</p>
7680
7681<div>
7682<div>
7683<pre class="source">array_avg( [1.2, 2.3, 3.4, 0, null] );
7684</pre></div></div>
7685</li>
7686<li>
7687
7688<p>The expected result is:</p>
7689
7690<div>
7691<div>
7692<pre class="source">1.725
7693</pre></div></div>
7694</li>
7695</ul></div>
7696<div class="section">
7697<h3><a name="array_sum"></a>array_sum</h3>
7698<ul>
7699
7700<li>
7701
7702<p>Syntax:</p>
7703
7704<div>
7705<div>
7706<pre class="source">array_sum(num_collection)
7707</pre></div></div>
7708</li>
7709<li>
7710
7711<p>Gets the sum of non-null and non-missing items in the given collection.</p>
7712</li>
7713<li>Arguments:
7714<ul>
7715
7716<li><tt>num_collection</tt> could be:
7717<ul>
7718
7719<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7720<li>or, a <tt>null</tt> value,</li>
7721<li>or, a <tt>missing</tt> value.</li>
7722</ul>
7723</li>
7724</ul>
7725</li>
7726<li>Return Value:
7727<ul>
7728
7729<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>
7730<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7731<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7732<li>any other non-array and non-multiset input value will cause a type error,</li>
7733<li>any other non-numeric value in the input collection will cause a type error.</li>
7734</ul>
7735</li>
7736<li>
7737
7738<p>Example:</p>
7739
7740<div>
7741<div>
7742<pre class="source">array_sum( [1.2, 2.3, 3.4, 0, null, missing] );
7743</pre></div></div>
7744</li>
7745<li>
7746
7747<p>The expected result is:</p>
7748
7749<div>
7750<div>
7751<pre class="source">6.9
7752</pre></div></div>
7753</li>
7754</ul></div>
7755<div class="section">
7756<h3><a name="array_min"></a>array_min</h3>
7757<ul>
7758
7759<li>
7760
7761<p>Syntax:</p>
7762
7763<div>
7764<div>
7765<pre class="source">array_min(num_collection)
7766</pre></div></div>
7767</li>
7768<li>
7769
7770<p>Gets the min value of non-null and non-missing comparable items in the given collection.</p>
7771</li>
7772<li>Arguments:
7773<ul>
7774
7775<li><tt>num_collection</tt> could be:
7776<ul>
7777
7778<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7779<li>or, a <tt>null</tt> value,</li>
7780<li>or, a <tt>missing</tt> value.</li>
7781</ul>
7782</li>
7783</ul>
7784</li>
7785<li>Return Value:
7786<ul>
7787
7788<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>
7789<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7790<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7791<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7792<li>any other non-array and non-multiset input value will cause a type error.</li>
7793</ul>
7794</li>
7795<li>
7796
7797<p>Example:</p>
7798
7799<div>
7800<div>
7801<pre class="source">array_min( [1.2, 2.3, 3.4, 0, null, missing] );
7802</pre></div></div>
7803</li>
7804<li>
7805
7806<p>The expected result is:</p>
7807
7808<div>
7809<div>
7810<pre class="source">0.0
7811</pre></div></div>
7812</li>
7813</ul></div>
7814<div class="section">
7815<h3><a name="array_max"></a>array_max</h3>
7816<ul>
7817
7818<li>
7819
7820<p>Syntax:</p>
7821
7822<div>
7823<div>
7824<pre class="source">array_max(num_collection)
7825</pre></div></div>
7826</li>
7827<li>
7828
7829<p>Gets the max value of the non-null and non-missing comparable items in the given collection.</p>
7830</li>
7831<li>Arguments:
7832<ul>
7833
7834<li><tt>num_collection</tt> could be:
7835<ul>
7836
7837<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7838<li>or, a <tt>null</tt> value,</li>
7839<li>or, a <tt>missing</tt> value.</li>
7840</ul>
7841</li>
7842</ul>
7843</li>
7844<li>Return Value:
7845<ul>
7846
7847<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>
7848<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7849<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7850<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7851<li>any other non-array and non-multiset input value will cause a type error.</li>
7852</ul>
7853</li>
7854<li>
7855
7856<p>Example:</p>
7857
7858<div>
7859<div>
7860<pre class="source">array_max( [1.2, 2.3, 3.4, 0, null, missing] );
7861</pre></div></div>
7862</li>
7863<li>
7864
7865<p>The expected result is:</p>
7866
7867<div>
7868<div>
7869<pre class="source">3.4
7870</pre></div></div>
7871</li>
7872</ul></div>
7873<div class="section">
7874<h3><a name="array_stddev_samp"></a>array_stddev_samp</h3>
7875<ul>
7876
7877<li>
7878
7879<p>Syntax:</p>
7880
7881<div>
7882<div>
7883<pre class="source">array_stddev_samp(num_collection)
7884</pre></div></div>
7885</li>
7886<li>
7887
7888<p>Gets the sample standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
7889</li>
7890<li>Arguments:
7891<ul>
7892
7893<li><tt>num_collection</tt> could be:
7894<ul>
7895
7896<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7897<li>or, a <tt>null</tt> value,</li>
7898<li>or, a <tt>missing</tt> value.</li>
7899</ul>
7900</li>
7901</ul>
7902</li>
7903<li>Return Value:
7904<ul>
7905
7906<li>a <tt>double</tt> value representing the sample standard deviation of the non-null and non-missing numbers in the given collection,</li>
7907<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7908<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7909<li>any other non-array and non-multiset input value will cause a type error,</li>
7910<li>any other non-numeric value in the input collection will cause a type error.</li>
7911</ul>
7912</li>
7913<li>
7914
7915<p>Example:</p>
7916
7917<div>
7918<div>
7919<pre class="source">array_stddev_samp( [1.2, 2.3, 3.4, 0, null] );
7920</pre></div></div>
7921</li>
7922<li>
7923
7924<p>The expected result is:</p>
7925
7926<div>
7927<div>
7928<pre class="source">1.4591664287073858
7929</pre></div></div>
7930</li>
7931</ul></div>
7932<div class="section">
7933<h3><a name="array_stddev_pop"></a>array_stddev_pop</h3>
7934<ul>
7935
7936<li>
7937
7938<p>Syntax:</p>
7939
7940<div>
7941<div>
7942<pre class="source">array_stddev_pop(num_collection)
7943</pre></div></div>
7944</li>
7945<li>
7946
7947<p>Gets the population standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
7948</li>
7949<li>Arguments:
7950<ul>
7951
7952<li><tt>num_collection</tt> could be:
7953<ul>
7954
7955<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7956<li>or, a <tt>null</tt> value,</li>
7957<li>or, a <tt>missing</tt> value.</li>
7958</ul>
7959</li>
7960</ul>
7961</li>
7962<li>Return Value:
7963<ul>
7964
7965<li>a <tt>double</tt> value representing the population standard deviation of the non-null and non-missing numbers in the given collection,</li>
7966<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7967<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7968<li>any other non-array and non-multiset input value will cause a type error,</li>
7969<li>any other non-numeric value in the input collection will cause a type error.</li>
7970</ul>
7971</li>
7972<li>
7973
7974<p>Example:</p>
7975
7976<div>
7977<div>
7978<pre class="source">array_stddev_pop( [1.2, 2.3, 3.4, 0, null] );
7979</pre></div></div>
7980</li>
7981<li>
7982
7983<p>The expected result is:</p>
7984
7985<div>
7986<div>
7987<pre class="source">1.2636751956100112
7988</pre></div></div>
7989</li>
7990</ul></div>
7991<div class="section">
7992<h3><a name="array_var_samp"></a>array_var_samp</h3>
7993<ul>
7994
7995<li>
7996
7997<p>Syntax:</p>
7998
7999<div>
8000<div>
8001<pre class="source">array_var_samp(num_collection)
8002</pre></div></div>
8003</li>
8004<li>
8005
8006<p>Gets the sample variance value of the non-null and non-missing numeric items in the given collection.</p>
8007</li>
8008<li>Arguments:
8009<ul>
8010
8011<li><tt>num_collection</tt> could be:
8012<ul>
8013
8014<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8015<li>or, a <tt>null</tt> value,</li>
8016<li>or, a <tt>missing</tt> value.</li>
8017</ul>
8018</li>
8019</ul>
8020</li>
8021<li>Return Value:
8022<ul>
8023
8024<li>a <tt>double</tt> value representing the sample variance of the non-null and non-missing numbers in the given collection,</li>
8025<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8026<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8027<li>any other non-array and non-multiset input value will cause a type error,</li>
8028<li>any other non-numeric value in the input collection will cause a type error.</li>
8029</ul>
8030</li>
8031<li>
8032
8033<p>Example:</p>
8034
8035<div>
8036<div>
8037<pre class="source">array_var_samp( [1.2, 2.3, 3.4, 0, null] );
8038</pre></div></div>
8039</li>
8040<li>
8041
8042<p>The expected result is:</p>
8043
8044<div>
8045<div>
8046<pre class="source">2.1291666666666664
8047</pre></div></div>
8048</li>
8049</ul></div>
8050<div class="section">
8051<h3><a name="array_var_pop"></a>array_var_pop</h3>
8052<ul>
8053
8054<li>
8055
8056<p>Syntax:</p>
8057
8058<div>
8059<div>
8060<pre class="source">array_var_pop(num_collection)
8061</pre></div></div>
8062</li>
8063<li>
8064
8065<p>Gets the population variance value of the non-null and non-missing numeric items in the given collection.</p>
8066</li>
8067<li>Arguments:
8068<ul>
8069
8070<li><tt>num_collection</tt> could be:
8071<ul>
8072
8073<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8074<li>or, a <tt>null</tt> value,</li>
8075<li>or, a <tt>missing</tt> value.</li>
8076</ul>
8077</li>
8078</ul>
8079</li>
8080<li>Return Value:
8081<ul>
8082
8083<li>a <tt>double</tt> value representing the population variance of the non-null and non-missing numbers in the given collection,</li>
8084<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8085<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8086<li>any other non-array and non-multiset input value will cause a type error,</li>
8087<li>any other non-numeric value in the input collection will cause a type error.</li>
8088</ul>
8089</li>
8090<li>
8091
8092<p>Example:</p>
8093
8094<div>
8095<div>
8096<pre class="source">array_var_pop( [1.2, 2.3, 3.4, 0, null] );
8097</pre></div></div>
8098</li>
8099<li>
8100
8101<p>The expected result is:</p>
8102
8103<div>
8104<div>
8105<pre class="source">1.5968749999999998
8106</pre></div></div>
8107</li>
8108</ul></div>
8109<div class="section">
8110<h3><a name="array_skewness"></a>array_skewness</h3>
8111<ul>
8112
8113<li>
8114
8115<p>Syntax:</p>
8116
8117<div>
8118<div>
8119<pre class="source">array_skewness(num_collection)
8120</pre></div></div>
8121</li>
8122<li>
8123
8124<p>Gets the skewness value of the non-null and non-missing numeric items in the given collection.</p>
8125</li>
8126<li>Arguments:
8127<ul>
8128
8129<li><tt>num_collection</tt> could be:
8130<ul>
8131
8132<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8133<li>or, a <tt>null</tt> value,</li>
8134<li>or, a <tt>missing</tt> value.</li>
8135</ul>
8136</li>
8137</ul>
8138</li>
8139<li>Return Value:
8140<ul>
8141
8142<li>a <tt>double</tt> value representing the skewness of the non-null and non-missing numbers in the given collection,</li>
8143<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8144<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8145<li>any other non-array and non-multiset input value will cause a type error,</li>
8146<li>any other non-numeric value in the input collection will cause a type error.</li>
8147</ul>
8148</li>
8149<li>
8150
8151<p>Example:</p>
8152
8153<div>
8154<div>
8155<pre class="source">array_skewness( [1.2, 2.3, 3.4, 0, null] );
8156</pre></div></div>
8157</li>
8158<li>
8159
8160<p>The expected result is:</p>
8161
8162<div>
8163<div>
8164<pre class="source">-0.04808451539164242
8165</pre></div></div>
8166</li>
8167</ul></div>
8168<div class="section">
8169<h3><a name="array_kurtosis"></a>array_kurtosis</h3>
8170<ul>
8171
8172<li>
8173
8174<p>Syntax:</p>
8175
8176<div>
8177<div>
8178<pre class="source">array_kurtosis(num_collection)
8179</pre></div></div>
8180</li>
8181<li>
8182
8183<p>Gets the kurtosis value from the normal distribution of the non-null and non-missing numeric items in the given collection.</p>
8184</li>
8185<li>Arguments:
8186<ul>
8187
8188<li><tt>num_collection</tt> could be:
8189<ul>
8190
8191<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8192<li>or, a <tt>null</tt> value,</li>
8193<li>or, a <tt>missing</tt> value.</li>
8194</ul>
8195</li>
8196</ul>
8197</li>
8198<li>Return Value:
8199<ul>
8200
8201<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>
8202<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8203<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8204<li>any other non-array and non-multiset input value will cause a type error,</li>
8205<li>any other non-numeric value in the input collection will cause a type error.</li>
8206</ul>
8207</li>
8208<li>
8209
8210<p>Example:</p>
8211
8212<div>
8213<div>
8214<pre class="source">array_kurtosis( [1.2, 2.3, 3.4, 0, null] );
8215</pre></div></div>
8216</li>
8217<li>
8218
8219<p>The expected result is:</p>
8220
8221<div>
8222<div>
8223<pre class="source">-1.342049701096427
8224</pre></div></div>
8225</li>
8226</ul></div>
8227<div class="section">
8228<h3><a name="strict_count"></a>strict_count</h3>
8229<ul>
8230
8231<li>
8232
8233<p>Syntax:</p>
8234
8235<div>
8236<div>
8237<pre class="source">strict_count(collection)
8238</pre></div></div>
8239</li>
8240<li>
8241
8242<p>Gets the number of items in the given collection.</p>
8243</li>
8244<li>Arguments:
8245<ul>
8246
8247<li><tt>collection</tt> could be:
8248<ul>
8249
8250<li>an <tt>array</tt> or <tt>multiset</tt> containing the items to be counted,</li>
8251<li>or a <tt>null</tt> value,</li>
8252<li>or a <tt>missing</tt> value.</li>
8253</ul>
8254</li>
8255</ul>
8256</li>
8257<li>Return Value:
8258<ul>
8259
8260<li>a <tt>bigint</tt> value representing the number of items in the given collection,</li>
8261<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>.</li>
8262</ul>
8263</li>
8264<li>
8265
8266<p>Example:</p>
8267
8268<div>
8269<div>
8270<pre class="source">strict_count( [1, 2, null, missing] );
8271</pre></div></div>
8272</li>
8273<li>
8274
8275<p>The expected result is:</p>
8276
8277<div>
8278<div>
8279<pre class="source">4
8280</pre></div></div>
8281</li>
8282</ul></div>
8283<div class="section">
8284<h3><a name="strict_avg"></a>strict_avg</h3>
8285<ul>
8286
8287<li>
8288
8289<p>Syntax:</p>
8290
8291<div>
8292<div>
8293<pre class="source">strict_avg(num_collection)
8294</pre></div></div>
8295</li>
8296<li>
8297
8298<p>Gets the average value of the numeric items in the given collection.</p>
8299</li>
8300<li>Arguments:
8301<ul>
8302
8303<li><tt>num_collection</tt> could be:
8304<ul>
8305
8306<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8307<li>or, a <tt>null</tt> value,</li>
8308<li>or, a <tt>missing</tt> value.</li>
8309</ul>
8310</li>
8311</ul>
8312</li>
8313<li>Return Value:
8314<ul>
8315
8316<li>a <tt>double</tt> value representing the average of the numbers in the given collection,</li>
8317<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8318<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8319<li>any other non-numeric value in the input collection will cause a type error.</li>
8320</ul>
8321</li>
8322<li>
8323
8324<p>Example:</p>
8325
8326<div>
8327<div>
8328<pre class="source">strict_avg( [100, 200, 300] );
8329</pre></div></div>
8330</li>
8331<li>
8332
8333<p>The expected result is:</p>
8334
8335<div>
8336<div>
8337<pre class="source">200.0
8338</pre></div></div>
8339</li>
8340</ul></div>
8341<div class="section">
8342<h3><a name="strict_sum"></a>strict_sum</h3>
8343<ul>
8344
8345<li>
8346
8347<p>Syntax:</p>
8348
8349<div>
8350<div>
8351<pre class="source">strict_sum(num_collection)
8352</pre></div></div>
8353</li>
8354<li>
8355
8356<p>Gets the sum of the items in the given collection.</p>
8357</li>
8358<li>Arguments:
8359<ul>
8360
8361<li><tt>num_collection</tt> could be:
8362<ul>
8363
8364<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8365<li>or, a <tt>null</tt> value,</li>
8366<li>or, a <tt>missing</tt> value.</li>
8367</ul>
8368</li>
8369</ul>
8370</li>
8371<li>Return Value:
8372<ul>
8373
8374<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>
8375<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8376<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8377<li>any other non-numeric value in the input collection will cause a type error.</li>
8378</ul>
8379</li>
8380<li>
8381
8382<p>Example:</p>
8383
8384<div>
8385<div>
8386<pre class="source">strict_sum( [100, 200, 300] );
8387</pre></div></div>
8388</li>
8389<li>
8390
8391<p>The expected result is:</p>
8392
8393<div>
8394<div>
8395<pre class="source">600
8396</pre></div></div>
8397</li>
8398</ul></div>
8399<div class="section">
8400<h3><a name="strict_min"></a>strict_min</h3>
8401<ul>
8402
8403<li>
8404
8405<p>Syntax:</p>
8406
8407<div>
8408<div>
8409<pre class="source">strict_min(num_collection)
8410</pre></div></div>
8411</li>
8412<li>
8413
8414<p>Gets the min value of comparable items in the given collection.</p>
8415</li>
8416<li>Arguments:
8417<ul>
8418
8419<li><tt>num_collection</tt> could be:
8420<ul>
8421
8422<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8423<li>or, a <tt>null</tt> value,</li>
8424<li>or, a <tt>missing</tt> value.</li>
8425</ul>
8426</li>
8427</ul>
8428</li>
8429<li>Return Value:
8430<ul>
8431
8432<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>
8433<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8434<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8435<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8436<li>any other non-array and non-multiset input value will cause a type error.</li>
8437</ul>
8438</li>
8439<li>
8440
8441<p>Example:</p>
8442
8443<div>
8444<div>
8445<pre class="source">strict_min( [10.2, 100, 5] );
8446</pre></div></div>
8447</li>
8448<li>
8449
8450<p>The expected result is:</p>
8451
8452<div>
8453<div>
8454<pre class="source">5.0
8455</pre></div></div>
8456</li>
8457</ul></div>
8458<div class="section">
8459<h3><a name="strict_max"></a>strict_max</h3>
8460<ul>
8461
8462<li>
8463
8464<p>Syntax:</p>
8465
8466<div>
8467<div>
8468<pre class="source">strict_max(num_collection)
8469</pre></div></div>
8470</li>
8471<li>
8472
8473<p>Gets the max value of numeric items in the given collection.</p>
8474</li>
8475<li>Arguments:
8476<ul>
8477
8478<li><tt>num_collection</tt> could be:
8479<ul>
8480
8481<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8482<li>or, a <tt>null</tt> value,</li>
8483<li>or, a <tt>missing</tt> value.</li>
8484</ul>
8485</li>
8486</ul>
8487</li>
8488<li>Return Value:
8489<ul>
8490
8491<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>
8492<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8493<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8494<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8495<li>any other non-array and non-multiset input value will cause a type error.</li>
8496</ul>
8497</li>
8498<li>
8499
8500<p>Example:</p>
8501
8502<div>
8503<div>
8504<pre class="source">strict_max( [10.2, 100, 5] );
8505</pre></div></div>
8506</li>
8507<li>
8508
8509<p>The expected result is:</p>
8510
8511<div>
8512<div>
8513<pre class="source">100.0
8514</pre></div></div>
8515</li>
8516</ul></div>
8517<div class="section">
8518<h3><a name="strict_stddev_samp"></a>strict_stddev_samp</h3>
8519<ul>
8520
8521<li>
8522
8523<p>Syntax:</p>
8524
8525<div>
8526<div>
8527<pre class="source">strict_stddev_samp(num_collection)
8528</pre></div></div>
8529</li>
8530<li>
8531
8532<p>Gets the sample standard deviation value of the numeric items in the given collection.</p>
8533</li>
8534<li>Arguments:
8535<ul>
8536
8537<li><tt>num_collection</tt> could be:
8538<ul>
8539
8540<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8541<li>or, a <tt>null</tt> value,</li>
8542<li>or, a <tt>missing</tt> value.</li>
8543</ul>
8544</li>
8545</ul>
8546</li>
8547<li>Return Value:
8548<ul>
8549
8550<li>a <tt>double</tt> value representing the sample standard deviation of the numbers in the given collection,</li>
8551<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8552<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8553<li>any other non-numeric value in the input collection will cause a type error.</li>
8554</ul>
8555</li>
8556<li>
8557
8558<p>Example:</p>
8559
8560<div>
8561<div>
8562<pre class="source">strict_stddev_samp( [100, 200, 300] );
8563</pre></div></div>
8564</li>
8565<li>
8566
8567<p>The expected result is:</p>
8568
8569<div>
8570<div>
8571<pre class="source">100.0
8572</pre></div></div>
8573</li>
8574</ul></div>
8575<div class="section">
8576<h3><a name="strict_stddev_pop"></a>strict_stddev_pop</h3>
8577<ul>
8578
8579<li>
8580
8581<p>Syntax:</p>
8582
8583<div>
8584<div>
8585<pre class="source">strict_stddev_pop(num_collection)
8586</pre></div></div>
8587</li>
8588<li>
8589
8590<p>Gets the population standard deviation value of the numeric items in the given collection.</p>
8591</li>
8592<li>Arguments:
8593<ul>
8594
8595<li><tt>num_collection</tt> could be:
8596<ul>
8597
8598<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8599<li>or, a <tt>null</tt> value,</li>
8600<li>or, a <tt>missing</tt> value.</li>
8601</ul>
8602</li>
8603</ul>
8604</li>
8605<li>Return Value:
8606<ul>
8607
8608<li>a <tt>double</tt> value representing the population standard deviation of the numbers in the given collection,</li>
8609<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8610<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8611<li>any other non-numeric value in the input collection will cause a type error.</li>
8612</ul>
8613</li>
8614<li>
8615
8616<p>Example:</p>
8617
8618<div>
8619<div>
8620<pre class="source">strict_stddev_pop( [100, 200, 300] );
8621</pre></div></div>
8622</li>
8623<li>
8624
8625<p>The expected result is:</p>
8626
8627<div>
8628<div>
8629<pre class="source">81.64965809277261
8630</pre></div></div>
8631</li>
8632</ul></div>
8633<div class="section">
8634<h3><a name="strict_var_samp"></a>strict_var_samp</h3>
8635<ul>
8636
8637<li>
8638
8639<p>Syntax:</p>
8640
8641<div>
8642<div>
8643<pre class="source">strict_var_samp(num_collection)
8644</pre></div></div>
8645</li>
8646<li>
8647
8648<p>Gets the sample variance value of the numeric items in the given collection.</p>
8649</li>
8650<li>Arguments:
8651<ul>
8652
8653<li><tt>num_collection</tt> could be:
8654<ul>
8655
8656<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8657<li>or, a <tt>null</tt> value,</li>
8658<li>or, a <tt>missing</tt> value.</li>
8659</ul>
8660</li>
8661</ul>
8662</li>
8663<li>Return Value:
8664<ul>
8665
8666<li>a <tt>double</tt> value representing the sample variance of the numbers in the given collection,</li>
8667<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8668<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8669<li>any other non-numeric value in the input collection will cause a type error.</li>
8670</ul>
8671</li>
8672<li>
8673
8674<p>Example:</p>
8675
8676<div>
8677<div>
8678<pre class="source">strict_var_samp( [100, 200, 300] );
8679</pre></div></div>
8680</li>
8681<li>
8682
8683<p>The expected result is:</p>
8684
8685<div>
8686<div>
8687<pre class="source">10000.0
8688</pre></div></div>
8689</li>
8690</ul></div>
8691<div class="section">
8692<h3><a name="strict_var_pop"></a>strict_var_pop</h3>
8693<ul>
8694
8695<li>
8696
8697<p>Syntax:</p>
8698
8699<div>
8700<div>
8701<pre class="source">strict_var_pop(num_collection)
8702</pre></div></div>
8703</li>
8704<li>
8705
8706<p>Gets the population variance value of the numeric items in the given collection.</p>
8707</li>
8708<li>Arguments:
8709<ul>
8710
8711<li><tt>num_collection</tt> could be:
8712<ul>
8713
8714<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8715<li>or, a <tt>null</tt> value,</li>
8716<li>or, a <tt>missing</tt> value.</li>
8717</ul>
8718</li>
8719</ul>
8720</li>
8721<li>Return Value:
8722<ul>
8723
8724<li>a <tt>double</tt> value representing the population variance of the numbers in the given collection,</li>
8725<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8726<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8727<li>any other non-numeric value in the input collection will cause a type error.</li>
8728</ul>
8729</li>
8730<li>
8731
8732<p>Example:</p>
8733
8734<div>
8735<div>
8736<pre class="source">strict_var_pop( [100, 200, 300] );
8737</pre></div></div>
8738</li>
8739<li>
8740
8741<p>The expected result is:</p>
8742
8743<div>
8744<div>
8745<pre class="source">6666.666666666667
8746</pre></div></div>
8747</li>
8748</ul></div>
8749<div class="section">
8750<h3><a name="strict_skewness"></a>strict_skewness</h3>
8751<ul>
8752
8753<li>
8754
8755<p>Syntax:</p>
8756
8757<div>
8758<div>
8759<pre class="source">strict_skewness(num_collection)
8760</pre></div></div>
8761</li>
8762<li>
8763
8764<p>Gets the skewness value of the numeric items in the given collection.</p>
8765</li>
8766<li>Arguments:
8767<ul>
8768
8769<li><tt>num_collection</tt> could be:
8770<ul>
8771
8772<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8773<li>or, a <tt>null</tt> value,</li>
8774<li>or, a <tt>missing</tt> value.</li>
8775</ul>
8776</li>
8777</ul>
8778</li>
8779<li>Return Value:
8780<ul>
8781
8782<li>a <tt>double</tt> value representing the skewness of the numbers in the given collection,</li>
8783<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8784<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8785<li>any other non-numeric value in the input collection will cause a type error.</li>
8786</ul>
8787</li>
8788<li>
8789
8790<p>Example:</p>
8791
8792<div>
8793<div>
8794<pre class="source">strict_skewness( [100, 200, 300] );
8795</pre></div></div>
8796</li>
8797<li>
8798
8799<p>The expected result is:</p>
8800
8801<div>
8802<div>
8803<pre class="source">0.0
8804</pre></div></div>
8805</li>
8806</ul></div>
8807<div class="section">
8808<h3><a name="strict_kurtosis"></a>strict_kurtosis</h3>
8809<ul>
8810
8811<li>
8812
8813<p>Syntax:</p>
8814
8815<div>
8816<div>
8817<pre class="source">strict_kurtosis(num_collection)
8818</pre></div></div>
8819</li>
8820<li>
8821
8822<p>Gets the kurtosis value from the normal distribution of the numeric items in the given collection.</p>
8823</li>
8824<li>Arguments:
8825<ul>
8826
8827<li><tt>num_collection</tt> could be:
8828<ul>
8829
8830<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8831<li>or, a <tt>null</tt> value,</li>
8832<li>or, a <tt>missing</tt> value.</li>
8833</ul>
8834</li>
8835</ul>
8836</li>
8837<li>Return Value:
8838<ul>
8839
8840<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the numbers in the given collection,</li>
8841<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8842<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8843<li>any other non-numeric value in the input collection will cause a type error.</li>
8844</ul>
8845</li>
8846<li>
8847
8848<p>Example:</p>
8849
8850<div>
8851<div>
8852<pre class="source">strict_kurtosis( [100, 200, 300] );
8853</pre></div></div>
8854</li>
8855<li>
8856
8857<p>The expected result is:</p>
8858
8859<div>
8860<div>
8861<pre class="source">-1.5
8862</pre></div></div>
8863</li>
8864</ul><!--
8865 ! Licensed to the Apache Software Foundation (ASF) under one
8866 ! or more contributor license agreements. See the NOTICE file
8867 ! distributed with this work for additional information
8868 ! regarding copyright ownership. The ASF licenses this file
8869 ! to you under the Apache License, Version 2.0 (the
8870 ! "License"); you may not use this file except in compliance
8871 ! with the License. You may obtain a copy of the License at
8872 !
8873 ! http://www.apache.org/licenses/LICENSE-2.0
8874 !
8875 ! Unless required by applicable law or agreed to in writing,
8876 ! software distributed under the License is distributed on an
8877 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8878 ! KIND, either express or implied. See the License for the
8879 ! specific language governing permissions and limitations
8880 ! under the License.
8881 !-->
8882</div></div>
8883<div class="section">
8884<h2><a name="Comparison_Functions"></a><a name="ComparisonFunctions" id="ComparisonFunctions">Comparison Functions</a></h2>
8885<div class="section">
8886<h3><a name="greatest"></a>greatest</h3>
8887<ul>
8888
8889<li>
8890
8891<p>Syntax:</p>
8892
8893<div>
8894<div>
8895<pre class="source">greatest(numeric_value1, numeric_value2, ...)
8896</pre></div></div>
8897</li>
8898<li>
8899
8900<p>Computes the greatest value among arguments.</p>
8901</li>
8902<li>Arguments:
8903<ul>
8904
8905<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>
8906<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>
8907<li>&#x2026;.</li>
8908</ul>
8909</li>
8910<li>Return Value:
8911<ul>
8912
8913<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>
8914<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
8915<li>any other non-numeric input value will cause a type error.</li>
8916</ul>
8917</li>
8918<li>
8919
8920<p>Example:</p>
8921
8922<div>
8923<div>
8924<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) };
8925</pre></div></div>
8926</li>
8927<li>
8928
8929<p>The expected result is:</p>
8930
8931<div>
8932<div>
8933<pre class="source">{ &quot;v1&quot;: 3, &quot;v2&quot;: 5000.0 }
8934</pre></div></div>
8935</li>
8936</ul></div>
8937<div class="section">
8938<h3><a name="least"></a>least</h3>
8939<ul>
8940
8941<li>
8942
8943<p>Syntax:</p>
8944
8945<div>
8946<div>
8947<pre class="source">least(numeric_value1, numeric_value2, ...)
8948</pre></div></div>
8949</li>
8950<li>
8951
8952<p>Computes the least value among arguments.</p>
8953</li>
8954<li>Arguments:
8955<ul>
8956
8957<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>
8958<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>
8959<li>&#x2026;.</li>
8960</ul>
8961</li>
8962<li>Return Value:
8963<ul>
8964
8965<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>
8966<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
8967<li>any other non-numeric input value will cause a type error.</li>
8968</ul>
8969</li>
8970<li>
8971
8972<p>Example:</p>
8973
8974<div>
8975<div>
8976<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) };
8977</pre></div></div>
8978</li>
8979<li>
8980
8981<p>The expected result is:</p>
8982
8983<div>
8984<div>
8985<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: -0.5 }
8986</pre></div></div>
8987</li>
8988</ul><!--
8989 ! Licensed to the Apache Software Foundation (ASF) under one
8990 ! or more contributor license agreements. See the NOTICE file
8991 ! distributed with this work for additional information
8992 ! regarding copyright ownership. The ASF licenses this file
8993 ! to you under the Apache License, Version 2.0 (the
8994 ! "License"); you may not use this file except in compliance
8995 ! with the License. You may obtain a copy of the License at
8996 !
8997 ! http://www.apache.org/licenses/LICENSE-2.0
8998 !
8999 ! Unless required by applicable law or agreed to in writing,
9000 ! software distributed under the License is distributed on an
9001 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9002 ! KIND, either express or implied. See the License for the
9003 ! specific language governing permissions and limitations
9004 ! under the License.
9005 !-->
9006</div></div>
9007<div class="section">
9008<h2><a name="Type_Functions"></a><a name="TypeFunctions" id="TypeFunctions">Type Functions</a></h2>
9009<div class="section">
9010<h3><a name="get_type"></a>get_type</h3>
9011<ul>
9012
9013<li>
9014
9015<p>Syntax:</p>
9016
9017<div>
9018<div>
9019<pre class="source">get_type(expr)
9020</pre></div></div>
9021</li>
9022<li>
9023
9024<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>
9025</li>
9026<li>Arguments:
9027<ul>
9028
9029<li><tt>expr</tt> : an expression (any type is allowed).</li>
9030</ul>
9031</li>
9032<li>
9033
9034<p>Example:</p>
9035
9036<div>
9037<div>
9038<pre class="source">{
9039 &quot;a&quot;: get_type(true),
9040 &quot;b&quot;: get_type(false),
9041 &quot;c&quot;: get_type(null),
9042 &quot;d&quot;: get_type(missing),
9043 &quot;e&quot;: get_type(&quot;d&quot;),
9044 &quot;f&quot;: gettype(4.0),
9045 &quot;g&quot;: gettype(5),
9046 &quot;h&quot;: gettype([&quot;1&quot;, 2]),
9047 &quot;i&quot;: gettype({&quot;a&quot;:1})
9048};
9049</pre></div></div>
9050</li>
9051<li>
9052
9053<p>The expected result is:</p>
9054
9055<div>
9056<div>
9057<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; }
9058</pre></div></div>
9059</li>
9060</ul>
9061<p>The function has an alias <tt>gettype</tt>.</p></div>
9062<div class="section">
9063<h3><a name="is_array"></a>is_array</h3>
9064<ul>
9065
9066<li>
9067
9068<p>Syntax:</p>
9069
9070<div>
9071<div>
9072<pre class="source">is_array(expr)
9073</pre></div></div>
9074</li>
9075<li>
9076
9077<p>Checks whether the given expression is evaluated to be an <tt>array</tt> value.</p>
9078</li>
9079<li>Arguments:
9080<ul>
9081
9082<li><tt>expr</tt> : an expression (any type is allowed).</li>
9083</ul>
9084</li>
9085<li>Return Value:
9086<ul>
9087
9088<li>a <tt>boolean</tt> on whether the argument is an <tt>array</tt> value or not,</li>
9089<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9090<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9091</ul>
9092</li>
9093<li>
9094
9095<p>Example:</p>
9096
9097<div>
9098<div>
9099<pre class="source">{
9100 &quot;a&quot;: is_array(true),
9101 &quot;b&quot;: is_array(false),
9102 &quot;c&quot;: isarray(null),
9103 &quot;d&quot;: isarray(missing),
9104 &quot;e&quot;: isarray(&quot;d&quot;),
9105 &quot;f&quot;: isarray(4.0),
9106 &quot;g&quot;: isarray(5),
9107 &quot;h&quot;: isarray([&quot;1&quot;, 2]),
9108 &quot;i&quot;: isarray({&quot;a&quot;:1})
9109};
9110</pre></div></div>
9111</li>
9112<li>
9113
9114<p>The expected result is:</p>
9115
9116<div>
9117<div>
9118<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 }
9119</pre></div></div>
9120</li>
9121</ul>
9122<p>The function has an alias <tt>isarray</tt>.</p></div>
9123<div class="section">
9124<h3><a name="is_multiset"></a>is_multiset</h3>
9125<ul>
9126
9127<li>
9128
9129<p>Syntax:</p>
9130
9131<div>
9132<div>
9133<pre class="source">is_multiset(expr)
9134</pre></div></div>
9135</li>
9136<li>
9137
9138<p>Checks whether the given expression is evaluated to be an <tt>multiset</tt> value.</p>
9139</li>
9140<li>Arguments:
9141<ul>
9142
9143<li><tt>expr</tt> : an expression (any type is allowed).</li>
9144</ul>
9145</li>
9146<li>Return Value:
9147<ul>
9148
9149<li>a <tt>boolean</tt> on whether the argument is an <tt>multiset</tt> value or not,</li>
9150<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9151<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9152</ul>
9153</li>
9154<li>
9155
9156<p>Example:</p>
9157
9158<div>
9159<div>
9160<pre class="source">{
9161 &quot;a&quot;: is_multiset(true),
9162 &quot;b&quot;: is_multiset(false),
9163 &quot;c&quot;: is_multiset(null),
9164 &quot;d&quot;: is_multiset(missing),
9165 &quot;e&quot;: is_multiset(&quot;d&quot;),
9166 &quot;f&quot;: ismultiset(4.0),
9167 &quot;g&quot;: ismultiset([&quot;1&quot;, 2]),
9168 &quot;h&quot;: ismultiset({&quot;a&quot;:1}),
9169 &quot;i&quot;: ismultiset({{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}})
9170};
9171</pre></div></div>
9172</li>
9173<li>
9174
9175<p>The expected result is:</p>
9176
9177<div>
9178<div>
9179<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 }
9180</pre></div></div>
9181</li>
9182</ul>
9183<p>The function has an alias <tt>ismultiset</tt>.</p></div>
9184<div class="section">
9185<h3><a name="is_atomic_.28is_atom.29"></a>is_atomic (is_atom)</h3>
9186<ul>
9187
9188<li>
9189
9190<p>Syntax:</p>
9191
9192<div>
9193<div>
9194<pre class="source">is_atomic(expr)
9195</pre></div></div>
9196</li>
9197<li>
9198
9199<p>Checks whether the given expression is evaluated to be a value of a <a href="../datamodel.html#PrimitiveTypes">primitive</a> type.</p>
9200</li>
9201<li>Arguments:
9202<ul>
9203
9204<li><tt>expr</tt> : an expression (any type is allowed).</li>
9205</ul>
9206</li>
9207<li>Return Value:
9208<ul>
9209
9210<li>a <tt>boolean</tt> on whether the argument is a primitive type or not,</li>
9211<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9212<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9213</ul>
9214</li>
9215<li>
9216
9217<p>Example:</p>
9218
9219<div>
9220<div>
9221<pre class="source">{
9222 &quot;a&quot;: is_atomic(true),
9223 &quot;b&quot;: is_atomic(false),
9224 &quot;c&quot;: isatomic(null),
9225 &quot;d&quot;: isatomic(missing),
9226 &quot;e&quot;: isatomic(&quot;d&quot;),
9227 &quot;f&quot;: isatom(4.0),
9228 &quot;g&quot;: isatom(5),
9229 &quot;h&quot;: isatom([&quot;1&quot;, 2]),
9230 &quot;i&quot;: isatom({&quot;a&quot;:1})
9231};
9232</pre></div></div>
9233</li>
9234<li>
9235
9236<p>The expected result is:</p>
9237
9238<div>
9239<div>
9240<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 }
9241</pre></div></div>
9242</li>
9243</ul>
9244<p>The function has three aliases: <tt>isatomic</tt>, <tt>is_atom</tt>, and <tt>isatom</tt>.</p></div>
9245<div class="section">
9246<h3><a name="is_boolean_.28is_bool.29"></a>is_boolean (is_bool)</h3>
9247<ul>
9248
9249<li>
9250
9251<p>Syntax:</p>
9252
9253<div>
9254<div>
9255<pre class="source">is_boolean(expr)
9256</pre></div></div>
9257</li>
9258<li>
9259
9260<p>Checks whether the given expression is evaluated to be a <tt>boolean</tt> value.</p>
9261</li>
9262<li>Arguments:
9263<ul>
9264
9265<li><tt>expr</tt> : an expression (any type is allowed).</li>
9266</ul>
9267</li>
9268<li>Return Value:
9269<ul>
9270
9271<li>a <tt>boolean</tt> on whether the argument is a <tt>boolean</tt> value or not,</li>
9272<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9273<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9274</ul>
9275</li>
9276<li>
9277
9278<p>Example:</p>
9279
9280<div>
9281<div>
9282<pre class="source">{
9283 &quot;a&quot;: isboolean(true),
9284 &quot;b&quot;: isboolean(false),
9285 &quot;c&quot;: is_boolean(null),
9286 &quot;d&quot;: is_boolean(missing),
9287 &quot;e&quot;: isbool(&quot;d&quot;),
9288 &quot;f&quot;: isbool(4.0),
9289 &quot;g&quot;: isbool(5),
9290 &quot;h&quot;: isbool([&quot;1&quot;, 2]),
9291 &quot;i&quot;: isbool({&quot;a&quot;:1})
9292};
9293</pre></div></div>
9294</li>
9295<li>
9296
9297<p>The expected result is:</p>
9298
9299<div>
9300<div>
9301<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 }
9302</pre></div></div>
9303</li>
9304</ul>
9305<p>The function has three aliases: <tt>isboolean</tt>, <tt>is_bool</tt>, and <tt>isbool</tt>.</p></div>
9306<div class="section">
9307<h3><a name="is_binary_.28is_bin.29"></a>is_binary (is_bin)</h3>
9308<ul>
9309
9310<li>
9311
9312<p>Syntax:</p>
9313
9314<div>
9315<div>
9316<pre class="source">is_binary(expr)
9317</pre></div></div>
9318</li>
9319<li>
9320
9321<p>Checks whether the given expression is evaluated to be a <tt>binary</tt> value.</p>
9322</li>
9323<li>Arguments:
9324<ul>
9325
9326<li><tt>expr</tt> : an expression (any type is allowed).</li>
9327</ul>
9328</li>
9329<li>Return Value:
9330<ul>
9331
9332<li>a <tt>boolean</tt> on whether the argument is a <tt>binary</tt> value or not,</li>
9333<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9334<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9335</ul>
9336</li>
9337<li>
9338
9339<p>Example:</p>
9340
9341<div>
9342<div>
9343<pre class="source">{
9344 &quot;a&quot;: is_binary(true),
9345 &quot;b&quot;: is_binary(false),
9346 &quot;c&quot;: isbinary(null),
9347 &quot;d&quot;: isbinary(missing),
9348 &quot;e&quot;: isbin(point(&quot;1,2&quot;)),
9349 &quot;f&quot;: isbin(hex(&quot;ABCDEF0123456789&quot;)),
9350 &quot;g&quot;: is_bin(sub_binary(hex(&quot;AABBCCDD&quot;), 4)),
9351 &quot;h&quot;: is_bin(2),
9352 &quot;i&quot;: is_bin({&quot;a&quot;:1})
9353};
9354</pre></div></div>
9355</li>
9356<li>
9357
9358<p>The expected result is:</p>
9359
9360<div>
9361<div>
9362<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 }
9363</pre></div></div>
9364</li>
9365</ul>
9366<p>The function has three aliases: <tt>isbinary</tt>, <tt>is_bin</tt>, and <tt>isbin</tt>.</p></div>
9367<div class="section">
9368<h3><a name="is_number_.28is_num.29"></a>is_number (is_num)</h3>
9369<ul>
9370
9371<li>
9372
9373<p>Syntax:</p>
9374
9375<div>
9376<div>
9377<pre class="source">is_number(expr)
9378</pre></div></div>
9379</li>
9380<li>
9381
9382<p>Checks whether the given expression is evaluated to be a numeric value.</p>
9383</li>
9384<li>Arguments:
9385<ul>
9386
9387<li><tt>expr</tt> : an expression (any type is allowed).</li>
9388</ul>
9389</li>
9390<li>Return Value:
9391<ul>
9392
9393<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>
9394<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9395<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9396</ul>
9397</li>
9398<li>
9399
9400<p>Example:</p>
9401
9402<div>
9403<div>
9404<pre class="source">{
9405 &quot;a&quot;: is_number(true),
9406 &quot;b&quot;: is_number(false),
9407 &quot;c&quot;: isnumber(null),
9408 &quot;d&quot;: isnumber(missing),
9409 &quot;e&quot;: isnumber(&quot;d&quot;),
9410 &quot;f&quot;: isnum(4.0),
9411 &quot;g&quot;: isnum(5),
9412 &quot;h&quot;: isnum([&quot;1&quot;, 2]),
9413 &quot;i&quot;: isnum({&quot;a&quot;:1})
9414};
9415</pre></div></div>
9416</li>
9417<li>
9418
9419<p>The expected result is:</p>
9420
9421<div>
9422<div>
9423<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 }
9424</pre></div></div>
9425</li>
9426</ul>
9427<p>The function has three aliases: <tt>isnumber</tt>, <tt>is_num</tt>, and <tt>isnum</tt>.</p></div>
9428<div class="section">
9429<h3><a name="is_point"></a>is_point</h3>
9430<ul>
9431
9432<li>
9433
9434<p>Syntax:</p>
9435
9436<div>
9437<div>
9438<pre class="source">is_point(expr)
9439</pre></div></div>
9440</li>
9441<li>
9442
9443<p>Checks whether the given expression is evaluated to be a <tt>point</tt> value.</p>
9444</li>
9445<li>Arguments:
9446<ul>
9447
9448<li><tt>expr</tt> : an expression (any type is allowed).</li>
9449</ul>
9450</li>
9451<li>Return Value:
9452<ul>
9453
9454<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt> value or not,</li>
9455<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9456<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9457</ul>
9458</li>
9459<li>
9460
9461<p>Example:</p>
9462
9463<div>
9464<div>
9465<pre class="source">{
9466 &quot;a&quot;: is_point(true),
9467 &quot;b&quot;: is_point(false),
9468 &quot;c&quot;: is_point(null),
9469 &quot;d&quot;: is_point(missing),
9470 &quot;e&quot;: is_point(point(&quot;1,2&quot;)),
9471 &quot;f&quot;: ispoint(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9472 &quot;g&quot;: ispoint(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9473 &quot;h&quot;: ispoint(circle(&quot;30.0,70.0 5.0&quot;)),
9474 &quot;i&quot;: ispoint(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9475 &quot;j&quot;: ispoint(3)
9476};
9477</pre></div></div>
9478</li>
9479<li>
9480
9481<p>The expected result is:</p>
9482
9483<div>
9484<div>
9485<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 }
9486</pre></div></div>
9487</li>
9488</ul>
9489<p>The function has an alias <tt>ispoint</tt>.</p></div>
9490<div class="section">
9491<h3><a name="is_line"></a>is_line</h3>
9492<ul>
9493
9494<li>
9495
9496<p>Syntax:</p>
9497
9498<div>
9499<div>
9500<pre class="source">is_line(expr)
9501</pre></div></div>
9502</li>
9503<li>
9504
9505<p>Checks whether the given expression is evaluated to be a <tt>line</tt> value.</p>
9506</li>
9507<li>Arguments:
9508<ul>
9509
9510<li><tt>expr</tt> : an expression (any type is allowed).</li>
9511</ul>
9512</li>
9513<li>Return Value:
9514<ul>
9515
9516<li>a <tt>boolean</tt> on whether the argument is a <tt>line</tt> value or not,</li>
9517<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9518<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9519</ul>
9520</li>
9521<li>
9522
9523<p>Example:</p>
9524
9525<div>
9526<div>
9527<pre class="source">{
9528 &quot;a&quot;: is_line(true),
9529 &quot;b&quot;: is_line(false),
9530 &quot;c&quot;: is_line(null),
9531 &quot;d&quot;: is_line(missing),
9532 &quot;e&quot;: is_line(point(&quot;1,2&quot;)),
9533 &quot;f&quot;: isline(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9534 &quot;g&quot;: isline(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9535 &quot;h&quot;: isline(circle(&quot;30.0,70.0 5.0&quot;)),
9536 &quot;i&quot;: isline(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9537 &quot;j&quot;: isline(3)
9538};
9539</pre></div></div>
9540</li>
9541<li>
9542
9543<p>The expected result is:</p>
9544
9545<div>
9546<div>
9547<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 }
9548</pre></div></div>
9549</li>
9550</ul>
9551<p>The function has an alias <tt>isline</tt>.</p></div>
9552<div class="section">
9553<h3><a name="is_rectangle"></a>is_rectangle</h3>
9554<ul>
9555
9556<li>
9557
9558<p>Syntax:</p>
9559
9560<div>
9561<div>
9562<pre class="source">is_rectangle(expr)
9563</pre></div></div>
9564</li>
9565<li>
9566
9567<p>Checks whether the given expression is evaluated to be a <tt>rectangle</tt> value.</p>
9568</li>
9569<li>Arguments:
9570<ul>
9571
9572<li><tt>expr</tt> : an expression (any type is allowed).</li>
9573</ul>
9574</li>
9575<li>Return Value:
9576<ul>
9577
9578<li>a <tt>boolean</tt> on whether the argument is a <tt>rectangle</tt> value or not,</li>
9579<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9580<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9581</ul>
9582</li>
9583<li>
9584
9585<p>Example:</p>
9586
9587<div>
9588<div>
9589<pre class="source">{
9590 &quot;a&quot;: is_rectangle(true),
9591 &quot;b&quot;: is_rectangle(false),
9592 &quot;c&quot;: is_rectangle(null),
9593 &quot;d&quot;: is_rectangle(missing),
9594 &quot;e&quot;: is_rectangle(point(&quot;1,2&quot;)),
9595 &quot;f&quot;: isrectangle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9596 &quot;g&quot;: isrectangle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9597 &quot;h&quot;: isrectangle(circle(&quot;30.0,70.0 5.0&quot;)),
9598 &quot;i&quot;: isrectangle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9599 &quot;j&quot;: isrectangle(3)
9600};
9601</pre></div></div>
9602</li>
9603<li>
9604
9605<p>The expected result is:</p>
9606
9607<div>
9608<div>
9609<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 }
9610</pre></div></div>
9611</li>
9612</ul>
9613<p>The function has an alias <tt>isrectangle</tt>.</p></div>
9614<div class="section">
9615<h3><a name="is_circle"></a>is_circle</h3>
9616<ul>
9617
9618<li>
9619
9620<p>Syntax:</p>
9621
9622<div>
9623<div>
9624<pre class="source">is_circle(expr)
9625</pre></div></div>
9626</li>
9627<li>
9628
9629<p>Checks whether the given expression is evaluated to be a <tt>circle</tt> value.</p>
9630</li>
9631<li>Arguments:
9632<ul>
9633
9634<li><tt>expr</tt> : an expression (any type is allowed).</li>
9635</ul>
9636</li>
9637<li>Return Value:
9638<ul>
9639
9640<li>a <tt>boolean</tt> on whether the argument is a <tt>circle</tt> value or not,</li>
9641<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9642<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9643</ul>
9644</li>
9645<li>
9646
9647<p>Example:</p>
9648
9649<div>
9650<div>
9651<pre class="source">{
9652 &quot;a&quot;: is_circle(true),
9653 &quot;b&quot;: is_circle(false),
9654 &quot;c&quot;: is_circle(null),
9655 &quot;d&quot;: is_circle(missing),
9656 &quot;e&quot;: is_circle(point(&quot;1,2&quot;)),
9657 &quot;f&quot;: iscircle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9658 &quot;g&quot;: iscircle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9659 &quot;h&quot;: iscircle(circle(&quot;30.0,70.0 5.0&quot;)),
9660 &quot;i&quot;: iscircle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9661 &quot;j&quot;: iscircle(3)
9662};
9663</pre></div></div>
9664</li>
9665<li>
9666
9667<p>The expected result is:</p>
9668
9669<div>
9670<div>
9671<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 }
9672</pre></div></div>
9673</li>
9674</ul>
9675<p>The function has an alias <tt>iscircle</tt>.</p></div>
9676<div class="section">
9677<h3><a name="is_polygon"></a>is_polygon</h3>
9678<ul>
9679
9680<li>
9681
9682<p>Syntax:</p>
9683
9684<div>
9685<div>
9686<pre class="source">is_polygon(expr)
9687</pre></div></div>
9688</li>
9689<li>
9690
9691<p>Checks whether the given expression is evaluated to be a <tt>polygon</tt> value.</p>
9692</li>
9693<li>Arguments:
9694<ul>
9695
9696<li><tt>expr</tt> : an expression (any type is allowed).</li>
9697</ul>
9698</li>
9699<li>Return Value:
9700<ul>
9701
9702<li>a <tt>boolean</tt> on whether the argument is a <tt>polygon</tt> value or not,</li>
9703<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9704<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9705</ul>
9706</li>
9707<li>
9708
9709<p>Example:</p>
9710
9711<div>
9712<div>
9713<pre class="source">{
9714 &quot;a&quot;: is_polygon(true),
9715 &quot;b&quot;: is_polygon(false),
9716 &quot;c&quot;: is_polygon(null),
9717 &quot;d&quot;: is_polygon(missing),
9718 &quot;e&quot;: is_polygon(point(&quot;1,2&quot;)),
9719 &quot;f&quot;: ispolygon(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9720 &quot;g&quot;: ispolygon(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9721 &quot;h&quot;: ispolygon(circle(&quot;30.0,70.0 5.0&quot;)),
9722 &quot;i&quot;: ispolygon(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9723 &quot;j&quot;: ispolygon(3)
9724};
9725</pre></div></div>
9726</li>
9727<li>
9728
9729<p>The expected result is:</p>
9730
9731<div>
9732<div>
9733<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 }
9734</pre></div></div>
9735</li>
9736</ul>
9737<p>The function has an alias <tt>ispolygon</tt>.</p></div>
9738<div class="section">
9739<h3><a name="is_spatial"></a>is_spatial</h3>
9740<ul>
9741
9742<li>
9743
9744<p>Syntax:</p>
9745
9746<div>
9747<div>
9748<pre class="source">is_spatial(expr)
9749</pre></div></div>
9750</li>
9751<li>
9752
9753<p>Checks whether the given expression is evaluated to be a spatial value.</p>
9754</li>
9755<li>Arguments:
9756<ul>
9757
9758<li><tt>expr</tt> : an expression (any type is allowed).</li>
9759</ul>
9760</li>
9761<li>Return Value:
9762<ul>
9763
9764<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>
9765<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9766<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9767</ul>
9768</li>
9769<li>
9770
9771<p>Example:</p>
9772
9773<div>
9774<div>
9775<pre class="source">{
9776 &quot;a&quot;: is_spatial(true),
9777 &quot;b&quot;: is_spatial(false),
9778 &quot;c&quot;: is_spatial(null),
9779 &quot;d&quot;: is_spatial(missing),
9780 &quot;e&quot;: is_spatial(point(&quot;1,2&quot;)),
9781 &quot;f&quot;: isspatial(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9782 &quot;g&quot;: isspatial(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9783 &quot;h&quot;: isspatial(circle(&quot;30.0,70.0 5.0&quot;)),
9784 &quot;i&quot;: isspatial(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9785 &quot;j&quot;: isspatial(3)
9786};
9787</pre></div></div>
9788</li>
9789<li>
9790
9791<p>The expected result is:</p>
9792
9793<div>
9794<div>
9795<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 }
9796</pre></div></div>
9797</li>
9798</ul>
9799<p>The function has an alias <tt>isspatial</tt>.</p></div>
9800<div class="section">
9801<h3><a name="is_date"></a>is_date</h3>
9802<ul>
9803
9804<li>
9805
9806<p>Syntax:</p>
9807
9808<div>
9809<div>
9810<pre class="source">is_date(expr)
9811</pre></div></div>
9812</li>
9813<li>
9814
9815<p>Checks whether the given expression is evaluated to be a <tt>date</tt> value.</p>
9816</li>
9817<li>Arguments:
9818<ul>
9819
9820<li><tt>expr</tt> : an expression (any type is allowed).</li>
9821</ul>
9822</li>
9823<li>Return Value:
9824<ul>
9825
9826<li>a <tt>boolean</tt> on whether the argument is a <tt>date</tt> value or not,</li>
9827<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9828<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9829</ul>
9830</li>
9831<li>
9832
9833<p>Example:</p>
9834
9835<div>
9836<div>
9837<pre class="source">{
9838 &quot;a&quot;: is_date(true),
9839 &quot;b&quot;: is_date(false),
9840 &quot;c&quot;: is_date(null),
9841 &quot;d&quot;: is_date(missing),
9842 &quot;e&quot;: is_date(date(&quot;-19700101&quot;)),
9843 &quot;f&quot;: isdate(date(&quot;2013-01-01&quot;)),
9844 &quot;g&quot;: isdate(time(&quot;12:12:12.039Z&quot;)),
9845 &quot;h&quot;: isdate(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
9846 &quot;i&quot;: isdate(duration(&quot;P100Y12MT12M&quot;)),
9847 &quot;j&quot;: isdate(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
9848 &quot;k&quot;: isdate(3)
9849};
9850</pre></div></div>
9851</li>
9852<li>
9853
9854<p>The expected result is:</p>
9855
9856<div>
9857<div>
9858<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 }
9859</pre></div></div>
9860</li>
9861</ul>
9862<p>The function has an alias <tt>isdate</tt>.</p></div>
9863<div class="section">
9864<h3><a name="is_datetime_.28is_timestamp.29"></a>is_datetime (is_timestamp)</h3>
9865<ul>
9866
9867<li>
9868
9869<p>Syntax:</p>
9870
9871<div>
9872<div>
9873<pre class="source">is_datetime(expr)
9874</pre></div></div>
9875</li>
9876<li>
9877
9878<p>Checks whether the given expression is evaluated to be a <tt>datetime</tt> value.</p>
9879</li>
9880<li>Arguments:
9881<ul>
9882
9883<li><tt>expr</tt> : an expression (any type is allowed).</li>
9884</ul>
9885</li>
9886<li>Return Value:
9887<ul>
9888
9889<li>a <tt>boolean</tt> on whether the argument is a <tt>datetime</tt> value or not,</li>
9890<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9891<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9892</ul>
9893</li>
9894<li>
9895
9896<p>Example:</p>
9897
9898<div>
9899<div>
9900<pre class="source">{
9901 &quot;a&quot;: is_datetime(true),
9902 &quot;b&quot;: is_datetime(false),
9903 &quot;c&quot;: is_datetime(null),
9904 &quot;d&quot;: is_datetime(missing),
9905 &quot;e&quot;: is_datetime(datetime(&quot;2016-02-02T12:09:22.023Z&quot;)),
9906 &quot;f&quot;: isdatetime(datetime(&quot;2011-03-03T12:10:42.011Z&quot;)),
9907 &quot;g&quot;: isdatetime(time(&quot;12:12:12.039Z&quot;)),
9908 &quot;h&quot;: is_timestamp(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
9909 &quot;i&quot;: is_timestamp(duration(&quot;P100Y12MT12M&quot;)),
9910 &quot;j&quot;: istimestamp(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
9911 &quot;k&quot;: istimestamp(3)
9912};
9913</pre></div></div>
9914</li>
9915<li>
9916
9917<p>The expected result is:</p>
9918
9919<div>
9920<div>
9921<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 }
9922</pre></div></div>
9923</li>
9924</ul>
9925<p>The function has three aliases: <tt>isdatetime</tt>, <tt>is_timestamp</tt>, and <tt>istimestamp</tt>.</p></div>
9926<div class="section">
9927<h3><a name="is_time"></a>is_time</h3>
9928<ul>
9929
9930<li>
9931
9932<p>Syntax:</p>
9933
9934<div>
9935<div>
9936<pre class="source">is_time(expr)
9937</pre></div></div>
9938</li>
9939<li>
9940
9941<p>Checks whether the given expression is evaluated to be a <tt>time</tt> value.</p>
9942</li>
9943<li>Arguments:
9944<ul>
9945
9946<li><tt>expr</tt> : an expression (any type is allowed).</li>
9947</ul>
9948</li>
9949<li>Return Value:
9950<ul>
9951
9952<li>a <tt>boolean</tt> on whether the argument is a <tt>time</tt> value or not,</li>
9953<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9954<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9955</ul>
9956</li>
9957<li>
9958
9959<p>Example:</p>
9960
9961<div>
9962<div>
9963<pre class="source"> {
9964 &quot;a&quot;: is_time(true),
9965 &quot;b&quot;: is_time(false),
9966 &quot;c&quot;: is_time(null),
9967 &quot;d&quot;: is_time(missing),
9968 &quot;e&quot;: is_time(time(&quot;08:00:00.000Z&quot;)),
9969 &quot;f&quot;: istime(date(&quot;2013-01-01&quot;)),
9970 &quot;g&quot;: istime(time(&quot;12:12:12.039Z&quot;)),
9971 &quot;h&quot;: istime(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
9972 &quot;i&quot;: istime(duration(&quot;P100Y12MT12M&quot;)),
9973 &quot;j&quot;: istime(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
9974 &quot;k&quot;: istime(3)
9975};
9976</pre></div></div>
9977</li>
9978<li>
9979
9980<p>The expected result is:</p>
9981
9982<div>
9983<div>
9984<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 }
9985</pre></div></div>
9986</li>
9987</ul>
9988<p>The function has an alias <tt>istime</tt>.</p></div>
9989<div class="section">
9990<h3><a name="is_duration"></a>is_duration</h3>
9991<ul>
9992
9993<li>
9994
9995<p>Syntax:</p>
9996
9997<div>
9998<div>
9999<pre class="source">is_duration(expr)
10000</pre></div></div>
10001</li>
10002<li>
10003
10004<p>Checks whether the given expression is evaluated to be a duration value.</p>
10005</li>
10006<li>Arguments:
10007<ul>
10008
10009<li><tt>expr</tt> : an expression (any type is allowed).</li>
10010</ul>
10011</li>
10012<li>Return Value:
10013<ul>
10014
10015<li>a <tt>boolean</tt> on whether the argument is a <tt>duration/year_month_duration/day_time_duration</tt> value or not,</li>
10016<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10017<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10018</ul>
10019</li>
10020<li>
10021
10022<p>Example:</p>
10023
10024<div>
10025<div>
10026<pre class="source"> {
10027 &quot;a&quot;: is_duration(true),
10028 &quot;b&quot;: is_duration(false),
10029 &quot;c&quot;: is_duration(null),
10030 &quot;d&quot;: is_duration(missing),
10031 &quot;e&quot;: is_duration(duration(&quot;-PT20.943S&quot;)),
10032 &quot;f&quot;: isduration(date(&quot;2013-01-01&quot;)),
10033 &quot;g&quot;: isduration(time(&quot;12:12:12.039Z&quot;)),
10034 &quot;h&quot;: isduration(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10035 &quot;i&quot;: isduration(duration(&quot;P100Y12MT12M&quot;)),
10036 &quot;j&quot;: isduration(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10037 &quot;k&quot;: isduration(3)
10038};
10039</pre></div></div>
10040</li>
10041<li>
10042
10043<p>The expected result is:</p>
10044
10045<div>
10046<div>
10047<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 }
10048</pre></div></div>
10049</li>
10050</ul>
10051<p>The function has an alias <tt>isduration</tt>.</p></div>
10052<div class="section">
10053<h3><a name="is_interval"></a>is_interval</h3>
10054<ul>
10055
10056<li>
10057
10058<p>Syntax:</p>
10059
10060<div>
10061<div>
10062<pre class="source">is_interval(expr)
10063</pre></div></div>
10064</li>
10065<li>
10066
10067<p>Checks whether the given expression is evaluated to be a <tt>interval</tt> value.</p>
10068</li>
10069<li>Arguments:
10070<ul>
10071
10072<li><tt>expr</tt> : an expression (any type is allowed).</li>
10073</ul>
10074</li>
10075<li>Return Value:
10076<ul>
10077
10078<li>a <tt>boolean</tt> on whether the argument is a <tt>interval</tt> value or not,</li>
10079<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10080<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10081</ul>
10082</li>
10083<li>
10084
10085<p>Example:</p>
10086
10087<div>
10088<div>
10089<pre class="source"> {
10090 &quot;a&quot;: is_interval(true),
10091 &quot;b&quot;: is_interval(false),
10092 &quot;c&quot;: is_interval(null),
10093 &quot;d&quot;: is_interval(missing),
10094 &quot;e&quot;: is_interval(interval(datetime(&quot;2013-01-01T00:01:01.000Z&quot;), datetime(&quot;2013-05-05T13:39:01.049Z&quot;))),
10095 &quot;f&quot;: isinterval(date(&quot;2013-01-01&quot;)),
10096 &quot;g&quot;: isinterval(time(&quot;12:12:12.039Z&quot;)),
10097 &quot;h&quot;: isinterval(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10098 &quot;i&quot;: isinterval(duration(&quot;P100Y12MT12M&quot;)),
10099 &quot;j&quot;: isinterval(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10100 &quot;k&quot;: isinterval(3)
10101};
10102</pre></div></div>
10103</li>
10104<li>
10105
10106<p>The expected result is:</p>
10107
10108<div>
10109<div>
10110<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 }
10111</pre></div></div>
10112</li>
10113</ul>
10114<p>The function has an alias <tt>isinterval</tt>.</p></div>
10115<div class="section">
10116<h3><a name="is_temporal"></a>is_temporal</h3>
10117<ul>
10118
10119<li>
10120
10121<p>Syntax:</p>
10122
10123<div>
10124<div>
10125<pre class="source">is_temporal(expr)
10126</pre></div></div>
10127</li>
10128<li>
10129
10130<p>Checks whether the given expression is evaluated to be a temporal value.</p>
10131</li>
10132<li>Arguments:
10133<ul>
10134
10135<li><tt>expr</tt> : an expression (any type is allowed).</li>
10136</ul>
10137</li>
10138<li>Return Value:
10139<ul>
10140
10141<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>
10142<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10143<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10144</ul>
10145</li>
10146<li>
10147
10148<p>Example:</p>
10149
10150<div>
10151<div>
10152<pre class="source"> {
10153 &quot;a&quot;: is_temporal(true),
10154 &quot;b&quot;: is_temporal(false),
10155 &quot;c&quot;: is_temporal(null),
10156 &quot;d&quot;: is_temporal(missing),
10157 &quot;e&quot;: is_temporal(duration(&quot;-PT20.943S&quot;)),
10158 &quot;f&quot;: istemporal(date(&quot;2013-01-01&quot;)),
10159 &quot;g&quot;: istemporal(time(&quot;12:12:12.039Z&quot;)),
10160 &quot;h&quot;: istemporal(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10161 &quot;i&quot;: istemporal(duration(&quot;P100Y12MT12M&quot;)),
10162 &quot;j&quot;: istemporal(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10163 &quot;k&quot;: istemporal(3)
10164};
10165</pre></div></div>
10166</li>
10167<li>
10168
10169<p>The expected result is:</p>
10170
10171<div>
10172<div>
10173<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 }
10174</pre></div></div>
10175</li>
10176</ul>
10177<p>The function has an alias <tt>istemporal</tt>.</p></div>
10178<div class="section">
10179<h3><a name="is_object_.28is_obj.29"></a>is_object (is_obj)</h3>
10180<ul>
10181
10182<li>
10183
10184<p>Syntax:</p>
10185
10186<div>
10187<div>
10188<pre class="source">is_object(expr)
10189</pre></div></div>
10190</li>
10191<li>
10192
10193<p>Checks whether the given expression is evaluated to be a <tt>object</tt> value.</p>
10194</li>
10195<li>Arguments:
10196<ul>
10197
10198<li><tt>expr</tt> : an expression (any type is allowed).</li>
10199</ul>
10200</li>
10201<li>Return Value:
10202<ul>
10203
10204<li>a <tt>boolean</tt> on whether the argument is a <tt>object</tt> value or not,</li>
10205<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10206<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10207</ul>
10208</li>
10209<li>
10210
10211<p>Example:</p>
10212
10213<div>
10214<div>
10215<pre class="source">{
10216 &quot;a&quot;: is_object(true),
10217 &quot;b&quot;: is_object(false),
10218 &quot;c&quot;: isobject(null),
10219 &quot;d&quot;: isobject(missing),
10220 &quot;e&quot;: isobj(&quot;d&quot;),
10221 &quot;f&quot;: isobj(4.0),
10222 &quot;g&quot;: isobj(5),
10223 &quot;h&quot;: isobj([&quot;1&quot;, 2]),
10224 &quot;i&quot;: isobj({&quot;a&quot;:1})
10225};
10226</pre></div></div>
10227</li>
10228<li>
10229
10230<p>The expected result is:</p>
10231<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>
10232</li>
10233</ul>
10234<p>The function has three aliases: <tt>isobject</tt>, <tt>is_obj</tt>, and <tt>isobj</tt>.</p></div>
10235<div class="section">
10236<h3><a name="is_string_.28is_str.29"></a>is_string (is_str)</h3>
10237<ul>
10238
10239<li>
10240
10241<p>Syntax:</p>
10242
10243<div>
10244<div>
10245<pre class="source">is_string(expr)
10246</pre></div></div>
10247</li>
10248<li>
10249
10250<p>Checks whether the given expression is evaluated to be a <tt>string</tt> value.</p>
10251</li>
10252<li>Arguments:
10253<ul>
10254
10255<li><tt>expr</tt> : an expression (any type is allowed).</li>
10256</ul>
10257</li>
10258<li>Return Value:
10259<ul>
10260
10261<li>a <tt>boolean</tt> on whether the argument is a <tt>string</tt> value or not,</li>
10262<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10263<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10264</ul>
10265</li>
10266<li>
10267
10268<p>Example:</p>
10269
10270<div>
10271<div>
10272<pre class="source">{
10273 &quot;a&quot;: is_string(true),
10274 &quot;b&quot;: isstring(false),
10275 &quot;c&quot;: isstring(null),
10276 &quot;d&quot;: isstr(missing),
10277 &quot;e&quot;: isstr(&quot;d&quot;),
10278 &quot;f&quot;: isstr(4.0),
10279 &quot;g&quot;: isstr(5),
10280 &quot;h&quot;: isstr([&quot;1&quot;, 2]),
10281 &quot;i&quot;: isstr({&quot;a&quot;:1})
10282};
10283</pre></div></div>
10284</li>
10285<li>
10286
10287<p>The expected result is:</p>
10288
10289<div>
10290<div>
10291<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 }
10292</pre></div></div>
10293</li>
10294</ul>
10295<p>The function has three aliases: <tt>isstring</tt>, <tt>is_str</tt>, and <tt>isstr</tt>.</p></div>
10296<div class="section">
10297<h3><a name="is_uuid"></a>is_uuid</h3>
10298<ul>
10299
10300<li>
10301
10302<p>Syntax:</p>
10303
10304<div>
10305<div>
10306<pre class="source">is_uuid(expr)
10307</pre></div></div>
10308</li>
10309<li>
10310
10311<p>Checks whether the given expression is evaluated to be a <tt>uuid</tt> value.</p>
10312</li>
10313<li>Arguments:
10314<ul>
10315
10316<li><tt>expr</tt> : an expression (any type is allowed).</li>
10317</ul>
10318</li>
10319<li>Return Value:
10320<ul>
10321
10322<li>a <tt>boolean</tt> on whether the argument is a <tt>uuid</tt> value or not,</li>
10323<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10324<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10325</ul>
10326</li>
10327<li>
10328
10329<p>Example:</p>
10330
10331<div>
10332<div>
10333<pre class="source"> {
10334 &quot;a&quot;: is_uuid(true),
10335 &quot;b&quot;: is_uuid(false),
10336 &quot;c&quot;: is_uuid(null),
10337 &quot;d&quot;: is_uuid(missing),
10338 &quot;e&quot;: isuuid(4.0),
10339 &quot;f&quot;: isuuid(date(&quot;2013-01-01&quot;)),
10340 &quot;g&quot;: isuuid(uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;))
10341};
10342</pre></div></div>
10343</li>
10344<li>
10345
10346<p>The expected result is:</p>
10347
10348<div>
10349<div>
10350<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 }
10351</pre></div></div>
10352</li>
10353</ul>
10354<p>The function has an alias <tt>isuuid</tt>.</p></div>
10355<div class="section">
10356<h3><a name="is_null"></a>is_null</h3>
10357<ul>
10358
10359<li>
10360
10361<p>Syntax:</p>
10362
10363<div>
10364<div>
10365<pre class="source">is_null(expr)
10366</pre></div></div>
10367</li>
10368<li>
10369
10370<p>Checks whether the given expression is evaluated to be a <tt>null</tt> value.</p>
10371</li>
10372<li>Arguments:
10373<ul>
10374
10375<li><tt>expr</tt> : an expression (any type is allowed).</li>
10376</ul>
10377</li>
10378<li>Return Value:
10379<ul>
10380
10381<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt> or not,</li>
10382<li>a <tt>missing</tt> if the input is <tt>missing</tt>.</li>
10383</ul>
10384</li>
10385<li>
10386
10387<p>Example:</p>
10388
10389<div>
10390<div>
10391<pre class="source">{ &quot;v1&quot;: is_null(null), &quot;v2&quot;: is_null(1), &quot;v3&quot;: is_null(missing) };
10392</pre></div></div>
10393</li>
10394<li>
10395
10396<p>The expected result is:</p>
10397
10398<div>
10399<div>
10400<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
10401</pre></div></div>
10402</li>
10403</ul>
10404<p>The function has an alias <tt>isnull</tt>.</p></div>
10405<div class="section">
10406<h3><a name="is_missing"></a>is_missing</h3>
10407<ul>
10408
10409<li>
10410
10411<p>Syntax:</p>
10412
10413<div>
10414<div>
10415<pre class="source">is_missing(expr)
10416</pre></div></div>
10417</li>
10418<li>
10419
10420<p>Checks whether the given expression is evaluated to be a <tt>missing</tt> value.</p>
10421</li>
10422<li>Arguments:
10423<ul>
10424
10425<li><tt>expr</tt> : an expression (any type is allowed).</li>
10426</ul>
10427</li>
10428<li>Return Value:
10429<ul>
10430
10431<li>a <tt>boolean</tt> on whether the variable is a <tt>missing</tt> or not.</li>
10432</ul>
10433</li>
10434<li>
10435
10436<p>Example:</p>
10437
10438<div>
10439<div>
10440<pre class="source">{ &quot;v1&quot;: is_missing(null), &quot;v2&quot;: is_missing(1), &quot;v3&quot;: is_missing(missing) };
10441</pre></div></div>
10442</li>
10443<li>
10444
10445<p>The expected result is:</p>
10446
10447<div>
10448<div>
10449<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: false, &quot;v3&quot;: true }
10450</pre></div></div>
10451</li>
10452</ul>
10453<p>The function has an alias <tt>ismissing</tt>.</p></div>
10454<div class="section">
10455<h3><a name="is_unknown"></a>is_unknown</h3>
10456<ul>
10457
10458<li>
10459
10460<p>Syntax:</p>
10461
10462<div>
10463<div>
10464<pre class="source">is_unknown(expr)
10465</pre></div></div>
10466</li>
10467<li>
10468
10469<p>Checks whether the given variable is a <tt>null</tt> value or a <tt>missing</tt> value.</p>
10470</li>
10471<li>Arguments:
10472<ul>
10473
10474<li><tt>expr</tt> : an expression (any type is allowed).</li>
10475</ul>
10476</li>
10477<li>Return Value:
10478<ul>
10479
10480<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>
10481</ul>
10482</li>
10483<li>
10484
10485<p>Example:</p>
10486
10487<div>
10488<div>
10489<pre class="source">{ &quot;v1&quot;: is_unknown(null), &quot;v2&quot;: is_unknown(1), &quot;v3&quot;: is_unknown(missing) };
10490</pre></div></div>
10491</li>
10492<li>
10493
10494<p>The expected result is:</p>
10495
10496<div>
10497<div>
10498<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false, &quot;v3&quot;: true }
10499</pre></div></div>
10500</li>
10501</ul>
10502<p>The function has an alias <tt>isunknown</tt>.</p></div>
10503<div class="section">
10504<h3><a name="to_array"></a>to_array</h3>
10505<ul>
10506
10507<li>
10508
10509<p>Syntax:</p>
10510
10511<div>
10512<div>
10513<pre class="source">to_array(expr)
10514</pre></div></div>
10515</li>
10516<li>
10517
10518<p>Converts input value to an <tt>array</tt> value</p>
10519</li>
10520<li>Arguments:
10521<ul>
10522
10523<li><tt>expr</tt> : an expression</li>
10524</ul>
10525</li>
10526<li>Return Value:
10527<ul>
10528
10529<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10530<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10531<li>if the argument is of <tt>array</tt> type then it is returned as is</li>
10532<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>
10533<li>otherwise an <tt>array</tt> containing the input expression as its single item is returned</li>
10534</ul>
10535</li>
10536<li>
10537
10538<p>Example:</p>
10539
10540<div>
10541<div>
10542<pre class="source">{
10543 &quot;v1&quot;: to_array(&quot;asterix&quot;),
10544 &quot;v2&quot;: to_array([&quot;asterix&quot;]),
10545};
10546</pre></div></div>
10547</li>
10548<li>
10549
10550<p>The expected result is:</p>
10551
10552<div>
10553<div>
10554<pre class="source">{ &quot;v1&quot;: [&quot;asterix&quot;], &quot;v2&quot;: [&quot;asterix&quot;] }
10555</pre></div></div>
10556</li>
10557</ul>
10558<p>The function has an alias <tt>toarray</tt>.</p></div>
10559<div class="section">
10560<h3><a name="to_atomic_.28to_atom.29"></a>to_atomic (to_atom)</h3>
10561<ul>
10562
10563<li>
10564
10565<p>Syntax:</p>
10566
10567<div>
10568<div>
10569<pre class="source">to_atomic(expr)
10570</pre></div></div>
10571</li>
10572<li>
10573
10574<p>Converts input value to a <a href="../datamodel.html#PrimitiveTypes">primitive</a> value</p>
10575</li>
10576<li>Arguments:
10577<ul>
10578
10579<li><tt>expr</tt> : an expression</li>
10580</ul>
10581</li>
10582<li>Return Value:
10583<ul>
10584
10585<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10586<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10587<li>if the argument is of primitive type then it is returned as is</li>
10588<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>
10589<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>
10590<li>otherwise <tt>null</tt> is returned</li>
10591</ul>
10592</li>
10593<li>
10594
10595<p>Example:</p>
10596
10597<div>
10598<div>
10599<pre class="source">{
10600 &quot;v1&quot;: to_atomic(&quot;asterix&quot;),
10601 &quot;v2&quot;: to_atomic([&quot;asterix&quot;]),
10602 &quot;v3&quot;: to_atomic([0, 1]),
10603 &quot;v4&quot;: to_atomic({&quot;value&quot;: &quot;asterix&quot;}),
10604 &quot;v5&quot;: to_number({&quot;x&quot;: 1, &quot;y&quot;: 2})
10605};
10606</pre></div></div>
10607</li>
10608<li>
10609
10610<p>The expected result is:</p>
10611
10612<div>
10613<div>
10614<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 }
10615</pre></div></div>
10616</li>
10617</ul>
10618<p>The function has three aliases: <tt>toatomic</tt>, <tt>to_atom</tt>, and <tt>toatom</tt>.</p></div>
10619<div class="section">
10620<h3><a name="to_boolean_.28to_bool.29"></a>to_boolean (to_bool)</h3>
10621<ul>
10622
10623<li>
10624
10625<p>Syntax:</p>
10626
10627<div>
10628<div>
10629<pre class="source">to_boolean(expr)
10630</pre></div></div>
10631</li>
10632<li>
10633
10634<p>Converts input value to a <tt>boolean</tt> value</p>
10635</li>
10636<li>Arguments:
10637<ul>
10638
10639<li><tt>expr</tt> : an expression</li>
10640</ul>
10641</li>
10642<li>Return Value:
10643<ul>
10644
10645<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10646<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10647<li>if the argument is of <tt>boolean</tt> type then it is returned as is</li>
10648<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>
10649<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>
10650<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>
10651<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>
10652<li>type error is raised for all other input types</li>
10653</ul>
10654</li>
10655<li>
10656
10657<p>Example:</p>
10658
10659<div>
10660<div>
10661<pre class="source">{
10662 &quot;v1&quot;: to_boolean(0),
10663 &quot;v2&quot;: to_boolean(1),
10664 &quot;v3&quot;: to_boolean(&quot;&quot;),
10665 &quot;v4&quot;: to_boolean(&quot;asterix&quot;)
10666};
10667</pre></div></div>
10668</li>
10669<li>
10670
10671<p>The expected result is:</p>
10672
10673<div>
10674<div>
10675<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: false, &quot;v4&quot;: true }
10676</pre></div></div>
10677</li>
10678</ul>
10679<p>The function has three aliases: <tt>toboolean</tt>, <tt>to_bool</tt>, and <tt>tobool</tt>.</p></div>
10680<div class="section">
10681<h3><a name="to_bigint"></a>to_bigint</h3>
10682<ul>
10683
10684<li>
10685
10686<p>Syntax:</p>
10687
10688<div>
10689<div>
10690<pre class="source">to_bigint(expr)
10691</pre></div></div>
10692</li>
10693<li>
10694
10695<p>Converts input value to an integer value</p>
10696</li>
10697<li>Arguments:
10698<ul>
10699
10700<li><tt>expr</tt> : an expression</li>
10701</ul>
10702</li>
10703<li>Return Value:
10704<ul>
10705
10706<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10707<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10708<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>
10709<li>if the argument is of numeric integer type then it is returned as the same value of <tt>bigint</tt> type</li>
10710<li>if the argument is of numeric <tt>float</tt>/<tt>double</tt> type then it is converted to <tt>bigint</tt> type</li>
10711<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>
10712<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10713<li>type error is raised for all other input types</li>
10714</ul>
10715</li>
10716<li>
10717
10718<p>Example:</p>
10719
10720<div>
10721<div>
10722<pre class="source">{
10723 &quot;v1&quot;: to_bigint(false),
10724 &quot;v2&quot;: to_bigint(true),
10725 &quot;v3&quot;: to_bigint(10),
10726 &quot;v4&quot;: to_bigint(float(&quot;1e100&quot;)),
10727 &quot;v5&quot;: to_bigint(double(&quot;1e1000&quot;)),
10728 &quot;v6&quot;: to_bigint(&quot;20&quot;)
10729};
10730</pre></div></div>
10731</li>
10732<li>
10733
10734<p>The expected result is:</p>
10735
10736<div>
10737<div>
10738<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 }
10739</pre></div></div>
10740</li>
10741</ul>
10742<p>The function has an alias <tt>tobigint</tt>.</p></div>
10743<div class="section">
10744<h3><a name="to_double"></a>to_double</h3>
10745<ul>
10746
10747<li>
10748
10749<p>Syntax:</p>
10750
10751<div>
10752<div>
10753<pre class="source">to_double(expr)
10754</pre></div></div>
10755</li>
10756<li>
10757
10758<p>Converts input value to a <tt>double</tt> value</p>
10759</li>
10760<li>Arguments:
10761<ul>
10762
10763<li><tt>expr</tt> : an expression</li>
10764</ul>
10765</li>
10766<li>Return Value:
10767<ul>
10768
10769<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10770<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10771<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>
10772<li>if the argument is of numeric type then it is returned as the value of <tt>double</tt> type</li>
10773<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>
10774<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10775<li>type error is raised for all other input types</li>
10776</ul>
10777</li>
10778<li>
10779
10780<p>Example:</p>
10781
10782<div>
10783<div>
10784<pre class="source">{
10785 &quot;v1&quot;: to_double(false),
10786 &quot;v2&quot;: to_double(true),
10787 &quot;v3&quot;: to_double(10),
10788 &quot;v4&quot;: to_double(11.5),
10789 &quot;v5&quot;: to_double(&quot;12.5&quot;)
10790};
10791</pre></div></div>
10792</li>
10793<li>
10794
10795<p>The expected result is:</p>
10796
10797<div>
10798<div>
10799<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 }
10800</pre></div></div>
10801</li>
10802</ul>
10803<p>The function has an alias <tt>todouble</tt>.</p></div>
10804<div class="section">
10805<h3><a name="to_number_.28to_num.29"></a>to_number (to_num)</h3>
10806<ul>
10807
10808<li>
10809
10810<p>Syntax:</p>
10811
10812<div>
10813<div>
10814<pre class="source">to_number(expr)
10815</pre></div></div>
10816</li>
10817<li>
10818
10819<p>Converts input value to a numeric value</p>
10820</li>
10821<li>Arguments:
10822<ul>
10823
10824<li><tt>expr</tt> : an expression</li>
10825</ul>
10826</li>
10827<li>Return Value:
10828<ul>
10829
10830<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10831<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10832<li>if the argument is of numeric type then it is returned as is</li>
10833<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>
10834<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>
10835<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10836<li>type error is raised for all other input types</li>
10837</ul>
10838</li>
10839<li>
10840
10841<p>Example:</p>
10842
10843<div>
10844<div>
10845<pre class="source">{
10846 &quot;v1&quot;: to_number(false),
10847 &quot;v2&quot;: to_number(true),
10848 &quot;v3&quot;: to_number(10),
10849 &quot;v4&quot;: to_number(11.5),
10850 &quot;v5&quot;: to_number(&quot;12.5&quot;)
10851};
10852</pre></div></div>
10853</li>
10854<li>
10855
10856<p>The expected result is:</p>
10857
10858<div>
10859<div>
10860<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 }
10861</pre></div></div>
10862</li>
10863</ul>
10864<p>The function has three aliases: <tt>tonumber</tt>, <tt>to_num</tt>, and <tt>tonum</tt>.</p></div>
10865<div class="section">
10866<h3><a name="to_object_.28to_obj.29"></a>to_object (to_obj)</h3>
10867<ul>
10868
10869<li>
10870
10871<p>Syntax:</p>
10872
10873<div>
10874<div>
10875<pre class="source">to_object(expr)
10876</pre></div></div>
10877</li>
10878<li>
10879
10880<p>Converts input value to an <tt>object</tt> value</p>
10881</li>
10882<li>Arguments:
10883<ul>
10884
10885<li><tt>expr</tt> : an expression</li>
10886</ul>
10887</li>
10888<li>Return Value:
10889<ul>
10890
10891<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10892<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10893<li>if the argument is of <tt>object</tt> type then it is returned as is</li>
10894<li>otherwise an empty <tt>object</tt> is returned</li>
10895</ul>
10896</li>
10897<li>
10898
10899<p>Example:</p>
10900
10901<div>
10902<div>
10903<pre class="source">{
10904 &quot;v1&quot;: to_object({&quot;value&quot;: &quot;asterix&quot;}),
10905 &quot;v2&quot;: to_object(&quot;asterix&quot;)
10906};
10907</pre></div></div>
10908</li>
10909<li>
10910
10911<p>The expected result is:</p>
10912
10913<div>
10914<div>
10915<pre class="source">{ &quot;v1&quot;: {&quot;value&quot;: &quot;asterix&quot;}, &quot;v2&quot;: {} }
10916</pre></div></div>
10917</li>
10918</ul>
10919<p>The function has three aliases: <tt>toobject</tt>, <tt>to_obj</tt>, and <tt>toobj</tt>.</p></div>
10920<div class="section">
10921<h3><a name="to_string_.28to_str.29"></a>to_string (to_str)</h3>
10922<ul>
10923
10924<li>
10925
10926<p>Syntax:</p>
10927
10928<div>
10929<div>
10930<pre class="source">to_string(expr)
10931</pre></div></div>
10932</li>
10933<li>
10934
10935<p>Converts input value to a string value</p>
10936</li>
10937<li>Arguments:
10938<ul>
10939
10940<li><tt>expr</tt> : an expression</li>
10941</ul>
10942</li>
10943<li>Return Value:
10944<ul>
10945
10946<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10947<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10948<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>
10949<li>if the argument is of numeric type then its string representation is returned</li>
10950<li>if the argument is of <tt>string</tt> type then it is returned as is</li>
10951<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10952<li>type error is raised for all other input types</li>
10953</ul>
10954</li>
10955<li>
10956
10957<p>Example:</p>
10958
10959<div>
10960<div>
10961<pre class="source">{
10962 &quot;v1&quot;: to_string(false),
10963 &quot;v2&quot;: to_string(true),
10964 &quot;v3&quot;: to_string(10),
10965 &quot;v4&quot;: to_string(11.5),
10966 &quot;v5&quot;: to_string(&quot;asterix&quot;)
10967};
10968</pre></div></div>
10969</li>
10970<li>
10971
10972<p>The expected result is:</p>
10973
10974<div>
10975<div>
10976<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; }
10977</pre></div></div>
10978</li>
10979</ul>
10980<p>The function has three aliases: <tt>tostring</tt>, <tt>to_str</tt>, and <tt>tostr</tt>.</p><!--
10981 ! Licensed to the Apache Software Foundation (ASF) under one
10982 ! or more contributor license agreements. See the NOTICE file
10983 ! distributed with this work for additional information
10984 ! regarding copyright ownership. The ASF licenses this file
10985 ! to you under the Apache License, Version 2.0 (the
10986 ! "License"); you may not use this file except in compliance
10987 ! with the License. You may obtain a copy of the License at
10988 !
10989 ! http://www.apache.org/licenses/LICENSE-2.0
10990 !
10991 ! Unless required by applicable law or agreed to in writing,
10992 ! software distributed under the License is distributed on an
10993 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10994 ! KIND, either express or implied. See the License for the
10995 ! specific language governing permissions and limitations
10996 ! under the License.
10997 !-->
10998</div></div>
10999<div class="section">
11000<h2><a name="Conditional_Functions"></a><a name="ConditionalFunctions" id="ConditionalFunctions">Conditional Functions</a></h2>
11001<div class="section">
11002<h3><a name="if_null_.28ifnull.29"></a>if_null (ifnull)</h3>
11003<ul>
11004
11005<li>
11006
11007<p>Syntax:</p>
11008
11009<div>
11010<div>
11011<pre class="source">if_null(expression1, expression2, ... expressionN)
11012</pre></div></div>
11013</li>
11014<li>
11015
11016<p>Finds first argument which value is not <tt>null</tt> and returns that value</p>
11017</li>
11018<li>Arguments:
11019<ul>
11020
11021<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11022</ul>
11023</li>
11024<li>Return Value:
11025<ul>
11026
11027<li>a <tt>null</tt> if all arguments evaluate to <tt>null</tt> or no arguments specified</li>
11028<li>a value of the first non-<tt>null</tt> argument otherwise</li>
11029</ul>
11030</li>
11031<li>
11032
11033<p>Example:</p>
11034
11035<div>
11036<div>
11037<pre class="source">{
11038 &quot;a&quot;: if_null(),
11039 &quot;b&quot;: if_null(null),
11040 &quot;c&quot;: if_null(null, &quot;asterixdb&quot;),
11041 &quot;d&quot;: is_missing(if_null(missing))
11042};
11043</pre></div></div>
11044</li>
11045<li>
11046
11047<p>The expected result is:</p>
11048
11049<div>
11050<div>
11051<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: true }
11052</pre></div></div>
11053</li>
11054</ul>
11055<p>The function has an alias <tt>ifnull</tt>.</p></div>
11056<div class="section">
11057<h3><a name="if_missing_.28ifmissing.29"></a>if_missing (ifmissing)</h3>
11058<ul>
11059
11060<li>
11061
11062<p>Syntax:</p>
11063
11064<div>
11065<div>
11066<pre class="source">if_missing(expression1, expression2, ... expressionN)
11067</pre></div></div>
11068</li>
11069<li>
11070
11071<p>Finds first argument which value is not <tt>missing</tt> and returns that value</p>
11072</li>
11073<li>Arguments:
11074<ul>
11075
11076<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11077</ul>
11078</li>
11079<li>Return Value:
11080<ul>
11081
11082<li>a <tt>null</tt> if all arguments evaluate to <tt>missing</tt> or no arguments specified</li>
11083<li>a value of the first non-<tt>missing</tt> argument otherwise</li>
11084</ul>
11085</li>
11086<li>
11087
11088<p>Example:</p>
11089
11090<div>
11091<div>
11092<pre class="source">{
11093 &quot;a&quot;: if_missing(),
11094 &quot;b&quot;: if_missing(missing),
11095 &quot;c&quot;: if_missing(missing, &quot;asterixdb&quot;),
11096 &quot;d&quot;: if_missing(null, &quot;asterixdb&quot;)
11097};
11098</pre></div></div>
11099</li>
11100<li>
11101
11102<p>The expected result is:</p>
11103
11104<div>
11105<div>
11106<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: null }
11107</pre></div></div>
11108</li>
11109</ul>
11110<p>The function has an alias <tt>ifmissing</tt>.</p></div>
11111<div class="section">
11112<h3><a name="if_missing_or_null_.28ifmissingornull.2C_coalesce.29"></a>if_missing_or_null (ifmissingornull, coalesce)</h3>
11113<ul>
11114
11115<li>
11116
11117<p>Syntax:</p>
11118
11119<div>
11120<div>
11121<pre class="source">if_missing_or_null(expression1, expression2, ... expressionN)
11122</pre></div></div>
11123</li>
11124<li>
11125
11126<p>Finds first argument which value is not <tt>null</tt> or <tt>missing</tt> and returns that value</p>
11127</li>
11128<li>Arguments:
11129<ul>
11130
11131<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11132</ul>
11133</li>
11134<li>Return Value:
11135<ul>
11136
11137<li>a <tt>null</tt> if all arguments evaluate to either <tt>null</tt> or <tt>missing</tt>, or no arguments specified</li>
11138<li>a value of the first non-<tt>null</tt>, non-<tt>missing</tt> argument otherwise</li>
11139</ul>
11140</li>
11141<li>
11142
11143<p>Example:</p>
11144
11145<div>
11146<div>
11147<pre class="source">{
11148 &quot;a&quot;: if_missing_or_null(),
11149 &quot;b&quot;: if_missing_or_null(null, missing),
11150 &quot;c&quot;: if_missing_or_null(null, missing, &quot;asterixdb&quot;)
11151};
11152</pre></div></div>
11153</li>
11154<li>
11155
11156<p>The expected result is:</p>
11157
11158<div>
11159<div>
11160<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot; }
11161</pre></div></div>
11162</li>
11163</ul>
11164<p>The function has two aliases: <tt>ifmissingornull</tt> and <tt>coalesce</tt>.</p></div>
11165<div class="section">
11166<h3><a name="if_inf_.28ifinf.29"></a>if_inf (ifinf)</h3>
11167<ul>
11168
11169<li>
11170
11171<p>Syntax:</p>
11172
11173<div>
11174<div>
11175<pre class="source">if_inf(expression1, expression2, ... expressionN)
11176</pre></div></div>
11177</li>
11178<li>
11179
11180<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) number</p>
11181</li>
11182<li>Arguments:
11183<ul>
11184
11185<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11186</ul>
11187</li>
11188<li>Return Value:
11189<ul>
11190
11191<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-infinite number argument</li>
11192<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>
11193<li>the first non-infinite number 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;: is_null(if_inf(null)),
11204 &quot;b&quot;: is_missing(if_inf(missing)),
11205 &quot;c&quot;: is_null(if_inf(double(&quot;INF&quot;))),
11206 &quot;d&quot;: if_inf(1, null, missing) ],
11207 &quot;e&quot;: is_null(if_inf(null, missing, 1)) ],
11208 &quot;f&quot;: is_missing(if_inf(missing, null, 1)) ],
11209 &quot;g&quot;: if_inf(float(&quot;INF&quot;), 1) ],
11210 &quot;h&quot;: to_string(if_inf(float(&quot;INF&quot;), double(&quot;NaN&quot;), 1)) ]
11211};
11212</pre></div></div>
11213</li>
11214<li>
11215
11216<p>The expected result is:</p>
11217
11218<div>
11219<div>
11220<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; }
11221</pre></div></div>
11222</li>
11223</ul>
11224<p>The function has an alias <tt>ifinf</tt>.</p></div>
11225<div class="section">
11226<h3><a name="if_nan_.28ifnan.29"></a>if_nan (ifnan)</h3>
11227<ul>
11228
11229<li>
11230
11231<p>Syntax:</p>
11232
11233<div>
11234<div>
11235<pre class="source">if_nan(expression1, expression2, ... expressionN)
11236</pre></div></div>
11237</li>
11238<li>
11239
11240<p>Finds first argument which is a non-<tt>NaN</tt> number</p>
11241</li>
11242<li>Arguments:
11243<ul>
11244
11245<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11246</ul>
11247</li>
11248<li>Return Value:
11249<ul>
11250
11251<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-<tt>NaN</tt> number argument</li>
11252<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>
11253<li>the first non-<tt>NaN</tt> number argument otherwise</li>
11254</ul>
11255</li>
11256<li>
11257
11258<p>Example:</p>
11259
11260<div>
11261<div>
11262<pre class="source">{
11263 &quot;a&quot;: is_null(if_nan(null)),
11264 &quot;b&quot;: is_missing(if_nan(missing)),
11265 &quot;c&quot;: is_null(if_nan(double(&quot;NaN&quot;))),
11266 &quot;d&quot;: if_nan(1, null, missing) ],
11267 &quot;e&quot;: is_null(if_nan(null, missing, 1)) ],
11268 &quot;f&quot;: is_missing(if_nan(missing, null, 1)) ],
11269 &quot;g&quot;: if_nan(float(&quot;NaN&quot;), 1) ],
11270 &quot;h&quot;: to_string(if_nan(float(&quot;NaN&quot;), double(&quot;INF&quot;), 1)) ]
11271};
11272</pre></div></div>
11273</li>
11274<li>
11275
11276<p>The expected result is:</p>
11277
11278<div>
11279<div>
11280<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; }
11281</pre></div></div>
11282</li>
11283</ul>
11284<p>The function has an alias <tt>ifnan</tt>.</p></div>
11285<div class="section">
11286<h3><a name="if_nan_or_inf_.28ifnanorinf.29"></a>if_nan_or_inf (ifnanorinf)</h3>
11287<ul>
11288
11289<li>
11290
11291<p>Syntax:</p>
11292
11293<div>
11294<div>
11295<pre class="source">if_nan_or_inf(expression1, expression2, ... expressionN)
11296</pre></div></div>
11297</li>
11298<li>
11299
11300<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) and non-<tt>NaN</tt> number</p>
11301</li>
11302<li>Arguments:
11303<ul>
11304
11305<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11306</ul>
11307</li>
11308<li>Return Value:
11309<ul>
11310
11311<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>
11312<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>
11313<li>the first non-infinite and non-<tt>NaN</tt> number argument otherwise</li>
11314</ul>
11315</li>
11316<li>
11317
11318<p>Example:</p>
11319
11320<div>
11321<div>
11322<pre class="source">{
11323 &quot;a&quot;: is_null(if_nan_or_inf(null)),
11324 &quot;b&quot;: is_missing(if_nan_or_inf(missing)),
11325 &quot;c&quot;: is_null(if_nan_or_inf(double(&quot;NaN&quot;), double(&quot;INF&quot;))),
11326 &quot;d&quot;: if_nan_or_inf(1, null, missing) ],
11327 &quot;e&quot;: is_null(if_nan_or_inf(null, missing, 1)) ],
11328 &quot;f&quot;: is_missing(if_nan_or_inf(missing, null, 1)) ],
11329 &quot;g&quot;: if_nan_or_inf(float(&quot;NaN&quot;), float(&quot;INF&quot;), 1) ],
11330};
11331</pre></div></div>
11332</li>
11333<li>
11334
11335<p>The expected result is:</p>
11336
11337<div>
11338<div>
11339<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 }
11340</pre></div></div>
11341</li>
11342</ul>
11343<p>The function has an alias <tt>ifnanorinf</tt>.</p></div>
11344<div class="section">
11345<h3><a name="null_if_.28nullif.29"></a>null_if (nullif)</h3>
11346<ul>
11347
11348<li>
11349
11350<p>Syntax:</p>
11351
11352<div>
11353<div>
11354<pre class="source">null_if(expression1, expression2)
11355</pre></div></div>
11356</li>
11357<li>
11358
11359<p>Compares two arguments and returns <tt>null</tt> if they are equal, otherwise returns the first argument.</p>
11360</li>
11361<li>Arguments:
11362<ul>
11363
11364<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11365</ul>
11366</li>
11367<li>Return Value:
11368<ul>
11369
11370<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11371<li><tt>null</tt> if
11372<ul>
11373
11374<li>any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or</li>
11375<li><tt>argument1</tt> = <tt>argument2</tt></li>
11376</ul>
11377</li>
11378<li>a value of the first argument otherwise</li>
11379</ul>
11380</li>
11381<li>
11382
11383<p>Example:</p>
11384
11385<div>
11386<div>
11387<pre class="source">{
11388 &quot;a&quot;: null_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;),
11389 &quot;b&quot;: null_if(1, 2)
11390};
11391</pre></div></div>
11392</li>
11393<li>
11394
11395<p>The expected result is:</p>
11396
11397<div>
11398<div>
11399<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: 1 }
11400</pre></div></div>
11401</li>
11402</ul>
11403<p>The function has an alias <tt>nullif</tt>.</p></div>
11404<div class="section">
11405<h3><a name="missing_if_.28missingif.29"></a>missing_if (missingif)</h3>
11406<ul>
11407
11408<li>
11409
11410<p>Syntax:</p>
11411
11412<div>
11413<div>
11414<pre class="source">missing_if(expression1, expression2)
11415</pre></div></div>
11416</li>
11417<li>
11418
11419<p>Compares two arguments and returns <tt>missing</tt> if they are equal, otherwise returns the first argument.</p>
11420</li>
11421<li>Arguments:
11422<ul>
11423
11424<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11425</ul>
11426</li>
11427<li>Return Value:
11428<ul>
11429
11430<li><tt>missing</tt> if
11431<ul>
11432
11433<li>any argument is a <tt>missing</tt> value, or</li>
11434<li>no argument is a <tt>null</tt> value and <tt>argument1</tt> = <tt>argument2</tt></li>
11435</ul>
11436</li>
11437<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11438<li>a value of the first argument otherwise</li>
11439</ul>
11440</li>
11441<li>
11442
11443<p>Example:</p>
11444
11445<div>
11446<div>
11447<pre class="source">{
11448 &quot;a&quot;: missing_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)
11449 &quot;b&quot;: missing_if(1, 2),
11450};
11451</pre></div></div>
11452</li>
11453<li>
11454
11455<p>The expected result is:</p>
11456
11457<div>
11458<div>
11459<pre class="source">{ &quot;b&quot;: 1 }
11460</pre></div></div>
11461</li>
11462</ul>
11463<p>The function has an alias <tt>missingif</tt>.</p></div>
11464<div class="section">
11465<h3><a name="nan_if_.28nanif.29"></a>nan_if (nanif)</h3>
11466<ul>
11467
11468<li>
11469
11470<p>Syntax:</p>
11471
11472<div>
11473<div>
11474<pre class="source">nan_if(expression1, expression2)
11475</pre></div></div>
11476</li>
11477<li>
11478
11479<p>Compares two arguments and returns <tt>NaN</tt> value if they are equal, otherwise returns the first argument.</p>
11480</li>
11481<li>Arguments:
11482<ul>
11483
11484<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11485</ul>
11486</li>
11487<li>Return Value:
11488<ul>
11489
11490<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11491<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11492<li><tt>NaN</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11493<li>a value of the first argument otherwise</li>
11494</ul>
11495</li>
11496<li>
11497
11498<p>Example:</p>
11499
11500<div>
11501<div>
11502<pre class="source">{
11503 &quot;a&quot;: to_string(nan_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11504 &quot;b&quot;: nan_if(1, 2)
11505};
11506</pre></div></div>
11507</li>
11508<li>
11509
11510<p>The expected result is:</p>
11511
11512<div>
11513<div>
11514<pre class="source">{ &quot;a&quot;: &quot;NaN&quot;, &quot;b&quot;: 1 }
11515</pre></div></div>
11516</li>
11517</ul>
11518<p>The function has an alias <tt>nanif</tt>.</p></div>
11519<div class="section">
11520<h3><a name="posinf_if_.28posinfif.29"></a>posinf_if (posinfif)</h3>
11521<ul>
11522
11523<li>
11524
11525<p>Syntax:</p>
11526
11527<div>
11528<div>
11529<pre class="source">posinf_if(expression1, expression2)
11530</pre></div></div>
11531</li>
11532<li>
11533
11534<p>Compares two arguments and returns <tt>+INF</tt> value if they are equal, otherwise returns the first argument.</p>
11535</li>
11536<li>Arguments:
11537<ul>
11538
11539<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11540</ul>
11541</li>
11542<li>Return Value:
11543<ul>
11544
11545<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11546<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11547<li><tt>+INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11548<li>a value of the first argument otherwise</li>
11549</ul>
11550</li>
11551<li>
11552
11553<p>Example:</p>
11554
11555<div>
11556<div>
11557<pre class="source">{
11558 &quot;a&quot;: to_string(posinf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11559 &quot;b&quot;: posinf_if(1, 2)
11560};
11561</pre></div></div>
11562</li>
11563<li>
11564
11565<p>The expected result is:</p>
11566
11567<div>
11568<div>
11569<pre class="source">{ &quot;a&quot;: &quot;+INF&quot;, &quot;b&quot;: 1 }
11570</pre></div></div>
11571</li>
11572</ul>
11573<p>The function has an alias <tt>posinfif</tt>.</p></div>
11574<div class="section">
11575<h3><a name="neginf_if_.28neginfif.29"></a>neginf_if (neginfif)</h3>
11576<ul>
11577
11578<li>
11579
11580<p>Syntax:</p>
11581
11582<div>
11583<div>
11584<pre class="source">neginf_if(expression1, expression2)
11585</pre></div></div>
11586</li>
11587<li>
11588
11589<p>Compares two arguments and returns <tt>-INF</tt> value if they are equal, otherwise returns the first argument.</p>
11590</li>
11591<li>Arguments:
11592<ul>
11593
11594<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11595</ul>
11596</li>
11597<li>Return Value:
11598<ul>
11599
11600<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11601<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11602<li><tt>-INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></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;: to_string(neginf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11614 &quot;b&quot;: neginf_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;a&quot;: &quot;-INF&quot;, &quot;b&quot;: 1 }
11625</pre></div></div>
11626</li>
11627</ul>
11628<p>The function has an alias <tt>neginfif</tt>.</p><!--
11629 ! Licensed to the Apache Software Foundation (ASF) under one
11630 ! or more contributor license agreements. See the NOTICE file
11631 ! distributed with this work for additional information
11632 ! regarding copyright ownership. The ASF licenses this file
11633 ! to you under the Apache License, Version 2.0 (the
11634 ! "License"); you may not use this file except in compliance
11635 ! with the License. You may obtain a copy of the License at
11636 !
11637 ! http://www.apache.org/licenses/LICENSE-2.0
11638 !
11639 ! Unless required by applicable law or agreed to in writing,
11640 ! software distributed under the License is distributed on an
11641 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11642 ! KIND, either express or implied. See the License for the
11643 ! specific language governing permissions and limitations
11644 ! under the License.
11645 !-->
11646</div></div>
11647<div class="section">
11648<h2><a name="Miscellaneous_Functions"></a><a name="MiscFunctions" id="MiscFunctions">Miscellaneous Functions</a></h2>
11649<div class="section">
11650<h3><a name="uuid"></a>uuid</h3>
11651<ul>
11652
11653<li>
11654
11655<p>Syntax:</p>
11656
11657<div>
11658<div>
11659<pre class="source">uuid()
11660</pre></div></div>
11661</li>
11662<li>
11663
11664<p>Generates a <tt>uuid</tt>.</p>
11665</li>
11666<li>Arguments:
11667<ul>
11668
11669<li>none</li>
11670</ul>
11671</li>
11672<li>Return Value:
11673<ul>
11674
11675<li>a generated, random <tt>uuid</tt>.</li>
11676</ul>
11677</li>
11678</ul></div>
11679<div class="section">
11680<h3><a name="len"></a>len</h3>
11681<ul>
11682
11683<li>
11684
11685<p>Syntax:</p>
11686<p>len(array)</p>
11687</li>
11688<li>
11689
11690<p>Returns the length of the array array.</p>
11691</li>
11692<li>Arguments:
11693<ul>
11694
11695<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>
11696</ul>
11697</li>
11698<li>Return Value:
11699<ul>
11700
11701<li>an <tt>integer</tt> that represents the length of input array or the size of the input multiset,</li>
11702<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11703<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
11704</ul>
11705</li>
11706<li>
11707
11708<p>Example:</p>
11709
11710<div>
11711<div>
11712<pre class="source">len([&quot;Hello&quot;, &quot;World&quot;])
11713</pre></div></div>
11714</li>
11715<li>
11716
11717<p>The expected result is:</p>
11718
11719<div>
11720<div>
11721<pre class="source">2
11722</pre></div></div>
11723</li>
11724</ul></div>
11725<div class="section">
11726<h3><a name="not"></a>not</h3>
11727<ul>
11728
11729<li>
11730
11731<p>Syntax:</p>
11732
11733<div>
11734<div>
11735<pre class="source">not(expr)
11736</pre></div></div>
11737</li>
11738<li>
11739
11740<p>Inverts a <tt>boolean</tt> value</p>
11741</li>
11742<li>Arguments:
11743<ul>
11744
11745<li><tt>expr</tt> : an expression</li>
11746</ul>
11747</li>
11748<li>Return Value:
11749<ul>
11750
11751<li>a <tt>boolean</tt>, the inverse of <tt>expr</tt>,</li>
11752<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11753<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
11754<li>other non-boolean argument value will cause a type error.</li>
11755</ul>
11756</li>
11757<li>Example:
11758
11759<div>
11760<div>
11761<pre class="source">{ &quot;v1&quot;: `not`(true), &quot;v2&quot;: `not`(false), &quot;v3&quot;: `not`(null), &quot;v4&quot;: `not`(missing) };
11762</pre></div></div>
11763</li>
11764<li>
11765
11766<p>The expected result is:</p>
11767
11768<div>
11769<div>
11770<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: null }
11771</pre></div></div>
11772</li>
11773</ul></div>
11774<div class="section">
11775<h3><a name="random"></a>random</h3>
11776<ul>
11777
11778<li>
11779
11780<p>Syntax:</p>
11781
11782<div>
11783<div>
11784<pre class="source">random( [seed_value] )
11785</pre></div></div>
11786</li>
11787<li>
11788
11789<p>Returns a random number, accepting an optional seed value</p>
11790</li>
11791<li>Arguments:
11792<ul>
11793
11794<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>
11795</ul>
11796</li>
11797<li>Return Value:
11798<ul>
11799
11800<li>A random number of type <tt>double</tt> between 0 and 1,</li>
11801<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
11802<li><tt>null</tt> if the argument is a <tt>null</tt> value or a non-numeric value.</li>
11803</ul>
11804</li>
11805<li>
11806
11807<p>Example:</p>
11808
11809<div>
11810<div>
11811<pre class="source">{
11812 &quot;v1&quot;: random(),
11813 &quot;v2&quot;: random(unix_time_from_datetime_in_ms(current_datetime()))
11814};
11815</pre></div></div>
11816</li>
11817</ul></div>
11818<div class="section">
11819<h3><a name="range"></a>range</h3>
11820<ul>
11821
11822<li>
11823
11824<p>Syntax:</p>
11825
11826<div>
11827<div>
11828<pre class="source">range(start_numeric_value, end_numeric_value)
11829</pre></div></div>
11830</li>
11831<li>
11832
11833<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>
11834</li>
11835<li>Arguments:</li>
11836<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>
11837<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>
11838<li>Return Value:
11839<ul>
11840
11841<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>
11842</ul>
11843</li>
11844<li>Example:
11845
11846<div>
11847<div>
11848<pre class="source">range(0, 3);
11849</pre></div></div>
11850</li>
11851<li>
11852
11853<p>The expected result is:</p>
11854
11855<div>
11856<div>
11857<pre class="source">[ 0, 1, 2, 3 ]
11858</pre></div></div>
11859</li>
11860</ul></div>
11861<div class="section">
11862<h3><a name="switch_case"></a>switch_case</h3>
11863<ul>
11864
11865<li>
11866
11867<p>Syntax:</p>
11868
11869<div>
11870<div>
11871<pre class="source">switch_case(
11872 condition,
11873 case1, case1_result,
11874 case2, case2_result,
11875 ...,
11876 default, default_result
11877)
11878</pre></div></div>
11879</li>
11880<li>
11881
11882<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>
11883</li>
11884<li>Arguments:
11885<ul>
11886
11887<li><tt>condition</tt>: a variable (any type is allowed).</li>
11888<li><tt>caseI/default</tt>: a variable (any type is allowed).</li>
11889<li><tt>caseI/default_result</tt>: a variable (any type is allowed).</li>
11890</ul>
11891</li>
11892<li>Return Value:
11893<ul>
11894
11895<li><tt>caseI_result</tt> if <tt>condition</tt> matches <tt>caseI</tt>, otherwise <tt>default_result</tt>.</li>
11896</ul>
11897</li>
11898<li>Example 1:
11899
11900<div>
11901<div>
11902<pre class="source">switch_case(
11903 &quot;a&quot;,
11904 &quot;a&quot;, 0,
11905 &quot;x&quot;, 1,
11906 &quot;y&quot;, 2,
11907 &quot;z&quot;, 3
11908);
11909</pre></div></div>
11910</li>
11911<li>
11912
11913<p>The expected result is:</p>
11914
11915<div>
11916<div>
11917<pre class="source">0
11918</pre></div></div>
11919</li>
11920<li>
11921
11922<p>Example 2:</p>
11923
11924<div>
11925<div>
11926<pre class="source">switch_case(
11927 &quot;a&quot;,
11928 &quot;x&quot;, 1,
11929 &quot;y&quot;, 2,
11930 &quot;z&quot;, 3
11931);
11932</pre></div></div>
11933</li>
11934<li>
11935
11936<p>The expected result is:</p>
11937
11938<div>
11939<div>
11940<pre class="source">3
11941</pre></div></div>
11942</li>
11943</ul></div>
11944<div class="section">
11945<h3><a name="deep_equal"></a>deep_equal</h3>
11946<ul>
11947
11948<li>
11949
11950<p>Syntax:</p>
11951
11952<div>
11953<div>
11954<pre class="source">deep_equal(expr1, expr2)
11955</pre></div></div>
11956</li>
11957<li>
11958
11959<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>
11960</li>
11961<li>Arguments:
11962<ul>
11963
11964<li><tt>expr1</tt> : an expression,</li>
11965<li><tt>expr2</tt> : an expression.</li>
11966</ul>
11967</li>
11968<li>Return Value:
11969<ul>
11970
11971<li><tt>true</tt> or <tt>false</tt> depending on the data equality,</li>
11972<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11973<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
11974</ul>
11975</li>
11976<li>
11977
11978<p>Example:</p>
11979
11980<div>
11981<div>
11982<pre class="source">deep_equal(
11983 {
11984 &quot;id&quot;:1,
11985 &quot;project&quot;:&quot;AsterixDB&quot;,
11986 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
11987 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
11988 },
11989 {
11990 &quot;id&quot;:1,
11991 &quot;project&quot;:&quot;AsterixDB&quot;,
11992 &quot;address&quot;:{&quot;city&quot;:&quot;San Diego&quot;, &quot;state&quot;:&quot;CA&quot;},
11993 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
11994 }
11995);
11996</pre></div></div>
11997</li>
11998<li>
11999
12000<p>The expected result is:</p>
12001
12002<div>
12003<div>
12004<pre class="source">false
12005</pre></div></div>
12006</li>
12007</ul><!--
12008 ! Licensed to the Apache Software Foundation (ASF) under one
12009 ! or more contributor license agreements. See the NOTICE file
12010 ! distributed with this work for additional information
12011 ! regarding copyright ownership. The ASF licenses this file
12012 ! to you under the Apache License, Version 2.0 (the
12013 ! "License"); you may not use this file except in compliance
12014 ! with the License. You may obtain a copy of the License at
12015 !
12016 ! http://www.apache.org/licenses/LICENSE-2.0
12017 !
12018 ! Unless required by applicable law or agreed to in writing,
12019 ! software distributed under the License is distributed on an
12020 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12021 ! KIND, either express or implied. See the License for the
12022 ! specific language governing permissions and limitations
12023 ! under the License.
12024 !-->
12025</div></div>
12026<div class="section">
12027<h2><a name="Bitwise_Functions"></a><a name="BitwiseFunctions" id="BitwiseFunctions">Bitwise Functions</a></h2>
12028<p>All Bit/Binary functions can only operate on 64-bit signed integers.</p>
12029<p><b>Note:</b> All non-integer numbers and other data types result in null.</p>
12030<p><b>Note:</b> The query language uses two&#x2019;s complement representation.</p>
12031<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>
12032<p>(MSB) Bit 32 &#x2192; <tt>0000 0000 0000 0000 0000 0000 0000 0000</tt> &#x2190; Bit 1 (LSB)</p>
12033<div class="section">
12034<h3><a name="bitand"></a>bitand</h3>
12035<ul>
12036
12037<li>
12038
12039<p>Syntax:</p>
12040
12041<div>
12042<div>
12043<pre class="source">BITAND(int_value1, int_value2, ... , int_valueN)
12044</pre></div></div>
12045</li>
12046<li>
12047
12048<p>Returns the result of a bitwise AND operation performed on all input integer values.</p>
12049<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>
12050</li>
12051<li>
12052
12053<p>Arguments:</p>
12054<ul>
12055
12056<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
12057</ul>
12058</li>
12059<li>
12060
12061<p>Return Value:</p>
12062<ul>
12063
12064<li>An integer, representing the bitwise AND between all of the input integers.</li>
12065</ul>
12066</li>
12067<li>
12068
12069<p>Limitations:</p>
12070<ul>
12071
12072<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12073</ul>
12074</li>
12075<li>
12076
12077<p>Example 1:</p>
12078<p>Compare 3 (0011 in binary) and 6 (0110 in binary).</p>
12079
12080<div>
12081<div>
12082<pre class="source">{ &quot;BitAND&quot;: BITAND(3,6) };
12083</pre></div></div>
12084</li>
12085<li>
12086
12087<p>The expected result is:</p>
12088
12089<div>
12090<div>
12091<pre class="source">{ &quot;BitAND&quot;: 2 }
12092</pre></div></div>
12093
12094<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>
12095</li>
12096<li>
12097
12098<p>Example 2:</p>
12099<p>Compare 4.5 and 3 (0011 in binary).</p>
12100
12101<div>
12102<div>
12103<pre class="source">{ &quot;BitAND&quot;: BITAND(4.5,3) };
12104</pre></div></div>
12105</li>
12106<li>
12107
12108<p>The expected result is:</p>
12109
12110<div>
12111<div>
12112<pre class="source">{ &quot;BitAND&quot;: null }
12113</pre></div></div>
12114
12115<p>The result is null because 4.5 is not an integer.</p>
12116</li>
12117<li>
12118
12119<p>Example 3:</p>
12120<p>Compare 4.0 (0100 in binary) and 3 (0011 in binary).</p>
12121
12122<div>
12123<div>
12124<pre class="source">{ &quot;BitAND&quot;: BITAND(4.0,3) };
12125</pre></div></div>
12126</li>
12127<li>
12128
12129<p>The expected result is:</p>
12130
12131<div>
12132<div>
12133<pre class="source">{ &quot;BitAND&quot;: 0 }
12134</pre></div></div>
12135
12136<p>This results in 0 (zero) because 4.0 (0100) and 3 (0011) do not share any bits that are both 1.</p>
12137</li>
12138<li>
12139
12140<p>Example 4:</p>
12141<p>Compare 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
12142
12143<div>
12144<div>
12145<pre class="source">{ &quot;BitAND&quot;: BITAND(3,6,15) };
12146</pre></div></div>
12147</li>
12148<li>
12149
12150<p>The expected result is:</p>
12151
12152<div>
12153<div>
12154<pre class="source">{ &quot;BitAND&quot;: 2 }
12155</pre></div></div>
12156
12157<p>This results in 2 (0010 in binary) because only the 2nd bit from the right is 1 in all three numbers.</p>
12158</li>
12159</ul></div>
12160<div class="section">
12161<h3><a name="bitclear"></a>bitclear</h3>
12162<ul>
12163
12164<li>
12165
12166<p>Syntax:</p>
12167
12168<div>
12169<div>
12170<pre class="source">BITCLEAR(int_value, positions)
12171</pre></div></div>
12172</li>
12173<li>
12174
12175<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>
12176<p><b>Note:</b> Specifying a negative or zero bit position makes the function return a null.</p>
12177</li>
12178<li>
12179
12180<p>Arguments:</p>
12181<ul>
12182
12183<li>
12184
12185<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>
12186</li>
12187<li>
12188
12189<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be cleared.</p>
12190</li>
12191</ul>
12192</li>
12193<li>
12194
12195<p>Return Value:</p>
12196<ul>
12197
12198<li>An integer, representing the result after clearing the bit or bits specified.</li>
12199</ul>
12200</li>
12201<li>
12202
12203<p>Limitations:</p>
12204<ul>
12205
12206<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12207</ul>
12208</li>
12209<li>
12210
12211<p>Example 1:</p>
12212<p>Clear bit 1 from 6 (0110 in binary).</p>
12213
12214<div>
12215<div>
12216<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(6,1) };
12217</pre></div></div>
12218</li>
12219<li>
12220
12221<p>The expected result is:</p>
12222
12223<div>
12224<div>
12225<pre class="source">{ &quot;BitCLEAR&quot;: 6 }
12226</pre></div></div>
12227
12228<p>This results in 6 (011<b>0</b> in binary) because bit 1 was already zero.</p>
12229</li>
12230<li>
12231
12232<p>Example 2:</p>
12233<p>Clear bits 1 and 2 from 6 (01<b>10</b> in binary).</p>
12234
12235<div>
12236<div>
12237<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(6,[1,2]) };
12238</pre></div></div>
12239</li>
12240<li>
12241
12242<p>The expected result is:</p>
12243
12244<div>
12245<div>
12246<pre class="source">{ &quot;BitCLEAR&quot;: 4 }
12247</pre></div></div>
12248
12249<p>This results in 4 (01<b>0</b>0 in binary) because bit 2 changed to zero.</p>
12250</li>
12251<li>
12252
12253<p>Example 3:</p>
12254<p>Clear bits 1, 2, 4, and 5 from 31 (0<b>11</b>1<b>11</b> in binary).</p>
12255
12256<div>
12257<div>
12258<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(31,[1,2,4,5]) };
12259</pre></div></div>
12260</li>
12261<li>
12262
12263<p>The expected result is:</p>
12264
12265<div>
12266<div>
12267<pre class="source">{ &quot;BitCLEAR&quot;: 4 }
12268</pre></div></div>
12269
12270<p>This results in 4 (0<b>00</b>1<b>00</b>) because bits 1, 2, 4, and 5 changed to zero.</p>
12271</li>
12272</ul></div>
12273<div class="section">
12274<h3><a name="bitnot"></a>bitnot</h3>
12275<ul>
12276
12277<li>
12278
12279<p>Syntax:</p>
12280
12281<div>
12282<div>
12283<pre class="source">BITNOT(int_value)
12284</pre></div></div>
12285</li>
12286<li>
12287
12288<p>Returns the results of a bitwise logical NOT operation performed on an integer value.</p>
12289<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>
12290<p><b>Note:</b> All bits of the integer will be altered by this operation.</p>
12291</li>
12292<li>
12293
12294<p>Arguments:</p>
12295<ul>
12296
12297<li><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bits to reverse.</li>
12298</ul>
12299</li>
12300<li>
12301
12302<p>Return Value:</p>
12303<ul>
12304
12305<li>An integer, representing the result after performing the logical NOT operation.</li>
12306</ul>
12307</li>
12308<li>
12309
12310<p>Limitations:</p>
12311<ul>
12312
12313<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12314</ul>
12315</li>
12316<li>
12317
12318<p>Example 1:</p>
12319<p>Perform the NOT operation on 3 (0000 0000 0000 0000 0000 0000 0000 0011 in binary).</p>
12320
12321<div>
12322<div>
12323<pre class="source">{ &quot;BitNOT&quot;: BITNOT(3) };
12324</pre></div></div>
12325</li>
12326<li>
12327
12328<p>The expected result is:</p>
12329
12330<div>
12331<div>
12332<pre class="source">{ &quot;BitNOT&quot;: -4 }
12333</pre></div></div>
12334
12335<p>This results in -4 (<b>1111 1111 1111 1111 1111 1111 1111 1100</b> in binary) because all bits changed.</p>
12336</li>
12337</ul></div>
12338<div class="section">
12339<h3><a name="bitor"></a>bitor</h3>
12340<ul>
12341
12342<li>
12343
12344<p>Syntax:</p>
12345
12346<div>
12347<div>
12348<pre class="source">BITOR(int_value1, int_value2, ... , int_valueN)
12349</pre></div></div>
12350</li>
12351<li>
12352
12353<p>Returns the result of a bitwise inclusive OR operation performed on all input integer values.</p>
12354<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>
12355</li>
12356<li>
12357
12358<p>Arguments:</p>
12359<ul>
12360
12361<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
12362</ul>
12363</li>
12364<li>
12365
12366<p>Return Value:</p>
12367<ul>
12368
12369<li>An integer, representing the bitwise OR between all of the input integers.</li>
12370</ul>
12371</li>
12372<li>
12373
12374<p>Limitations:</p>
12375<ul>
12376
12377<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12378</ul>
12379</li>
12380<li>
12381
12382<p>Example 1:</p>
12383<p>Perform OR on 3 (0011 in binary) and 6 (0110 in binary).</p>
12384
12385<div>
12386<div>
12387<pre class="source">{ &quot;BitOR&quot;: BITOR(3,6) };
12388</pre></div></div>
12389</li>
12390<li>
12391
12392<p>The expected result is:</p>
12393
12394<div>
12395<div>
12396<pre class="source">{ &quot;BitOR&quot;: 7 }
12397</pre></div></div>
12398
12399<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>
12400</li>
12401<li>
12402
12403<p>Example 2:</p>
12404<p>Perform OR on 3 (0011 in binary) and -4 (1000 0000 0000 &#x2026; 0000 1100 in binary).</p>
12405
12406<div>
12407<div>
12408<pre class="source">{ &quot;BitOR&quot;: BITOR(3,-4) };
12409</pre></div></div>
12410</li>
12411<li>
12412
12413<p>The expected result is:</p>
12414
12415<div>
12416<div>
12417<pre class="source">{ &quot;BitOR&quot;: -1 }
12418</pre></div></div>
12419
12420<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>
12421</li>
12422<li>
12423
12424<p>Example 3:</p>
12425<p>Perform OR on 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
12426
12427<div>
12428<div>
12429<pre class="source">{ &quot;BitOR&quot;: BITOR(3,6,15) };
12430</pre></div></div>
12431</li>
12432<li>
12433
12434<p>The expected result is:</p>
12435
12436<div>
12437<div>
12438<pre class="source">{ &quot;BitOR&quot;: 15 }
12439</pre></div></div>
12440
12441<p>This results in 15 (1111 in binary) because there is at least one 1 in each of the four rightmost bits.</p>
12442</li>
12443</ul></div>
12444<div class="section">
12445<h3><a name="bitset"></a>bitset</h3>
12446<ul>
12447
12448<li>
12449
12450<p>Syntax:</p>
12451
12452<div>
12453<div>
12454<pre class="source">BITSET(int_value, positions)
12455</pre></div></div>
12456</li>
12457<li>
12458
12459<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>
12460<p><b>Note:</b> Specifying a negative or zero position makes the function return a null.</p>
12461</li>
12462<li>
12463
12464<p>Arguments:</p>
12465<ul>
12466
12467<li>
12468
12469<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>
12470</li>
12471<li>
12472
12473<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be set.</p>
12474</li>
12475</ul>
12476</li>
12477<li>
12478
12479<p>Return Value:</p>
12480<ul>
12481
12482<li>An integer, representing the result after setting the bit or bits specified. If the bit is already set, then it stays set.</li>
12483</ul>
12484</li>
12485<li>
12486
12487<p>Limitations:</p>
12488<ul>
12489
12490<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12491</ul>
12492</li>
12493<li>
12494
12495<p>Example 1:</p>
12496<p>Set bit 1 in the value 6 (011<b>0</b> in binary).</p>
12497
12498<div>
12499<div>
12500<pre class="source">{ &quot;BitSET&quot;: BITSET(6,1) };
12501</pre></div></div>
12502</li>
12503<li>
12504
12505<p>The expected result is:</p>
12506
12507<div>
12508<div>
12509<pre class="source">{ &quot;BitSET&quot;: 7 }
12510</pre></div></div>
12511
12512<p>This results in 7 (011<b>1</b> in binary) because bit 1 changed to 1.</p>
12513</li>
12514<li>
12515
12516<p>Example 2:</p>
12517<p>Set bits 1 and 2 in the value 6 (01<b>10</b> in binary).</p>
12518
12519<div>
12520<div>
12521<pre class="source">{ &quot;BitSET&quot;: BITSET(6,[1,2]) };
12522</pre></div></div>
12523</li>
12524<li>
12525
12526<p>The expected result is:</p>
12527
12528<div>
12529<div>
12530<pre class="source">{ &quot;BitSET&quot;: 7 }
12531</pre></div></div>
12532
12533<p>This also results in 7 (01<b>11</b> in binary) because bit 1 changed while bit 2 remained the same.</p>
12534</li>
12535<li>
12536
12537<p>Example 3:</p>
12538<p>Set bits 1 and 4 in the value 6 (<b>0</b>11<b>0</b> in binary).</p>
12539
12540<div>
12541<div>
12542<pre class="source">{ &quot;BitSET&quot;: BITSET(6,[1,4]) };
12543</pre></div></div>
12544</li>
12545<li>
12546
12547<p>The expected result is:</p>
12548
12549<div>
12550<div>
12551<pre class="source">{ &quot;BitSET&quot;: 15 }
12552</pre></div></div>
12553
12554<p>This results in 15 (<b>1</b>11<b>1</b> in binary) because bit 1 and 4 changed to ones.</p>
12555</li>
12556</ul></div>
12557<div class="section">
12558<h3><a name="bitshift"></a>bitshift</h3>
12559<ul>
12560
12561<li>
12562
12563<p>Syntax:</p>
12564
12565<div>
12566<div>
12567<pre class="source">BITSHIFT(int_value, shift_amount[, rotate])
12568</pre></div></div>
12569</li>
12570<li>
12571
12572<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>
12573</li>
12574<li>
12575
12576<p>Arguments:</p>
12577<ul>
12578
12579<li>
12580
12581<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>
12582</li>
12583<li>
12584
12585<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>
12586<ul>
12587
12588<li>
12589
12590<p>A positive (+) number means this is a LEFT shift.</p>
12591</li>
12592<li>
12593
12594<p>A negative (-) number means this is a RIGHT shift.</p>
12595</li>
12596</ul>
12597</li>
12598<li>
12599
12600<p><tt>rotate</tt>: (Optional) A boolean, or any valid expression which evaluates to a boolean, where:</p>
12601<ul>
12602
12603<li>
12604
12605<p>FALSE means this is a LOGICAL shift, where bits shifted off the end of a value are considered lost.</p>
12606</li>
12607<li>
12608
12609<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>
12610</li>
12611</ul>
12612<p>If omitted, the default is FALSE.</p>
12613</li>
12614</ul>
12615<p>For comparison, see the below table.</p>
12616<table border="0" class="table table-striped">
12617<thead>
12618
12619<tr class="a">
12620<th> Input </th>
12621<th> Shift </th>
12622<th> Result of Logical Shift (Rotate FALSE) </th>
12623<th> Result of Circular Shift (Rotate TRUE) </th></tr>
12624</thead><tbody>
12625
12626<tr class="b">
12627<td> 6 (0000 0110) </td>
12628<td> 4 </td>
12629<td> 96 (0110 0000) </td>
12630<td> 96 (0110 0000) </td></tr>
12631<tr class="a">
12632<td> 6 (0000 0110) </td>
12633<td> 3 </td>
12634<td> 48 (0011 0000) </td>
12635<td> 48 (0011 0000) </td></tr>
12636<tr class="b">
12637<td> 6 (0000 0110) </td>
12638<td> 2 </td>
12639<td> 24 (0001 1000) </td>
12640<td> 24 (0001 1000) </td></tr>
12641<tr class="a">
12642<td> 6 (0000 0110) </td>
12643<td> 1 </td>
12644<td> 12 (0000 1100) </td>
12645<td> 12 (0000 1100) </td></tr>
12646<tr class="b">
12647<td> <b>6 (0000 0110)</b> </td>
12648<td> <b>0</b> </td>
12649<td> <b>6 (0000 0110)</b> </td>
12650<td> <b>6 (0000 0110)</b> </td></tr>
12651<tr class="a">
12652<td> 6 (0000 0110) </td>
12653<td> -1 </td>
12654<td> 3 (0000 0011) </td>
12655<td> 3 (0000 0011) </td></tr>
12656<tr class="b">
12657<td> 6 (0000 0110) </td>
12658<td> -2 </td>
12659<td> 1 (0000 0001) </td>
12660<td> -9223372036854775807 (1000 0000 &#x2026; 0000 0001) </td></tr>
12661<tr class="a">
12662<td> 6 (0000 0110) </td>
12663<td> -3 </td>
12664<td> 0 (0000 0000) </td>
12665<td> -4611686018427387904 (1100 0000 &#x2026; 0000 0000) </td></tr>
12666<tr class="b">
12667<td> 6 (0000 0110) </td>
12668<td> -4 </td>
12669<td> 0 (0000 0000) </td>
12670<td> 6917529027641081856 (0110 0000 &#x2026; 0000 0000) </td></tr>
12671</tbody>
12672</table>
12673</li>
12674<li>
12675
12676<p>Return Value:</p>
12677<ul>
12678
12679<li>An integer, representing the result of either a logical or circular shift of the given integer.</li>
12680</ul>
12681</li>
12682<li>
12683
12684<p>Limitations:</p>
12685<ul>
12686
12687<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12688</ul>
12689</li>
12690<li>
12691
12692<p>Example 1:</p>
12693<p>Logical left shift of the number 6 (0110 in binary) by one bit.</p>
12694
12695<div>
12696<div>
12697<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,1,FALSE) };
12698</pre></div></div>
12699</li>
12700<li>
12701
12702<p>The expected result is:</p>
12703
12704<div>
12705<div>
12706<pre class="source">{ &quot;BitSHIFT&quot;: 12 }
12707</pre></div></div>
12708
12709<p>This results in 12 (1100 in binary) because the 1-bits moved from positions 2 and 3 to positions 3 and 4.</p>
12710</li>
12711<li>
12712
12713<p>Example 2:</p>
12714<p>Logical right shift of the number 6 (0110 in binary) by two bits.</p>
12715
12716<div>
12717<div>
12718<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,-2) };
12719</pre></div></div>
12720</li>
12721<li>
12722
12723<p>The expected result is:</p>
12724
12725<div>
12726<div>
12727<pre class="source">{ &quot;BitSHIFT&quot;: 1 }
12728</pre></div></div>
12729
12730<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>
12731</li>
12732<li>
12733
12734<p>Example 2b:</p>
12735<p>Circular right shift of the number 6 (0110 in binary) by two bits.</p>
12736
12737<div>
12738<div>
12739<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,-2,TRUE) };
12740</pre></div></div>
12741</li>
12742<li>
12743
12744<p>The expected result is:</p>
12745
12746<div>
12747<div>
12748<pre class="source">{ &quot;BitSHIFT&quot;: -9223372036854775807 }
12749</pre></div></div>
12750
12751<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>
12752</li>
12753<li>
12754
12755<p>Example 3:</p>
12756<p>Circular left shift of the number 524288 (1000 0000 0000 0000 0000 in binary) by 45 bits.</p>
12757
12758<div>
12759<div>
12760<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(524288,45,TRUE) };
12761</pre></div></div>
12762</li>
12763<li>
12764
12765<p>The expected result is:</p>
12766
12767<div>
12768<div>
12769<pre class="source">{ &quot;BitSHIFT&quot;: 1 }
12770</pre></div></div>
12771
12772<p>This results in 1 because the 1-bit wrapped left, around to the Least Significant Digit position.</p>
12773</li>
12774</ul></div>
12775<div class="section">
12776<h3><a name="bittest"></a>bittest</h3>
12777<ul>
12778
12779<li>
12780
12781<p>Syntax:</p>
12782
12783<div>
12784<div>
12785<pre class="source">BITTEST(int_value, positions [, all_set])
12786</pre></div></div>
12787</li>
12788<li>
12789
12790<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>
12791<p><b>Note:</b> Specifying a negative or zero bit position will result in null being returned.</p>
12792</li>
12793<li>
12794
12795<p>Arguments:</p>
12796<ul>
12797
12798<li>
12799
12800<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>
12801</li>
12802<li>
12803
12804<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be tested.</p>
12805</li>
12806<li>
12807
12808<p><tt>all_set</tt>: (Optional) A boolean, or any valid expression which evaluates to a boolean.</p>
12809<ul>
12810
12811<li>
12812
12813<p>When <tt>all_set</tt> is FALSE, then it returns TRUE even if one bit in one of the positions is set.</p>
12814</li>
12815<li>
12816
12817<p>When <tt>all_set</tt> is TRUE, then it returns TRUE only if all input positions are set.</p>
12818</li>
12819</ul>
12820<p>If omitted, the default is FALSE.</p>
12821</li>
12822</ul>
12823</li>
12824<li>
12825
12826<p>Return Value:</p>
12827<ul>
12828
12829<li>A boolean, that follows the below table:
12830<table border="0" class="table table-striped">
12831<thead>
12832
12833<tr class="a">
12834<th> <tt>int_value</tt> </th>
12835<th> <tt>all_set</tt> </th>
12836<th> Return Value </th></tr>
12837</thead><tbody>
12838
12839<tr class="b">
12840<td> <i>all</i> specified bits are TRUE </td>
12841<td> FALSE </td>
12842<td> TRUE </td></tr>
12843<tr class="a">
12844<td> <i>all</i> specified bits are TRUE </td>
12845<td> TRUE </td>
12846<td> TRUE </td></tr>
12847<tr class="b">
12848<td> <i>some</i> specified bits are TRUE </td>
12849<td> FALSE </td>
12850<td> TRUE </td></tr>
12851<tr class="a">
12852<td> <i>some</i> specified bits are TRUE </td>
12853<td> TRUE </td>
12854<td> FALSE </td></tr>
12855</tbody>
12856</table>
12857</li>
12858</ul>
12859</li>
12860<li>
12861
12862<p>Limitations:</p>
12863<ul>
12864
12865<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12866</ul>
12867</li>
12868<li>
12869
12870<p>Example 1:</p>
12871<p>In the number 6 (0110 in binary), is bit 1 set?</p>
12872
12873<div>
12874<div>
12875<pre class="source">{ &quot;IsBitSET&quot;: ISBITSET(6,1) };
12876</pre></div></div>
12877</li>
12878<li>
12879
12880<p>The expected result is:</p>
12881
12882<div>
12883<div>
12884<pre class="source">{ &quot;IsBitSET&quot;: false }
12885</pre></div></div>
12886
12887<p>This returns FALSE because bit 1 of 6 (011<b>0</b> in binary) is not set to 1.</p>
12888</li>
12889<li>
12890
12891<p>Example 2:</p>
12892<p>In the number 1, is either bit 1 or bit 2 set?</p>
12893
12894<div>
12895<div>
12896<pre class="source">{ &quot;BitTEST&quot;: BITTEST(1,[1,2],FALSE) };
12897</pre></div></div>
12898</li>
12899<li>
12900
12901<p>The expected result is:</p>
12902
12903<div>
12904<div>
12905<pre class="source">{ &quot;BitTEST&quot;: true }
12906</pre></div></div>
12907
12908<p>This returns TRUE because bit 1 of the number 1 (000<b>1</b> in binary) is set to 1.</p>
12909</li>
12910<li>
12911
12912<p>Example 3:</p>
12913<p>In the number 6 (0110 in binary), are both bits 2 and 3 set?</p>
12914
12915<div>
12916<div>
12917<pre class="source">{ &quot;IsBitSET&quot;: ISBITSET(6,[2,3],TRUE) };
12918</pre></div></div>
12919</li>
12920<li>
12921
12922<p>The expected result is:</p>
12923
12924<div>
12925<div>
12926<pre class="source">{ &quot;IsBitSET&quot;: true }
12927</pre></div></div>
12928
12929<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>
12930</li>
12931<li>
12932
12933<p>Example 4:</p>
12934<p>In the number 6 (0110 in binary), are all the bits in positions 1 through 3 set?</p>
12935
12936<div>
12937<div>
12938<pre class="source">{ &quot;BitTEST&quot;: BITTEST(6,[1,3],TRUE) };
12939</pre></div></div>
12940</li>
12941<li>
12942
12943<p>The expected result is:</p>
12944
12945<div>
12946<div>
12947<pre class="source">{ &quot;BitTEST&quot;: false }
12948</pre></div></div>
12949
12950<p>This returns FALSE because bit 1 in the number 6 (011<b>0</b> in binary) is set to 0 (zero).</p>
12951</li>
12952</ul>
12953<p>The function has an alias <tt>isbitset</tt>.</p></div>
12954<div class="section">
12955<h3><a name="bitxor"></a>bitxor</h3>
12956<ul>
12957
12958<li>
12959
12960<p>Syntax:</p>
12961
12962<div>
12963<div>
12964<pre class="source">BITXOR(int_value1, int_value2, ... , int_valueN)
12965</pre></div></div>
12966</li>
12967<li>
12968
12969<p>Returns the result of a bitwise Exclusive OR operation performed on two or more integer values.</p>
12970<p>The bitwise Exclusive OR operation compares each bit of <tt>int_value1</tt> to the corresponding bit of <tt>int_value2</tt>.</p>
12971<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>
12972<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>
12973<table border="0" class="table table-striped">
12974<thead>
12975
12976<tr class="a">
12977<th> Bit 1 </th>
12978<th> Bit 2 </th>
12979<th> XOR Result Bit </th></tr>
12980</thead><tbody>
12981
12982<tr class="b">
12983<td> 0 </td>
12984<td> 0 </td>
12985<td> 0 </td></tr>
12986<tr class="a">
12987<td> 0 </td>
12988<td> 1 </td>
12989<td> 1 </td></tr>
12990<tr class="b">
12991<td> 1 </td>
12992<td> 0 </td>
12993<td> 1 </td></tr>
12994<tr class="a">
12995<td> 1 </td>
12996<td> 1 </td>
12997<td> 0 </td></tr>
12998</tbody>
12999</table>
13000</li>
13001<li>
13002
13003<p>Arguments:</p>
13004<ul>
13005
13006<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
13007</ul>
13008</li>
13009<li>
13010
13011<p>Return Value:</p>
13012<ul>
13013
13014<li>An integer, representing the bitwise XOR between the input integers.</li>
13015</ul>
13016</li>
13017<li>
13018
13019<p>Limitations:</p>
13020<ul>
13021
13022<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
13023</ul>
13024</li>
13025<li>
13026
13027<p>Example 1:</p>
13028<p>Perform the XOR operation on 3 (0011 in binary) and 6 (0110 in binary).</p>
13029
13030<div>
13031<div>
13032<pre class="source">{ &quot;BitXOR&quot;: BITXOR(3,6) };
13033</pre></div></div>
13034</li>
13035<li>
13036
13037<p>The expected result is:</p>
13038
13039<div>
13040<div>
13041<pre class="source">{ &quot;BitXOR&quot;: 5 }
13042</pre></div></div>
13043
13044<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>
13045
13046<div>
13047<div>
13048<pre class="source">0011 (3)
130490110 (6)
13050====
130510101 (5)
13052</pre></div></div>
13053</li>
13054<li>
13055
13056<p>Example 2:</p>
13057<p>Perform the XOR operation on 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
13058
13059<div>
13060<div>
13061<pre class="source">{ &quot;BitXOR&quot;: BITXOR(3,6,15) };
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;BitXOR&quot;: 10 }
13071</pre></div></div>
13072
13073<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>
13074</li>
13075</ul><!--
13076 ! Licensed to the Apache Software Foundation (ASF) under one
13077 ! or more contributor license agreements. See the NOTICE file
13078 ! distributed with this work for additional information
13079 ! regarding copyright ownership. The ASF licenses this file
13080 ! to you under the Apache License, Version 2.0 (the
13081 ! "License"); you may not use this file except in compliance
13082 ! with the License. You may obtain a copy of the License at
13083 !
13084 ! http://www.apache.org/licenses/LICENSE-2.0
13085 !
13086 ! Unless required by applicable law or agreed to in writing,
13087 ! software distributed under the License is distributed on an
13088 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13089 ! KIND, either express or implied. See the License for the
13090 ! specific language governing permissions and limitations
13091 ! under the License.
13092 !-->
13093</div></div>
13094<div class="section">
13095<h2><a name="Window_Functions"></a><a name="WindowFunctions" id="WindowFunctions">Window Functions</a></h2>
13096<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>
13097<p>The tuples are not grouped into a single output tuple &#x2014; each tuple remains separate in the query output.</p>
13098<p>All window functions must be used with an OVER clause. Refer to <a href="manual.html#Over_clauses">OVER Clauses</a> for details.</p>
13099<p>Window functions cannot appear in the FROM clause clause or LIMIT clause.</p>
13100<p>The examples in this section use the <tt>GleambookMessages</tt> dataset, described in the section on <a href="manual.html#SELECT_statements">SELECT Statements</a>.</p>
13101<div class="section">
13102<h3><a name="cume_dist"></a>cume_dist</h3>
13103<ul>
13104
13105<li>
13106
13107<p>Syntax:</p>
13108
13109<div>
13110<div>
13111<pre class="source">CUME_DIST() OVER ([window-partition-clause] [window-order-clause])
13112</pre></div></div>
13113</li>
13114<li>
13115
13116<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>
13117<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>
13118</li>
13119<li>
13120
13121<p>Arguments:</p>
13122<ul>
13123
13124<li>None.</li>
13125</ul>
13126</li>
13127<li>
13128
13129<p>Clauses:</p>
13130<ul>
13131
13132<li>
13133
13134<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13135</li>
13136<li>
13137
13138<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13139</li>
13140</ul>
13141</li>
13142<li>
13143
13144<p>Return Value:</p>
13145<ul>
13146
13147<li>A number greater than 0 and less than or equal to 1. The higher the value, the higher the ranking.</li>
13148</ul>
13149</li>
13150<li>
13151
13152<p>Example:</p>
13153<p>For each author, find the cumulative distribution of all messages in order of message ID.</p>
13154
13155<div>
13156<div>
13157<pre class="source">SELECT m.messageId, m.authorId, CUME_DIST() OVER (
13158 PARTITION BY m.authorId
13159 ORDER BY m.messageId
13160) AS `rank`
13161FROM GleambookMessages AS m;
13162</pre></div></div>
13163</li>
13164<li>
13165
13166<p>The expected result is:</p>
13167
13168<div>
13169<div>
13170<pre class="source">[
13171 {
13172 &quot;rank&quot;: 0.2,
13173 &quot;messageId&quot;: 2,
13174 &quot;authorId&quot;: 1
13175 },
13176 {
13177 &quot;rank&quot;: 0.4,
13178 &quot;messageId&quot;: 4,
13179 &quot;authorId&quot;: 1
13180 },
13181 {
13182 &quot;rank&quot;: 0.6,
13183 &quot;messageId&quot;: 8,
13184 &quot;authorId&quot;: 1
13185 },
13186 {
13187 &quot;rank&quot;: 0.8,
13188 &quot;messageId&quot;: 10,
13189 &quot;authorId&quot;: 1
13190 },
13191 {
13192 &quot;rank&quot;: 1,
13193 &quot;messageId&quot;: 11,
13194 &quot;authorId&quot;: 1
13195 },
13196 {
13197 &quot;rank&quot;: 0.5,
13198 &quot;messageId&quot;: 3,
13199 &quot;authorId&quot;: 2
13200 },
13201 {
13202 &quot;rank&quot;: 1,
13203 &quot;messageId&quot;: 6,
13204 &quot;authorId&quot;: 2
13205 }
13206]
13207</pre></div></div>
13208</li>
13209</ul></div>
13210<div class="section">
13211<h3><a name="dense_rank"></a>dense_rank</h3>
13212<ul>
13213
13214<li>
13215
13216<p>Syntax:</p>
13217
13218<div>
13219<div>
13220<pre class="source">DENSE_RANK() OVER ([window-partition-clause] [window-order-clause])
13221</pre></div></div>
13222</li>
13223<li>
13224
13225<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>
13226<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>
13227<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 three tuples ranked 2, the next dense rank is 3.</p>
13228</li>
13229<li>
13230
13231<p>Arguments:</p>
13232<ul>
13233
13234<li>None.</li>
13235</ul>
13236</li>
13237<li>
13238
13239<p>Clauses:</p>
13240<ul>
13241
13242<li>
13243
13244<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13245</li>
13246<li>
13247
13248<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13249</li>
13250</ul>
13251</li>
13252<li>
13253
13254<p>Return Value:</p>
13255<ul>
13256
13257<li>An integer, greater than or equal to 1.</li>
13258</ul>
13259</li>
13260<li>
13261
13262<p>Example:</p>
13263<p>For each author, find the dense rank of all messages in order of location.</p>
13264
13265<div>
13266<div>
13267<pre class="source">SELECT m.authorId, m.messageId, m.senderLocation[1] as longitude,
13268DENSE_RANK() OVER (
13269 PARTITION BY m.authorId
13270 ORDER BY m.senderLocation[1]
13271) AS `rank`
13272FROM GleambookMessages AS m;
13273</pre></div></div>
13274</li>
13275<li>
13276
13277<p>The expected result is:</p>
13278
13279<div>
13280<div>
13281<pre class="source">[
13282 {
13283 &quot;rank&quot;: 1,
13284 &quot;authorId&quot;: 1,
13285 &quot;messageId&quot;: 10,
13286 &quot;longitude&quot;: 70.01
13287 },
13288 {
13289 &quot;rank&quot;: 2,
13290 &quot;authorId&quot;: 1,
13291 &quot;messageId&quot;: 11,
13292 &quot;longitude&quot;: 77.49
13293 },
13294 {
13295 &quot;rank&quot;: 3,
13296 &quot;authorId&quot;: 1,
13297 &quot;messageId&quot;: 2,
13298 &quot;longitude&quot;: 80.87
13299 },
13300 {
13301 &quot;rank&quot;: 3,
13302 &quot;authorId&quot;: 1,
13303 &quot;messageId&quot;: 8,
13304 &quot;longitude&quot;: 80.87
13305 },
13306 {
13307 &quot;rank&quot;: 4,
13308 &quot;authorId&quot;: 1,
13309 &quot;messageId&quot;: 4,
13310 &quot;longitude&quot;: 97.04
13311 },
13312 {
13313 &quot;rank&quot;: 1,
13314 &quot;authorId&quot;: 2,
13315 &quot;messageId&quot;: 6,
13316 &quot;longitude&quot;: 75.56
13317 },
13318 {
13319 &quot;rank&quot;: 2,
13320 &quot;authorId&quot;: 2,
13321 &quot;messageId&quot;: 3,
13322 &quot;longitude&quot;: 81.01
13323 }
13324]
13325</pre></div></div>
13326</li>
13327</ul></div>
13328<div class="section">
13329<h3><a name="first_value"></a>first_value</h3>
13330<ul>
13331
13332<li>
13333
13334<p>Syntax:</p>
13335
13336<div>
13337<div>
13338<pre class="source">FIRST_VALUE(expr) [nulls-treatment] OVER (window-definition)
13339</pre></div></div>
13340</li>
13341<li>
13342
13343<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>
13344</li>
13345<li>
13346
13347<p>Arguments:</p>
13348<ul>
13349
13350<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>
13351</ul>
13352</li>
13353<li>
13354
13355<p>Modifiers:</p>
13356<ul>
13357
13358<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the first value in the window frame.
13359<ul>
13360
13361<li>
13362
13363<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>
13364</li>
13365<li>
13366
13367<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>
13368</li>
13369</ul>
13370<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13371</li>
13372</ul>
13373</li>
13374<li>
13375
13376<p>Clauses:</p>
13377<ul>
13378
13379<li>
13380
13381<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13382</li>
13383<li>
13384
13385<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13386</li>
13387<li>
13388
13389<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
13390</li>
13391</ul>
13392</li>
13393<li>
13394
13395<p>Return Value:</p>
13396<ul>
13397
13398<li>
13399
13400<p>The specified value from the first tuple. The order of the tuples is determined by the window order clause.</p>
13401</li>
13402<li>
13403
13404<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>
13405</li>
13406<li>
13407
13408<p>In the following cases, this function may return unpredictable results.</p>
13409<ul>
13410
13411<li>
13412
13413<p>If the window order clause is omitted.</p>
13414</li>
13415<li>
13416
13417<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
13418</li>
13419</ul>
13420</li>
13421<li>
13422
13423<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>
13424</li>
13425<li>
13426
13427<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>
13428</li>
13429</ul>
13430</li>
13431<li>
13432
13433<p>Example:</p>
13434<p>For each author, show the length of each message, including the length of the shortest message from that author.</p>
13435
13436<div>
13437<div>
13438<pre class="source">SELECT m.authorId, m.messageId,
13439LENGTH(m.message) AS message_length,
13440FIRST_VALUE(LENGTH(m.message)) OVER (
13441 PARTITION BY m.authorId
13442 ORDER BY LENGTH(m.message)
13443) AS shortest_message
13444FROM GleambookMessages AS m;
13445</pre></div></div>
13446</li>
13447<li>
13448
13449<p>The expected result is:</p>
13450
13451<div>
13452<div>
13453<pre class="source">[
13454 {
13455 &quot;message_length&quot;: 31,
13456 &quot;shortest_message&quot;: 31,
13457 &quot;authorId&quot;: 1,
13458 &quot;messageId&quot;: 8
13459 },
13460 {
13461 &quot;message_length&quot;: 39,
13462 &quot;shortest_message&quot;: 31,
13463 &quot;authorId&quot;: 1,
13464 &quot;messageId&quot;: 11
13465 },
13466 {
13467 &quot;message_length&quot;: 44,
13468 &quot;shortest_message&quot;: 31,
13469 &quot;authorId&quot;: 1,
13470 &quot;messageId&quot;: 4
13471 },
13472 {
13473 &quot;message_length&quot;: 45,
13474 &quot;shortest_message&quot;: 31,
13475 &quot;authorId&quot;: 1,
13476 &quot;messageId&quot;: 2
13477 },
13478 {
13479 &quot;message_length&quot;: 51,
13480 &quot;shortest_message&quot;: 31,
13481 &quot;authorId&quot;: 1,
13482 &quot;messageId&quot;: 10
13483 },
13484 {
13485 &quot;message_length&quot;: 35,
13486 &quot;shortest_message&quot;: 35,
13487 &quot;authorId&quot;: 2,
13488 &quot;messageId&quot;: 3
13489 },
13490 {
13491 &quot;message_length&quot;: 44,
13492 &quot;shortest_message&quot;: 35,
13493 &quot;authorId&quot;: 2,
13494 &quot;messageId&quot;: 6
13495 }
13496]
13497</pre></div></div>
13498</li>
13499</ul></div>
13500<div class="section">
13501<h3><a name="lag"></a>lag</h3>
13502<ul>
13503
13504<li>
13505
13506<p>Syntax:</p>
13507
13508<div>
13509<div>
13510<pre class="source">LAG(expr[, offset[, default]]) [nulls-treatment] OVER ([window-partition-clause] [window-order-clause])
13511</pre></div></div>
13512</li>
13513<li>
13514
13515<p>Returns the value from a tuple at a given offset prior to the current tuple position.</p>
13516<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>
13517</li>
13518<li>
13519
13520<p>Arguments:</p>
13521<ul>
13522
13523<li>
13524
13525<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>
13526</li>
13527<li>
13528
13529<p><tt>offset</tt>: (Optional) A positive integer. If omitted, the default is 1.</p>
13530</li>
13531<li>
13532
13533<p><tt>default</tt>: (Optional) The value to return when the offset goes out of partition scope. If omitted, the default is NULL.</p>
13534</li>
13535</ul>
13536</li>
13537<li>
13538
13539<p>Modifiers:</p>
13540<ul>
13541
13542<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window partition.
13543<ul>
13544
13545<li>
13546
13547<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>
13548</li>
13549<li>
13550
13551<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>
13552</li>
13553</ul>
13554<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13555</li>
13556</ul>
13557</li>
13558<li>
13559
13560<p>Clauses:</p>
13561<ul>
13562
13563<li>
13564
13565<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13566</li>
13567<li>
13568
13569<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13570</li>
13571</ul>
13572</li>
13573<li>
13574
13575<p>Return Value:</p>
13576<ul>
13577
13578<li>
13579
13580<p>The specified value from the offset tuple.</p>
13581</li>
13582<li>
13583
13584<p>If the offset tuple is out of partition scope, it returns the default value, or NULL if no default is specified.</p>
13585</li>
13586</ul>
13587</li>
13588<li>
13589
13590<p>Example:</p>
13591<p>For each author, show the length of each message, including the length of the next-shortest message.</p>
13592
13593<div>
13594<div>
13595<pre class="source">SELECT m.authorId, m.messageId,
13596LENGTH(m.message) AS message_length,
13597LAG(LENGTH(m.message), 1, &quot;No shorter message&quot;) OVER (
13598 PARTITION BY m.authorId
13599 ORDER BY LENGTH(m.message)
13600) AS next_shortest_message
13601FROM GleambookMessages AS m;
13602</pre></div></div>
13603</li>
13604<li>
13605
13606<p>The expected result is:</p>
13607
13608<div>
13609<div>
13610<pre class="source">[
13611 {
13612 &quot;message_length&quot;: 31,
13613 &quot;authorId&quot;: 1,
13614 &quot;messageId&quot;: 8,
13615 &quot;next_shortest_message&quot;: &quot;No shorter message&quot;
13616 },
13617 {
13618 &quot;message_length&quot;: 39,
13619 &quot;authorId&quot;: 1,
13620 &quot;messageId&quot;: 11,
13621 &quot;next_shortest_message&quot;: 31
13622 },
13623 {
13624 &quot;message_length&quot;: 44,
13625 &quot;authorId&quot;: 1,
13626 &quot;messageId&quot;: 4,
13627 &quot;next_shortest_message&quot;: 39
13628 },
13629 {
13630 &quot;message_length&quot;: 45,
13631 &quot;authorId&quot;: 1,
13632 &quot;messageId&quot;: 2,
13633 &quot;next_shortest_message&quot;: 44
13634 },
13635 {
13636 &quot;message_length&quot;: 51,
13637 &quot;authorId&quot;: 1,
13638 &quot;messageId&quot;: 10,
13639 &quot;next_shortest_message&quot;: 45
13640 },
13641 {
13642 &quot;message_length&quot;: 35,
13643 &quot;authorId&quot;: 2,
13644 &quot;messageId&quot;: 3,
13645 &quot;next_shortest_message&quot;: &quot;No shorter message&quot;
13646 },
13647 {
13648 &quot;message_length&quot;: 44,
13649 &quot;authorId&quot;: 2,
13650 &quot;messageId&quot;: 6,
13651 &quot;next_shortest_message&quot;: 35
13652 }
13653]
13654</pre></div></div>
13655</li>
13656</ul></div>
13657<div class="section">
13658<h3><a name="last_value"></a>last_value</h3>
13659<ul>
13660
13661<li>
13662
13663<p>Syntax:</p>
13664
13665<div>
13666<div>
13667<pre class="source">LAST_VALUE(expr) [nulls-treatment] OVER (window-definition)
13668</pre></div></div>
13669</li>
13670<li>
13671
13672<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>
13673</li>
13674<li>
13675
13676<p>Arguments:</p>
13677<ul>
13678
13679<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>
13680</ul>
13681</li>
13682<li>
13683
13684<p>Modifiers:</p>
13685<ul>
13686
13687<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the last tuple in the window frame.
13688<ul>
13689
13690<li>
13691
13692<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>
13693</li>
13694<li>
13695
13696<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>
13697</li>
13698</ul>
13699<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13700</li>
13701</ul>
13702</li>
13703<li>
13704
13705<p>Clauses:</p>
13706<ul>
13707
13708<li>
13709
13710<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13711</li>
13712<li>
13713
13714<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13715</li>
13716<li>
13717
13718<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
13719</li>
13720</ul>
13721</li>
13722<li>
13723
13724<p>Return Value:</p>
13725<ul>
13726
13727<li>
13728
13729<p>The specified value from the last tuple. The order of the tuples is determined by the window order clause.</p>
13730</li>
13731<li>
13732
13733<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>
13734</li>
13735<li>
13736
13737<p>In the following cases, this function may return unpredictable results.</p>
13738<ul>
13739
13740<li>
13741
13742<p>If the window order clause is omitted.</p>
13743</li>
13744<li>
13745
13746<p>If the window frame clause is omitted.</p>
13747</li>
13748<li>
13749
13750<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
13751</li>
13752</ul>
13753</li>
13754<li>
13755
13756<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>
13757</li>
13758<li>
13759
13760<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>
13761</li>
13762</ul>
13763</li>
13764<li>
13765
13766<p>Example:</p>
13767<p>For each author, show the length of each message, including the length of the longest message from that author.</p>
13768
13769<div>
13770<div>
13771<pre class="source">SELECT m.authorId, m.messageId,
13772LENGTH(m.message) AS message_length,
13773LAST_VALUE(LENGTH(m.message)) OVER (
13774 PARTITION BY m.authorId
13775 ORDER BY LENGTH(m.message)
13776 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
13777) AS longest_message
13778FROM GleambookMessages AS m;
13779</pre></div></div>
13780</li>
13781<li>
13782
13783<p>The expected result is:</p>
13784
13785<div>
13786<div>
13787<pre class="source">[
13788 {
13789 &quot;message_length&quot;: 31,
13790 &quot;longest_message&quot;: 51,
13791 &quot;authorId&quot;: 1,
13792 &quot;messageId&quot;: 8
13793 },
13794 {
13795 &quot;message_length&quot;: 39,
13796 &quot;longest_message&quot;: 51,
13797 &quot;authorId&quot;: 1,
13798 &quot;messageId&quot;: 11
13799 },
13800 {
13801 &quot;message_length&quot;: 44,
13802 &quot;longest_message&quot;: 51,
13803 &quot;authorId&quot;: 1,
13804 &quot;messageId&quot;: 4
13805 },
13806 {
13807 &quot;message_length&quot;: 45,
13808 &quot;longest_message&quot;: 51,
13809 &quot;authorId&quot;: 1,
13810 &quot;messageId&quot;: 2
13811 },
13812 {
13813 &quot;message_length&quot;: 51,
13814 &quot;longest_message&quot;: 51,
13815 &quot;authorId&quot;: 1,
13816 &quot;messageId&quot;: 10
13817 },
13818 {
13819 &quot;message_length&quot;: 35,
13820 &quot;longest_message&quot;: 44,
13821 &quot;authorId&quot;: 2,
13822 &quot;messageId&quot;: 3
13823 },
13824 {
13825 &quot;message_length&quot;: 44,
13826 &quot;longest_message&quot;: 44,
13827 &quot;authorId&quot;: 2,
13828 &quot;messageId&quot;: 6
13829 }
13830]
13831</pre></div></div>
13832
13833<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 longest message would always be the same as the current message.</p>
13834</li>
13835</ul></div>
13836<div class="section">
13837<h3><a name="lead"></a>lead</h3>
13838<ul>
13839
13840<li>
13841
13842<p>Syntax:</p>
13843
13844<div>
13845<div>
13846<pre class="source">LEAD(expr[, offset[, default]]) [nulls-treatment] OVER ([window-partition-clause] [window-order-clause])
13847</pre></div></div>
13848</li>
13849<li>
13850
13851<p>Returns the value from a tuple at a given offset ahead of the current tuple position.</p>
13852<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>
13853</li>
13854<li>
13855
13856<p>Arguments:</p>
13857<ul>
13858
13859<li>
13860
13861<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>
13862</li>
13863<li>
13864
13865<p><tt>offset</tt>: (Optional) A positive integer. If omitted, the default is 1.</p>
13866</li>
13867<li>
13868
13869<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>
13870</li>
13871</ul>
13872</li>
13873<li>
13874
13875<p>Modifiers:</p>
13876<ul>
13877
13878<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window partition.
13879<ul>
13880
13881<li>
13882
13883<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>
13884</li>
13885<li>
13886
13887<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>
13888</li>
13889</ul>
13890<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13891</li>
13892</ul>
13893</li>
13894<li>
13895
13896<p>Clauses:</p>
13897<ul>
13898
13899<li>
13900
13901<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13902</li>
13903<li>
13904
13905<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13906</li>
13907</ul>
13908</li>
13909<li>
13910
13911<p>Return Value:</p>
13912<ul>
13913
13914<li>
13915
13916<p>The specified value from the offset tuple.</p>
13917</li>
13918<li>
13919
13920<p>If the offset tuple is out of partition scope, it returns the default value, or NULL if no default is specified.</p>
13921</li>
13922</ul>
13923</li>
13924<li>
13925
13926<p>Example:</p>
13927<p>For each author, show the length of each message, including the length of the next-longest message.</p>
13928
13929<div>
13930<div>
13931<pre class="source">SELECT m.authorId, m.messageId,
13932LENGTH(m.message) AS message_length,
13933LEAD(LENGTH(m.message), 1, &quot;No longer message&quot;) OVER (
13934 PARTITION BY m.authorId
13935 ORDER BY LENGTH(m.message)
13936) AS next_longest_message
13937FROM GleambookMessages AS m;
13938</pre></div></div>
13939</li>
13940<li>
13941
13942<p>The expected result is:</p>
13943
13944<div>
13945<div>
13946<pre class="source">[
13947 {
13948 &quot;message_length&quot;: 31,
13949 &quot;authorId&quot;: 1,
13950 &quot;messageId&quot;: 8,
13951 &quot;next_longest_message&quot;: 39
13952 },
13953 {
13954 &quot;message_length&quot;: 39,
13955 &quot;authorId&quot;: 1,
13956 &quot;messageId&quot;: 11,
13957 &quot;next_longest_message&quot;: 44
13958 },
13959 {
13960 &quot;message_length&quot;: 44,
13961 &quot;authorId&quot;: 1,
13962 &quot;messageId&quot;: 4,
13963 &quot;next_longest_message&quot;: 45
13964 },
13965 {
13966 &quot;message_length&quot;: 45,
13967 &quot;authorId&quot;: 1,
13968 &quot;messageId&quot;: 2,
13969 &quot;next_longest_message&quot;: 51
13970 },
13971 {
13972 &quot;message_length&quot;: 51,
13973 &quot;authorId&quot;: 1,
13974 &quot;messageId&quot;: 10,
13975 &quot;next_longest_message&quot;: &quot;No longer message&quot;
13976 },
13977 {
13978 &quot;message_length&quot;: 35,
13979 &quot;authorId&quot;: 2,
13980 &quot;messageId&quot;: 3,
13981 &quot;next_longest_message&quot;: 44
13982 },
13983 {
13984 &quot;message_length&quot;: 44,
13985 &quot;authorId&quot;: 2,
13986 &quot;messageId&quot;: 6,
13987 &quot;next_longest_message&quot;: &quot;No longer message&quot;
13988 }
13989]
13990</pre></div></div>
13991</li>
13992</ul></div>
13993<div class="section">
13994<h3><a name="nth_value"></a>nth_value</h3>
13995<ul>
13996
13997<li>
13998
13999<p>Syntax:</p>
14000
14001<div>
14002<div>
14003<pre class="source">NTH_VALUE(expr, offset) [nthval-from] [nulls-treatment] OVER (window-definition)
14004</pre></div></div>
14005</li>
14006<li>
14007
14008<p>Returns the requested value from a tuple in the current window frame, where the window frame is specified by the window definition.</p>
14009</li>
14010<li>
14011
14012<p>Arguments:</p>
14013<ul>
14014
14015<li>
14016
14017<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>
14018</li>
14019<li>
14020
14021<p><tt>offset</tt>: The number of the offset tuple within the window frame, counting from 1.</p>
14022</li>
14023</ul>
14024</li>
14025<li>
14026
14027<p>Modifiers:</p>
14028<ul>
14029
14030<li>
14031
14032<p><a href="manual.html#Nth_val_from">Nth Val From</a>: (Optional) Determines where the function starts counting the offset.</p>
14033<ul>
14034
14035<li>
14036
14037<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>
14038</li>
14039<li>
14040
14041<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>
14042</li>
14043</ul>
14044<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>
14045</li>
14046<li>
14047
14048<p><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window frame.</p>
14049<ul>
14050
14051<li>
14052
14053<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>
14054</li>
14055<li>
14056
14057<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>
14058</li>
14059</ul>
14060<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
14061</li>
14062</ul>
14063</li>
14064<li>
14065
14066<p>Clauses:</p>
14067<ul>
14068
14069<li>
14070
14071<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14072</li>
14073<li>
14074
14075<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14076</li>
14077<li>
14078
14079<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
14080</li>
14081</ul>
14082</li>
14083<li>
14084
14085<p>Return Value:</p>
14086<ul>
14087
14088<li>
14089
14090<p>The specified value from the offset tuple.</p>
14091</li>
14092<li>
14093
14094<p>In the following cases, this function may return unpredictable results.</p>
14095<ul>
14096
14097<li>
14098
14099<p>If the window order clause is omitted.</p>
14100</li>
14101<li>
14102
14103<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
14104</li>
14105</ul>
14106</li>
14107<li>
14108
14109<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>
14110</li>
14111<li>
14112
14113<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>
14114</li>
14115</ul>
14116</li>
14117<li>
14118
14119<p>Example 1:</p>
14120<p>For each author, show the length of each message, including the length of the second shortest message from that author.</p>
14121
14122<div>
14123<div>
14124<pre class="source">SELECT m.authorId, m.messageId,
14125LENGTH(m.message) AS message_length,
14126NTH_VALUE(LENGTH(m.message), 2) FROM FIRST OVER (
14127 PARTITION BY m.authorId
14128 ORDER BY LENGTH(m.message)
14129 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
14130) AS shortest_message_but_1
14131FROM GleambookMessages AS m;
14132</pre></div></div>
14133</li>
14134<li>
14135
14136<p>The expected result is:</p>
14137
14138<div>
14139<div>
14140<pre class="source">[
14141 {
14142 &quot;message_length&quot;: 31,
14143 &quot;shortest_message_but_1&quot;: 39,
14144 &quot;authorId&quot;: 1,
14145 &quot;messageId&quot;: 8
14146 },
14147 {
14148 &quot;message_length&quot;: 39,
14149 &quot;shortest_message_but_1&quot;: 39,
14150 &quot;authorId&quot;: 1,
14151 &quot;messageId&quot;: 11 // &#x278b;
14152 },
14153 {
14154 &quot;message_length&quot;: 44,
14155 &quot;shortest_message_but_1&quot;: 39,
14156 &quot;authorId&quot;: 1,
14157 &quot;messageId&quot;: 4
14158 },
14159 {
14160 &quot;message_length&quot;: 45,
14161 &quot;shortest_message_but_1&quot;: 39,
14162 &quot;authorId&quot;: 1,
14163 &quot;messageId&quot;: 2
14164 },
14165 {
14166 &quot;message_length&quot;: 51,
14167 &quot;shortest_message_but_1&quot;: 39,
14168 &quot;authorId&quot;: 1,
14169 &quot;messageId&quot;: 10
14170 },
14171 {
14172 &quot;message_length&quot;: 35,
14173 &quot;shortest_message_but_1&quot;: 44,
14174 &quot;authorId&quot;: 2,
14175 &quot;messageId&quot;: 3
14176 },
14177 {
14178 &quot;message_length&quot;: 44,
14179 &quot;shortest_message_but_1&quot;: 44,
14180 &quot;authorId&quot;: 2,
14181 &quot;messageId&quot;: 6 // &#x278b;
14182 }
14183]
14184</pre></div></div>
14185
14186<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 shortest message, the function would be unable to find the route with the second shortest message.</p>
14187<p>&#x2781; The second shortest message from this author.</p>
14188</li>
14189<li>
14190
14191<p>Example 2:</p>
14192<p>For each author, show the length of each message, including the length of the second longest message from that author.</p>
14193
14194<div>
14195<div>
14196<pre class="source">SELECT m.authorId, m.messageId,
14197LENGTH(m.message) AS message_length,
14198NTH_VALUE(LENGTH(m.message), 2) FROM LAST OVER (
14199 PARTITION BY m.authorId
14200 ORDER BY LENGTH(m.message)
14201 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
14202) AS longest_message_but_1
14203FROM GleambookMessages AS m;
14204</pre></div></div>
14205</li>
14206<li>
14207
14208<p>The expected result is:</p>
14209
14210<div>
14211<div>
14212<pre class="source">[
14213 {
14214 &quot;message_length&quot;: 31,
14215 &quot;longest_message_but_1&quot;: 45,
14216 &quot;authorId&quot;: 1,
14217 &quot;messageId&quot;: 8
14218 },
14219 {
14220 &quot;message_length&quot;: 39,
14221 &quot;longest_message_but_1&quot;: 45,
14222 &quot;authorId&quot;: 1,
14223 &quot;messageId&quot;: 11
14224 },
14225 {
14226 &quot;message_length&quot;: 44,
14227 &quot;longest_message_but_1&quot;: 45,
14228 &quot;authorId&quot;: 1,
14229 &quot;messageId&quot;: 4
14230 },
14231 {
14232 &quot;message_length&quot;: 45,
14233 &quot;longest_message_but_1&quot;: 45,
14234 &quot;authorId&quot;: 1,
14235 &quot;messageId&quot;: 2 // &#x278b;
14236 },
14237 {
14238 &quot;message_length&quot;: 51,
14239 &quot;longest_message_but_1&quot;: 45,
14240 &quot;authorId&quot;: 1,
14241 &quot;messageId&quot;: 10
14242 },
14243 {
14244 &quot;message_length&quot;: 35,
14245 &quot;longest_message_but_1&quot;: 35,
14246 &quot;authorId&quot;: 2,
14247 &quot;messageId&quot;: 3 // &#x278b;
14248 },
14249 {
14250 &quot;message_length&quot;: 44,
14251 &quot;longest_message_but_1&quot;: 35,
14252 &quot;authorId&quot;: 2,
14253 &quot;messageId&quot;: 6
14254 }
14255]
14256</pre></div></div>
14257
14258<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 longest message for shorter messages.</p>
14259<p>&#x2781; The second longest message from this author.</p>
14260</li>
14261</ul></div>
14262<div class="section">
14263<h3><a name="ntile"></a>ntile</h3>
14264<ul>
14265
14266<li>
14267
14268<p>Syntax:</p>
14269
14270<div>
14271<div>
14272<pre class="source">NTILE(num_tiles) OVER ([window-partition-clause] [window-order-clause])
14273</pre></div></div>
14274</li>
14275<li>
14276
14277<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>
14278<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>
14279</li>
14280<li>
14281
14282<p>Arguments:</p>
14283<ul>
14284
14285<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>
14286</ul>
14287</li>
14288<li>
14289
14290<p>Clauses:</p>
14291<ul>
14292
14293<li>
14294
14295<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14296</li>
14297<li>
14298
14299<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14300</li>
14301</ul>
14302</li>
14303<li>
14304
14305<p>Return Value:</p>
14306<ul>
14307
14308<li>An value greater than or equal to 1 and less than or equal to the number of tiles.</li>
14309</ul>
14310</li>
14311<li>
14312
14313<p>Example:</p>
14314<p>Allocate each message to one of three tiles by length and message ID.</p>
14315
14316<div>
14317<div>
14318<pre class="source">SELECT m.messageId, LENGTH(m.message) AS `length`,
14319NTILE(3) OVER (
14320 ORDER BY LENGTH(m.message), m.messageId
14321) AS `ntile`
14322FROM GleambookMessages AS m;
14323</pre></div></div>
14324</li>
14325<li>
14326
14327<p>The expected result is:</p>
14328
14329<div>
14330<div>
14331<pre class="source">[
14332 {
14333 &quot;length&quot;: 31,
14334 &quot;ntile&quot;: 1,
14335 &quot;messageId&quot;: 8
14336 },
14337 {
14338 &quot;length&quot;: 35,
14339 &quot;ntile&quot;: 1,
14340 &quot;messageId&quot;: 3
14341 },
14342 {
14343 &quot;length&quot;: 39,
14344 &quot;ntile&quot;: 1,
14345 &quot;messageId&quot;: 11
14346 },
14347 {
14348 &quot;length&quot;: 44,
14349 &quot;ntile&quot;: 2,
14350 &quot;messageId&quot;: 4
14351 },
14352 {
14353 &quot;length&quot;: 44,
14354 &quot;ntile&quot;: 2,
14355 &quot;messageId&quot;: 6
14356 },
14357 {
14358 &quot;length&quot;: 45,
14359 &quot;ntile&quot;: 3,
14360 &quot;messageId&quot;: 2
14361 },
14362 {
14363 &quot;length&quot;: 51,
14364 &quot;ntile&quot;: 3,
14365 &quot;messageId&quot;: 10
14366 }
14367]
14368</pre></div></div>
14369</li>
14370</ul></div>
14371<div class="section">
14372<h3><a name="percent_rank"></a>percent_rank</h3>
14373<ul>
14374
14375<li>
14376
14377<p>Syntax:</p>
14378
14379<div>
14380<div>
14381<pre class="source">PERCENT_RANK() OVER ([window-partition-clause] [window-order-clause])
14382</pre></div></div>
14383</li>
14384<li>
14385
14386<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>
14387<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>
14388</li>
14389<li>
14390
14391<p>Arguments:</p>
14392<ul>
14393
14394<li>None.</li>
14395</ul>
14396</li>
14397<li>
14398
14399<p>Clauses:</p>
14400<ul>
14401
14402<li>
14403
14404<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14405</li>
14406<li>
14407
14408<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14409</li>
14410</ul>
14411</li>
14412<li>
14413
14414<p>Return Value:</p>
14415<ul>
14416
14417<li>A number between 0 and 1. The higher the value, the higher the ranking.</li>
14418</ul>
14419</li>
14420<li>
14421
14422<p>Example:</p>
14423<p>For each author, find the percentile rank of all messages in order of message ID.</p>
14424
14425<div>
14426<div>
14427<pre class="source">SELECT m.messageId, m.authorId, PERCENT_RANK() OVER (
14428 PARTITION BY m.authorId
14429 ORDER BY m.messageId
14430) AS `rank`
14431FROM GleambookMessages AS m;
14432</pre></div></div>
14433</li>
14434<li>
14435
14436<p>The expected result is:</p>
14437
14438<div>
14439<div>
14440<pre class="source">[
14441 {
14442 &quot;rank&quot;: 0,
14443 &quot;messageId&quot;: 2,
14444 &quot;authorId&quot;: 1
14445 },
14446 {
14447 &quot;rank&quot;: 0.25,
14448 &quot;messageId&quot;: 4,
14449 &quot;authorId&quot;: 1
14450 },
14451 {
14452 &quot;rank&quot;: 0.5,
14453 &quot;messageId&quot;: 8,
14454 &quot;authorId&quot;: 1
14455 },
14456 {
14457 &quot;rank&quot;: 0.75,
14458 &quot;messageId&quot;: 10,
14459 &quot;authorId&quot;: 1
14460 },
14461 {
14462 &quot;rank&quot;: 1,
14463 &quot;messageId&quot;: 11,
14464 &quot;authorId&quot;: 1
14465 },
14466 {
14467 &quot;rank&quot;: 0,
14468 &quot;messageId&quot;: 3,
14469 &quot;authorId&quot;: 2
14470 },
14471 {
14472 &quot;rank&quot;: 1,
14473 &quot;messageId&quot;: 6,
14474 &quot;authorId&quot;: 2
14475 }
14476]
14477</pre></div></div>
14478</li>
14479</ul></div>
14480<div class="section">
14481<h3><a name="rank"></a>rank</h3>
14482<ul>
14483
14484<li>
14485
14486<p>Syntax:</p>
14487
14488<div>
14489<div>
14490<pre class="source">RANK() OVER ([window-partition-clause] [window-order-clause])
14491</pre></div></div>
14492</li>
14493<li>
14494
14495<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>
14496<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>
14497<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 three tuples ranked 2, the next rank is 5.</p>
14498<p>To avoid gaps in the returned values, use the DENSE_RANK() function instead.</p>
14499</li>
14500<li>
14501
14502<p>Arguments:</p>
14503<ul>
14504
14505<li>None.</li>
14506</ul>
14507</li>
14508<li>
14509
14510<p>Clauses:</p>
14511<ul>
14512
14513<li>
14514
14515<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14516</li>
14517<li>
14518
14519<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14520</li>
14521</ul>
14522</li>
14523<li>
14524
14525<p>Return Value:</p>
14526<ul>
14527
14528<li>An integer, greater than or equal to 1.</li>
14529</ul>
14530</li>
14531<li>
14532
14533<p>Example:</p>
14534<p>For each author, find the rank of all messages in order of location.</p>
14535
14536<div>
14537<div>
14538<pre class="source">SELECT m.authorId, m.messageId, m.senderLocation[1] as longitude,
14539RANK() OVER (
14540 PARTITION BY m.authorId
14541 ORDER BY m.senderLocation[1]
14542) AS `rank`
14543FROM GleambookMessages AS m;
14544</pre></div></div>
14545</li>
14546<li>
14547
14548<p>The expected result is:</p>
14549
14550<div>
14551<div>
14552<pre class="source">[
14553 {
14554 &quot;rank&quot;: 1,
14555 &quot;authorId&quot;: 1,
14556 &quot;messageId&quot;: 10,
14557 &quot;longitude&quot;: 70.01
14558 },
14559 {
14560 &quot;rank&quot;: 2,
14561 &quot;authorId&quot;: 1,
14562 &quot;messageId&quot;: 11,
14563 &quot;longitude&quot;: 77.49
14564 },
14565 {
14566 &quot;rank&quot;: 3,
14567 &quot;authorId&quot;: 1,
14568 &quot;messageId&quot;: 2,
14569 &quot;longitude&quot;: 80.87
14570 },
14571 {
14572 &quot;rank&quot;: 3,
14573 &quot;authorId&quot;: 1,
14574 &quot;messageId&quot;: 8,
14575 &quot;longitude&quot;: 80.87
14576 },
14577 {
14578 &quot;rank&quot;: 5,
14579 &quot;authorId&quot;: 1,
14580 &quot;messageId&quot;: 4,
14581 &quot;longitude&quot;: 97.04
14582 },
14583 {
14584 &quot;rank&quot;: 1,
14585 &quot;authorId&quot;: 2,
14586 &quot;messageId&quot;: 6,
14587 &quot;longitude&quot;: 75.56
14588 },
14589 {
14590 &quot;rank&quot;: 2,
14591 &quot;authorId&quot;: 2,
14592 &quot;messageId&quot;: 3,
14593 &quot;longitude&quot;: 81.01
14594 }
14595]
14596</pre></div></div>
14597</li>
14598</ul></div>
14599<div class="section">
14600<h3><a name="ratio_to_report"></a>ratio_to_report</h3>
14601<ul>
14602
14603<li>
14604
14605<p>Syntax:</p>
14606
14607<div>
14608<div>
14609<pre class="source">RATIO_TO_REPORT(expr) OVER (window-definition)
14610</pre></div></div>
14611</li>
14612<li>
14613
14614<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>
14615</li>
14616<li>
14617
14618<p>Arguments:</p>
14619<ul>
14620
14621<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>
14622</ul>
14623</li>
14624<li>
14625
14626<p>Clauses:</p>
14627<ul>
14628
14629<li>
14630
14631<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14632</li>
14633<li>
14634
14635<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14636</li>
14637<li>
14638
14639<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
14640</li>
14641</ul>
14642</li>
14643<li>
14644
14645<p>Return Value:</p>
14646<ul>
14647
14648<li>
14649
14650<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>
14651</li>
14652<li>
14653
14654<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>
14655</li>
14656</ul>
14657</li>
14658<li>
14659
14660<p>Example:</p>
14661<p>For each author, calculate the length of each message as a fraction of the total length of all messages.</p>
14662
14663<div>
14664<div>
14665<pre class="source">SELECT m.messageId, m.authorId,
14666RATIO_TO_REPORT(LENGTH(m.message)) OVER (
14667 PARTITION BY m.authorId
14668) AS length_ratio
14669FROM GleambookMessages AS m;
14670</pre></div></div>
14671</li>
14672<li>
14673
14674<p>The expected result is:</p>
14675
14676<div>
14677<div>
14678<pre class="source">[
14679 {
14680 &quot;length_ratio&quot;: 0.21428571428571427,
14681 &quot;messageId&quot;: 2,
14682 &quot;authorId&quot;: 1
14683 },
14684 {
14685 &quot;length_ratio&quot;: 0.20952380952380953,
14686 &quot;messageId&quot;: 4,
14687 &quot;authorId&quot;: 1
14688 },
14689 {
14690 &quot;length_ratio&quot;: 0.14761904761904762,
14691 &quot;messageId&quot;: 8,
14692 &quot;authorId&quot;: 1
14693 },
14694 {
14695 &quot;length_ratio&quot;: 0.24285714285714285,
14696 &quot;messageId&quot;: 10,
14697 &quot;authorId&quot;: 1
14698 },
14699 {
14700 &quot;length_ratio&quot;: 0.18571428571428572,
14701 &quot;messageId&quot;: 11,
14702 &quot;authorId&quot;: 1
14703 },
14704 {
14705 &quot;length_ratio&quot;: 0.4430379746835443,
14706 &quot;messageId&quot;: 3,
14707 &quot;authorId&quot;: 2
14708 },
14709 {
14710 &quot;length_ratio&quot;: 0.5569620253164557,
14711 &quot;messageId&quot;: 6,
14712 &quot;authorId&quot;: 2
14713 }
14714]
14715</pre></div></div>
14716</li>
14717</ul></div>
14718<div class="section">
14719<h3><a name="row_number"></a>row_number</h3>
14720<ul>
14721
14722<li>
14723
14724<p>Syntax:</p>
14725
14726<div>
14727<div>
14728<pre class="source">ROW_NUMBER() OVER ([window-partition-clause] [window-order-clause])
14729</pre></div></div>
14730</li>
14731<li>
14732
14733<p>Returns a unique row number for every tuple in every window partition. In each window partition, the row numbering starts at 1.</p>
14734<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>
14735</li>
14736<li>
14737
14738<p>Arguments:</p>
14739<ul>
14740
14741<li>None.</li>
14742</ul>
14743</li>
14744<li>
14745
14746<p>Clauses:</p>
14747<ul>
14748
14749<li>
14750
14751<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14752</li>
14753<li>
14754
14755<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14756</li>
14757</ul>
14758</li>
14759<li>
14760
14761<p>Return Value:</p>
14762<ul>
14763
14764<li>An integer, greater than or equal to 1.</li>
14765</ul>
14766</li>
14767<li>
14768
14769<p>Example:</p>
14770<p>For each author, number all messages in order of length.</p>
14771
14772<div>
14773<div>
14774<pre class="source">SELECT m.messageId, m.authorId,
14775ROW_NUMBER() OVER (
14776 PARTITION BY m.authorId
14777 ORDER BY LENGTH(m.message)
14778) AS `row`
14779FROM GleambookMessages AS m;
14780</pre></div></div>
14781</li>
14782<li>
14783
14784<p>The expected result is:</p>
14785
14786<div>
14787<div>
14788<pre class="source">[
14789 {
14790 &quot;row&quot;: 1,
14791 &quot;messageId&quot;: 8,
14792 &quot;authorId&quot;: 1
14793 },
14794 {
14795 &quot;row&quot;: 2,
14796 &quot;messageId&quot;: 11,
14797 &quot;authorId&quot;: 1
14798 },
14799 {
14800 &quot;row&quot;: 3,
14801 &quot;messageId&quot;: 4,
14802 &quot;authorId&quot;: 1
14803 },
14804 {
14805 &quot;row&quot;: 4,
14806 &quot;messageId&quot;: 2,
14807 &quot;authorId&quot;: 1
14808 },
14809 {
14810 &quot;row&quot;: 5,
14811 &quot;messageId&quot;: 10,
14812 &quot;authorId&quot;: 1
14813 },
14814 {
14815 &quot;row&quot;: 1,
14816 &quot;messageId&quot;: 3,
14817 &quot;authorId&quot;: 2
14818 },
14819 {
14820 &quot;row&quot;: 2,
14821 &quot;messageId&quot;: 6,
14822 &quot;authorId&quot;: 2
14823 }
14824]
14825</pre></div></div>
14826</li>
14827</ul><hr />
14828<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>
14829 </div>
14830 </div>
14831 </div>
14832 <hr/>
14833 <footer>
14834 <div class="container-fluid">
14835 <div class="row-fluid">
14836<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
14837 feather logo, and the Apache AsterixDB project logo are either
14838 registered trademarks or trademarks of The Apache Software
14839 Foundation in the United States and other countries.
14840 All other marks mentioned may be trademarks or registered
14841 trademarks of their respective owners.
14842 </div>
14843 </div>
14844 </div>
14845 </footer>
14846 </body>
14847</html>