Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
velox committed Oct 4, 2023
1 parent 01b0aa0 commit 5e34bbf
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 5 deletions.
30 changes: 30 additions & 0 deletions docs/_sources/functions/presto/map.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
Map Functions
===========================

.. function:: all_keys_match(x(K,V), function(K, boolean)) -> boolean

Returns whether all keys of a map match the given predicate. Returns true if all the keys match the predicate (a special case is when the map is empty); false if one or more keys don’t match; NULL if the predicate function returns NULL for one or more keys and true for all other keys. ::

SELECT all_keys_match(map(array['a', 'b', 'c'], array[1, 2, 3]), x -> length(x) = 1); -- true

.. function:: any_keys_match(x(K,V), function(K, boolean)) -> boolean

Returns whether any keys of a map match the given predicate. Returns true if one or more keys match the predicate; false if none of the keys match (a special case is when the map is empty); NULL if the predicate function returns NULL for one or more keys and false for all other keys. ::

SELECT any_keys_match(map(array['a', 'b', 'c'], array[1, 2, 3]), x -> x = 'a'); -- true

.. function:: any_values_match(x(K,V), function(V, boolean)) -> boolean

Returns whether any values of a map matches the given predicate. Returns true if one or more values match the predicate; false if none of the values match (a special case is when the map is empty); NULL if the predicate function returns NULL for one or more values and false for all other values. ::

SELECT ANY_VALUES_MATCH(map(ARRAY['a', 'b', 'c'], ARRAY[1, 2, 3]), x -> x = 1); -- true

.. function:: cardinality(x) -> bigint
:noindex:

Expand Down Expand Up @@ -75,6 +93,18 @@ Map Functions
MAP(ARRAY['a', 'b', 'c'], ARRAY[1, 2, 3]),
(k, v1, v2) -> k || CAST(v1/v2 AS VARCHAR));

.. function:: no_keys_match(x(K,V), function(K, boolean)) -> boolean

Returns whether no keys of a map match the given predicate. Returns true if none of the keys match the predicate (a special case is when the map is empty); false if one or more keys match; NULL if the predicate function returns NULL for one or more keys and false for all other keys. ::

SELECT no_keys_match(map(array['a', 'b', 'c'], array[1, 2, 3]), x -> x = 'd'); -- true

.. function:: no_values_match(x(K,V), function(V, boolean)) -> boolean

Returns whether no values of a map match the given predicate. Returns true if none of the values match the predicate (a special case is when the map is empty); false if one or more values match; NULL if the predicate function returns NULL for one or more values and false for all other values. ::

SELECT no_values_match(map(array['a', 'b', 'c'], array[1, 2, 3]), x -> x = 'd'); -- true

.. function:: subscript(map(K, V), key) -> V
:noindex:

Expand Down
45 changes: 45 additions & 0 deletions docs/functions/presto/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ <h3>Navigation</h3>

