This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new e2c66a8fa5 Publish built docs triggered by 
3f422a1746a243d13f37c229c7b774af6d4552b1
e2c66a8fa5 is described below

commit e2c66a8fa5be18dcb310b631205db21dd4137eef
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Sep 5 12:19:01 2025 +0000

    Publish built docs triggered by 3f422a1746a243d13f37c229c7b774af6d4552b1
---
 _sources/user-guide/sql/aggregate_functions.md.txt | 19 +++++++++++++++++++
 _sources/user-guide/sql/window_functions.md.txt    | 11 +++++++++++
 searchindex.js                                     |  2 +-
 user-guide/sql/aggregate_functions.html            | 20 ++++++++++++++++++++
 user-guide/sql/index.html                          |  2 ++
 user-guide/sql/window_functions.html               | 14 ++++++++++++++
 6 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/_sources/user-guide/sql/aggregate_functions.md.txt 
b/_sources/user-guide/sql/aggregate_functions.md.txt
index cdb51c64fc..205962031b 100644
--- a/_sources/user-guide/sql/aggregate_functions.md.txt
+++ b/_sources/user-guide/sql/aggregate_functions.md.txt
@@ -29,6 +29,25 @@ dev/update_function_docs.sh file for updating surrounding 
text.
 
 Aggregate functions operate on a set of values to compute a single result.
 