<section id="map-functions">
<h1>Map Functions<a class="headerlink" href="#map-functions" title="Permalink to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="all_keys_match">
<span class="sig-name descname"><span class="pre">all_keys_match</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">V)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boolean)</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">boolean</span></span></span><a class="headerlink" href="#all_keys_match" title="Permalink to this definition"></a></dt>
<dd><p>Returns whether all keys of a map match the given predicate. Returns true if all the keys match the predicate (a special case is when the map is empty); false if one or more keys don’t match; NULL if the predicate function returns NULL for one or more keys and true for all other keys.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SELECT</span> <span class="n">all_keys_match</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">array</span><span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">],</span> <span class="n">array</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="n">x</span> <span class="o">-&gt;</span> <span class="n">length</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">=</span> <span class="mi">1</span><span class="p">);</span> <span class="o">--</span> <span class="n">true</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="any_keys_match">
<span class="sig-name descname"><span class="pre">any_keys_match</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">V)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boolean)</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">boolean</span></span></span><a class="headerlink" href="#any_keys_match" title="Permalink to this definition"></a></dt>
<dd><p>Returns whether any keys of a map match the given predicate. Returns true if one or more keys match the predicate; false if none of the keys match (a special case is when the map is empty); NULL if the predicate function returns NULL for one or more keys and false for all other keys.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SELECT</span> <span class="n">any_keys_match</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">array</span><span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">],</span> <span class="n">array</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="n">x</span> <span class="o">-&gt;</span> <span class="n">x</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span><span class="p">);</span> <span class="o">--</span> <span class="n">true</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="any_values_match">
<span class="sig-name descname"><span class="pre">any_values_match</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">V)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function(V</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boolean)</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">boolean</span></span></span><a class="headerlink" href="#any_values_match" title="Permalink to this definition"></a></dt>
<dd><p>Returns whether any values of a map matches the given predicate. Returns true if one or more values match the predicate; false if none of the values match (a special case is when the map is empty); NULL if the predicate function returns NULL for one or more values and false for all other values.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SELECT</span> <span class="n">ANY_VALUES_MATCH</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">ARRAY</span><span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">],</span> <span class="n">ARRAY</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="n">x</span> <span class="o">-&gt;</span> <span class="n">x</span> <span class="o">=</span> <span class="mi">1</span><span class="p">);</span> <span class="o">--</span> <span class="n">true</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">cardinality</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">bigint</span></span></span></dt>
Expand Down Expand Up @@ -143,6 +170,24 @@ <h1>Map Functions<a class="headerlink" href="#map-functions" title="Permalink to
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="no_keys_match">
<span class="sig-name descname"><span class="pre">no_keys_match</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">V)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boolean)</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">boolean</span></span></span><a class="headerlink" href="#no_keys_match" title="Permalink to this definition"></a></dt>
<dd><p>Returns whether no keys of a map match the given predicate. Returns true if none of the keys match the predicate (a special case is when the map is empty); false if one or more keys match; NULL if the predicate function returns NULL for one or more keys and false for all other keys.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SELECT</span> <span class="n">no_keys_match</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">array</span><span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">],</span> <span class="n">array</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="n">x</span> <span class="o">-&gt;</span> <span class="n">x</span> <span class="o">=</span> <span class="s1">&#39;d&#39;</span><span class="p">);</span> <span class="o">--</span> <span class="n">true</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="no_values_match">
<span class="sig-name descname"><span class="pre">no_values_match</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">V)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">function(V</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boolean)</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">boolean</span></span></span><a class="headerlink" href="#no_values_match" title="Permalink to this definition"></a></dt>
<dd><p>Returns whether no values of a map match the given predicate. Returns true if none of the values match the predicate (a special case is when the map is empty); false if one or more values match; NULL if the predicate function returns NULL for one or more values and false for all other values.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SELECT</span> <span class="n">no_values_match</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="n">array</span><span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">],</span> <span class="n">array</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="n">x</span> <span class="o">-&gt;</span> <span class="n">x</span> <span class="o">=</span> <span class="s1">&#39;d&#39;</span><span class="p">);</span> <span class="o">--</span> <span class="n">true</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">subscript</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">map(K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">V)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">key</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">V</span></span></span></dt>
Expand Down
53 changes: 49 additions & 4 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ <h2 id="A">A</h2>

<ul>
<li><a href="functions/spark/array.html#aggregate">built-in function</a>
</li>
</ul></li>
<li>
all_keys_match()

<ul>
<li><a href="functions/presto/map.html#all_keys_match">built-in function</a>
</li>
</ul></li>
<li>
any_keys_match()

<ul>
<li><a href="functions/presto/map.html#any_keys_match">built-in function</a>
</li>
</ul></li>
<li>
any_values_match()

<ul>
<li><a href="functions/presto/map.html#any_values_match">built-in function</a>
</li>
</ul></li>
<li>
Expand Down Expand Up @@ -186,6 +207,8 @@ <h2 id="A">A</h2>
<li><a href="functions/presto/array.html#array_except">built-in function</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
array_frequency()

Expand All @@ -200,8 +223,6 @@ <h2 id="A">A</h2>
<li><a href="functions/presto/array.html#array_has_duplicates">built-in function</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
array_intersect()

Expand Down Expand Up @@ -508,6 +529,12 @@ <h2 id="B">B</h2>
<li><a href="functions/spark/math.html#add">add()</a>
</li>
<li><a href="functions/spark/array.html#aggregate">aggregate()</a>
</li>
<li><a href="functions/presto/map.html#all_keys_match">all_keys_match()</a>
</li>
<li><a href="functions/presto/map.html#any_keys_match">any_keys_match()</a>
</li>
<li><a href="functions/presto/map.html#any_values_match">any_values_match()</a>
</li>
<li><a href="functions/presto/aggregate.html#approx_distinct">approx_distinct()</a>
</li>
Expand Down Expand Up @@ -940,6 +967,10 @@ <h2 id="B">B</h2>
<li><a href="functions/presto/math.html#negate">negate()</a>
</li>
<li><a href="functions/presto/comparison.html#neq">neq()</a>
</li>
<li><a href="functions/presto/map.html#no_keys_match">no_keys_match()</a>
</li>
<li><a href="functions/presto/map.html#no_values_match">no_values_match()</a>
</li>
<li><a href="functions/presto/math.html#normal_cdf">normal_cdf()</a>
</li>
Expand Down Expand Up @@ -2408,15 +2439,29 @@ <h2 id="N">N</h2>
</li>
</ul></li>
<li>
normal_cdf()
no_keys_match()

<ul>
<li><a href="functions/presto/math.html#normal_cdf">built-in function</a>
<li><a href="functions/presto/map.html#no_keys_match">built-in function</a>
</li>
</ul></li>
<li>
no_values_match()

<ul>
<li><a href="functions/presto/map.html#no_values_match">built-in function</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
normal_cdf()

<ul>
<li><a href="functions/presto/math.html#normal_cdf">built-in function</a>
</li>
</ul></li>
<li>
not()

<ul>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

0 comments on commit 5e34bbf

Please sign in to comment.