+## Filter clause
+
+Aggregate functions support the SQL `FILTER (WHERE ...)` clause to restrict 
which input rows contribute to the aggregate result.
+
+```sql
+function([exprs]) FILTER (WHERE condition)
+```
+
+Example:
+
+```sql
+SELECT
+  sum(salary) FILTER (WHERE salary > 0) AS sum_positive_salaries,
+  count(*)    FILTER (WHERE active)     AS active_count
+FROM employees;
+```
+
+Note: When no rows pass the filter, `COUNT` returns `0` while 
`SUM`/`AVG`/`MIN`/`MAX` return `NULL`.
+
 ## General Functions
 
 - [array_agg](#array_agg)
diff --git a/_sources/user-guide/sql/window_functions.md.txt 
b/_sources/user-guide/sql/window_functions.md.txt
index 73e9731cdb..2c8050ce1f 100644
--- a/_sources/user-guide/sql/window_functions.md.txt
+++ b/_sources/user-guide/sql/window_functions.md.txt
@@ -145,6 +145,17 @@ where **offset** is an non-negative integer.
 
 RANGE and GROUPS modes require an ORDER BY clause (with RANGE the ORDER BY 
must specify exactly one column).
 
+## Filter clause for aggregate window functions
+
+Aggregate window functions support the SQL `FILTER (WHERE ...)` clause to 
include only rows that satisfy the predicate from the window frame in the 
aggregation.
+
+```sql
+sum(salary) FILTER (WHERE salary > 0)
+  OVER (PARTITION BY depname ORDER BY salary ROWS BETWEEN UNBOUNDED PRECEDING 
AND CURRENT ROW)
+```
+
+If no rows in the frame satisfy the filter for a given output row, `COUNT` 
yields `0` while `SUM`/`AVG`/`MIN`/`MAX` yield `NULL`.
+
 ## Aggregate functions
 
 All [aggregate functions](aggregate_functions.md) can be used as window 
functions.
diff --git a/searchindex.js b/searchindex.js
index 872598c3e0..e736210b9e 100644
--- a/searchindex.js
+++ b/searchindex.js
@@ -1 +1 @@
-Search.setIndex({"alltitles":{"!=":[[57,"op-neq"]],"!~":[[57,"op-re-not-match"]],"!~*":[[57,"op-re-not-match-i"]],"!~~":[[57,"id19"]],"!~~*":[[57,"id20"]],"#":[[57,"op-bit-xor"]],"%":[[57,"op-modulo"]],"&":[[57,"op-bit-and"]],"(relation,
 name) tuples in logical fields and logical columns are 
unique":[[12,"relation-name-tuples-in-logical-fields-and-logical-columns-are-unique"]],"*":[[57,"op-multiply"]],"+":[[57,"op-plus"]],"-":[[57,"op-minus"]],"/":[[57,"op-divide"]],"<":[[57,"op-lt"]],"<
 [...]
\ No newline at end of file
+Search.setIndex({"alltitles":{"!=":[[57,"op-neq"]],"!~":[[57,"op-re-not-match"]],"!~*":[[57,"op-re-not-match-i"]],"!~~":[[57,"id19"]],"!~~*":[[57,"id20"]],"#":[[57,"op-bit-xor"]],"%":[[57,"op-modulo"]],"&":[[57,"op-bit-and"]],"(relation,
 name) tuples in logical fields and logical columns are 
unique":[[12,"relation-name-tuples-in-logical-fields-and-logical-columns-are-unique"]],"*":[[57,"op-multiply"]],"+":[[57,"op-plus"]],"-":[[57,"op-minus"]],"/":[[57,"op-divide"]],"<":[[57,"op-lt"]],"<
 [...]
\ No newline at end of file
diff --git a/user-guide/sql/aggregate_functions.html 
b/user-guide/sql/aggregate_functions.html
index ff38b24c5b..a1fddbe337 100644
--- a/user-guide/sql/aggregate_functions.html
+++ b/user-guide/sql/aggregate_functions.html
@@ -549,6 +549,11 @@
 
 <nav id="bd-toc-nav">
     <ul class="visible nav section-nav flex-column">
+ <li class="toc-h2 nav-item toc-entry">
+  <a class="reference internal nav-link" href="#filter-clause">
+   Filter clause
+  </a>
+ </li>
  <li class="toc-h2 nav-item toc-entry">
   <a class="reference internal nav-link" href="#general-functions">
    General Functions
@@ -1457,6 +1462,21 @@ dev/update_function_docs.sh file for updating 
surrounding text.
 <section id="aggregate-functions">
 <h1>Aggregate Functions<a class="headerlink" href="#aggregate-functions" 
title="Link to this heading">¶</a></h1>
 <p>Aggregate functions operate on a set of values to compute a single 
result.</p>
+<section id="filter-clause">
+<h2>Filter clause<a class="headerlink" href="#filter-clause" title="Link to 
this heading">¶</a></h2>
+<p>Aggregate functions support the SQL <code class="docutils literal 
notranslate"><span class="pre">FILTER</span> <span class="pre">(WHERE</span> 
<span class="pre">...)</span></code> clause to restrict which input rows 
contribute to the aggregate result.</p>
+<div class="highlight-sql notranslate"><div 
class="highlight"><pre><span></span><span class="k">function</span><span 
class="p">([</span><span class="n">exprs</span><span class="p">])</span><span 
class="w"> </span><span class="n">FILTER</span><span class="w"> </span><span 
class="p">(</span><span class="k">WHERE</span><span class="w"> </span><span 
class="n">condition</span><span class="p">)</span>
+</pre></div>
+</div>
+<p>Example:</p>
+<div class="highlight-sql notranslate"><div 
class="highlight"><pre><span></span><span class="k">SELECT</span>
+<span class="w">  </span><span class="k">sum</span><span 
class="p">(</span><span class="n">salary</span><span class="p">)</span><span 
class="w"> </span><span class="n">FILTER</span><span class="w"> </span><span 
class="p">(</span><span class="k">WHERE</span><span class="w"> </span><span 
class="n">salary</span><span class="w"> </span><span class="o">&gt;</span><span 
class="w"> </span><span class="mi">0</span><span class="p">)</span><span 
class="w"> </span><span class="k">AS</span><span cla [...]
+<span class="w">  </span><span class="k">count</span><span 
class="p">(</span><span class="o">*</span><span class="p">)</span><span 
class="w">    </span><span class="n">FILTER</span><span class="w"> </span><span 
class="p">(</span><span class="k">WHERE</span><span class="w"> </span><span 
class="n">active</span><span class="p">)</span><span class="w">     
</span><span class="k">AS</span><span class="w"> </span><span 
class="n">active_count</span>
+<span class="k">FROM</span><span class="w"> </span><span 
class="n">employees</span><span class="p">;</span>
+</pre></div>
+</div>
+<p>Note: When no rows pass the filter, <code class="docutils literal 
notranslate"><span class="pre">COUNT</span></code> returns <code 
class="docutils literal notranslate"><span class="pre">0</span></code> while 
<code class="docutils literal notranslate"><span 
class="pre">SUM</span></code>/<code class="docutils literal notranslate"><span 
class="pre">AVG</span></code>/<code class="docutils literal notranslate"><span 
class="pre">MIN</span></code>/<code class="docutils literal notranslate">< [...]
+</section>
 <section id="general-functions">
 <h2>General Functions<a class="headerlink" href="#general-functions" 
title="Link to this heading">¶</a></h2>
 <ul class="simple">
diff --git a/user-guide/sql/index.html b/user-guide/sql/index.html
index 4024e7958f..7858be21f8 100644
--- a/user-guide/sql/index.html
+++ b/user-guide/sql/index.html
@@ -649,6 +649,7 @@
 </ul>
 </li>
 <li class="toctree-l1"><a class="reference internal" 
href="aggregate_functions.html">Aggregate Functions</a><ul>
+<li class="toctree-l2"><a class="reference internal" 
href="aggregate_functions.html#filter-clause">Filter clause</a></li>
 <li class="toctree-l2"><a class="reference internal" 
href="aggregate_functions.html#general-functions">General Functions</a></li>
 <li class="toctree-l2"><a class="reference internal" 
href="aggregate_functions.html#statistical-functions">Statistical 
Functions</a></li>
 <li class="toctree-l2"><a class="reference internal" 
href="aggregate_functions.html#approximate-functions">Approximate 
Functions</a></li>
@@ -656,6 +657,7 @@
 </li>
 <li class="toctree-l1"><a class="reference internal" 
href="window_functions.html">Window Functions</a><ul>
 <li class="toctree-l2"><a class="reference internal" 
href="window_functions.html#syntax">Syntax</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="window_functions.html#filter-clause-for-aggregate-window-functions">Filter
 clause for aggregate window functions</a></li>
 <li class="toctree-l2"><a class="reference internal" 
href="window_functions.html#aggregate-functions">Aggregate functions</a></li>
 <li class="toctree-l2"><a class="reference internal" 
href="window_functions.html#ranking-functions">Ranking Functions</a></li>
 <li class="toctree-l2"><a class="reference internal" 
href="window_functions.html#analytical-functions">Analytical Functions</a></li>
diff --git a/user-guide/sql/window_functions.html 
b/user-guide/sql/window_functions.html
index 563b442506..0463e52a86 100644
--- a/user-guide/sql/window_functions.html
+++ b/user-guide/sql/window_functions.html
@@ -554,6 +554,11 @@
    Syntax
   </a>
  </li>
+ <li class="toc-h2 nav-item toc-entry">
+  <a class="reference internal nav-link" 
href="#filter-clause-for-aggregate-window-functions">
+   Filter clause for aggregate window functions
+  </a>
+ </li>
  <li class="toc-h2 nav-item toc-entry">
   <a class="reference internal nav-link" href="#aggregate-functions">
    Aggregate functions
@@ -935,6 +940,15 @@ Instead, the rows retain their separate identities. Behind 
the scenes, the windo
 <p>where <strong>offset</strong> is an non-negative integer.</p>
 <p>RANGE and GROUPS modes require an ORDER BY clause (with RANGE the ORDER BY 
must specify exactly one column).</p>
 </section>
+<section id="filter-clause-for-aggregate-window-functions">
+<h2>Filter clause for aggregate window functions<a class="headerlink" 
href="#filter-clause-for-aggregate-window-functions" title="Link to this 
heading">¶</a></h2>
+<p>Aggregate window functions support the SQL <code class="docutils literal 
notranslate"><span class="pre">FILTER</span> <span class="pre">(WHERE</span> 
<span class="pre">...)</span></code> clause to include only rows that satisfy 
the predicate from the window frame in the aggregation.</p>
+<div class="highlight-sql notranslate"><div 
class="highlight"><pre><span></span><span class="k">sum</span><span 
class="p">(</span><span class="n">salary</span><span class="p">)</span><span 
class="w"> </span><span class="n">FILTER</span><span class="w"> </span><span 
class="p">(</span><span class="k">WHERE</span><span class="w"> </span><span 
class="n">salary</span><span class="w"> </span><span class="o">&gt;</span><span 
class="w"> </span><span class="mi">0</span><span class="p">)</span>
+<span class="w">  </span><span class="n">OVER</span><span class="w"> 
</span><span class="p">(</span><span class="n">PARTITION</span><span class="w"> 
</span><span class="k">BY</span><span class="w"> </span><span 
class="n">depname</span><span class="w"> </span><span 
class="k">ORDER</span><span class="w"> </span><span class="k">BY</span><span 
class="w"> </span><span class="n">salary</span><span class="w"> </span><span 
class="k">ROWS</span><span class="w"> </span><span class="k">BETWEEN</spa [...]
+</pre></div>
+</div>
+<p>If no rows in the frame satisfy the filter for a given output row, <code 
class="docutils literal notranslate"><span class="pre">COUNT</span></code> 
yields <code class="docutils literal notranslate"><span 
class="pre">0</span></code> while <code class="docutils literal 
notranslate"><span class="pre">SUM</span></code>/<code class="docutils literal 
notranslate"><span class="pre">AVG</span></code>/<code class="docutils literal 
notranslate"><span class="pre">MIN</span></code>/<code class="d [...]
+</section>
 <section id="aggregate-functions">
 <h2>Aggregate functions<a class="headerlink" href="#aggregate-functions" 
title="Link to this heading">¶</a></h2>
 <p>All <a class="reference internal" href="aggregate_functions.html"><span 
class="std std-doc">aggregate functions</span></a> can be used as window 
functions.</p>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@datafusion.apache.org
For additional commands, e-mail: commits-h...@datafusion.apache.org

Reply via email to