This is an automated email from the ASF dual-hosted git repository. kassiez pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new 3c5742d1b18 [function] Fix incomplete window-function introduce (#2168) 3c5742d1b18 is described below commit 3c5742d1b1821d243676f62a22ea9650c2efe178 Author: zclllyybb <zhaochan...@selectdb.com> AuthorDate: Wed Apr 23 19:45:30 2025 +0800 [function] Fix incomplete window-function introduce (#2168) ## Versions - [x] dev - [x] 3.0 - [x] 2.1 - [x] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --- .../{window-function.md => overview.md} | 26 ++++----- .../{window-function.md => overview.md} | 44 +++++++------- .../query/query-data/window-function.md | 46 ++++++++------- .../window-functions/WINDOW-FUNCTION.md | 55 +++++++++-------- .../{window-function.md => overview.md} | 44 +++++++------- .../{window-function.md => overview.md} | 44 +++++++------- sidebars.json | 2 +- .../query/query-data/window-function.md | 68 ++++++++++++---------- .../window-functions/WINDOW-FUNCTION.md | 21 ++++--- .../{window-function.md => overview.md} | 26 ++++----- .../{window-function.md => overview.md} | 26 ++++----- versioned_sidebars/version-2.1-sidebars.json | 2 +- versioned_sidebars/version-3.0-sidebars.json | 2 +- 13 files changed, 208 insertions(+), 198 deletions(-) diff --git a/docs/sql-manual/sql-functions/window-functions/window-function.md b/docs/sql-manual/sql-functions/window-functions/overview.md similarity index 78% rename from docs/sql-manual/sql-functions/window-functions/window-function.md rename to docs/sql-manual/sql-functions/window-functions/overview.md index c12caa967bd..05351aa4233 100644 --- a/docs/sql-manual/sql-functions/window-functions/window-function.md +++ b/docs/sql-manual/sql-functions/window-functions/overview.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION", + "title": "OVERVIEW", "language": "en" } --- @@ -13,7 +13,7 @@ Unless required by applicable law or agreed to in writing, software distributed ## Description -Window functions (also known as analytic functions) are special built-in functions that perform calculations while preserving the original rows. Unlike aggregate functions, window functions: +[Window functions](../../../query-data/window-function) (also known as analytic functions) are special built-in functions that perform calculations while preserving the original rows. Unlike aggregate functions, window functions: - Process data within a specific window range rather than by GROUP BY grouping - Calculate a value for each row in the result set @@ -37,7 +37,7 @@ function(<args>) OVER( | Parameter | Description | |-----------|-------------| | `<args>` | Input parameters for the window function, specific to the function being used | -| `<function>` | Supported functions include: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() | +| `<function>` | Supported functions include: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() and all aggregate functions | | `<partition_by>` | Similar to GROUP BY, groups data by specified columns | | `<order_by>` | Defines the ordering of data within the window | | `<window_clause>` | Defines the window range, syntax: ROWS BETWEEN [ { m \| UNBOUNDED } PRECEDING \| CURRENT ROW] [ AND [CURRENT ROW \| { UNBOUNDED \| n } FOLLOWING] ] | @@ -78,13 +78,13 @@ from stock_ticker; ``` ```text - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | -``` \ No newline at end of file +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/window-function.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/overview.md similarity index 67% rename from i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/window-function.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/overview.md index c272479d08f..4791e5a3343 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/window-function.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/overview.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION", + "title": "OVERVIEW", "language": "zh-CN" } --- @@ -13,7 +13,7 @@ Unless required by applicable law or agreed to in writing, software distributed ## 描述 -窗口函数(也称为分析函数)是一类特殊的内置函数,它能在保留原始行的基础上进行计算。与聚合函数不同,窗口函数: +[窗口函数](../../../query-data/window-function)(也称为分析函数)是一类特殊的内置函数,它能在保留原始行的基础上进行计算。与聚合函数不同,窗口函数: - 在特定窗口范围内处理数据,而不是按 GROUP BY 分组 - 为结果集的每一行计算一个值 @@ -37,7 +37,7 @@ function(<args>) OVER( | 参数 | 说明 | |------|------| | `<args>` | 窗口函数的输入参数,具体参数根据所使用的函数而定 | -| `<function>` | 支持的函数包括:AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() | +| `<function>` | 支持的函数包括:AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() 和所有聚合函数 | | `<partition_by>` | 类似于 GROUP BY,按指定列对数据进行分组 | | `<order_by>` | 定义窗口内数据的排序方式 | | `<window_clause>` | 定义窗口范围,语法为:ROWS BETWEEN [ { m \| UNBOUNDED } PRECEDING \| CURRENT ROW] [ AND [CURRENT ROW \| { UNBOUNDED \| n } FOLLOWING] ] | @@ -57,15 +57,15 @@ select * from stock_ticker order by stock_symbol, closing_date ``` ```text - | stock_symbol | closing_price | closing_date | - |--------------|---------------|---------------------| - | JDR | 12.86 | 2014-10-02 00:00:00 | - | JDR | 12.89 | 2014-10-03 00:00:00 | - | JDR | 12.94 | 2014-10-04 00:00:00 | - | JDR | 12.55 | 2014-10-05 00:00:00 | - | JDR | 14.03 | 2014-10-06 00:00:00 | - | JDR | 14.75 | 2014-10-07 00:00:00 | - | JDR | 13.98 | 2014-10-08 00:00:00 | +| stock_symbol | closing_price | closing_date | +|--------------|---------------|---------------------| +| JDR | 12.86 | 2014-10-02 00:00:00 | +| JDR | 12.89 | 2014-10-03 00:00:00 | +| JDR | 12.94 | 2014-10-04 00:00:00 | +| JDR | 12.55 | 2014-10-05 00:00:00 | +| JDR | 14.03 | 2014-10-06 00:00:00 | +| JDR | 14.75 | 2014-10-07 00:00:00 | +| JDR | 13.98 | 2014-10-08 00:00:00 | ``` 2. 这个查询使用分析函数产生 moving_average 这一列,它的值是 3 天的股票均价,即前一天、当前以及后一天三天的均价。第一天没有前一天的值,最后一天没有后一天的值,所以这两行只计算了两天的均值。这里 Partition By 没有起到作用,因为所有的数据都是 JDR 的数据,但如果还有其他股票信息,Partition By 会保证分析函数值作用在本 Partition 之内。 @@ -78,13 +78,13 @@ from stock_ticker; ``` ```text - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | -``` \ No newline at end of file +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/query/query-data/window-function.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/query/query-data/window-function.md index 1326faf6354..d6b139f72ac 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/query/query-data/window-function.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/query/query-data/window-function.md @@ -36,7 +36,7 @@ order_by_clause ::= ORDER BY expr [ASC | DESC] [, expr [ASC | DESC] ...] ## Function -目前支持的 Function 包括 AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER() 和 SUM()。 +目前支持的 Function 包括 AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() 和所有聚合函数。 ## PARTITION BY 从句 @@ -75,15 +75,18 @@ ROWS BETWEEN [ { m | UNBOUNDED } PRECEDING | CURRENT ROW] [ AND [CURRENT ROW | { create table stock_ticker (stock_symbol string, closing_price decimal(8,2), closing_date timestamp); ...load some data... select * from stock_ticker order by stock_symbol, closing_date - | stock_symbol | closing_price | closing_date | - |--------------|---------------|---------------------| - | JDR | 12.86 | 2014-10-02 00:00:00 | - | JDR | 12.89 | 2014-10-03 00:00:00 | - | JDR | 12.94 | 2014-10-04 00:00:00 | - | JDR | 12.55 | 2014-10-05 00:00:00 | - | JDR | 14.03 | 2014-10-06 00:00:00 | - | JDR | 14.75 | 2014-10-07 00:00:00 | - | JDR | 13.98 | 2014-10-08 00:00:00 | +``` + +```text +| stock_symbol | closing_price | closing_date | +|--------------|---------------|---------------------| +| JDR | 12.86 | 2014-10-02 00:00:00 | +| JDR | 12.89 | 2014-10-03 00:00:00 | +| JDR | 12.94 | 2014-10-04 00:00:00 | +| JDR | 12.55 | 2014-10-05 00:00:00 | +| JDR | 14.03 | 2014-10-06 00:00:00 | +| JDR | 14.75 | 2014-10-07 00:00:00 | +| JDR | 13.98 | 2014-10-08 00:00:00 | ``` 这个查询使用分析函数产生 moving_average 这一列,它的值是 3 天的股票均价,即前一天、当前以及后一天三天的均价。第一天没有前一天的值,最后一天没有后一天的值,所以这两行只计算了两天的均值。这里 Partition By 没有起到作用,因为所有的数据都是 JDR 的数据,但如果还有其他股票信息,Partition By 会保证分析函数值作用在本 Partition 之内。 @@ -93,17 +96,20 @@ select stock_symbol, closing_date, closing_price, avg(closing_price) over (partition by stock_symbol order by closing_date rows between 1 preceding and 1 following) as moving_average from stock_ticker; - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +``` + +```text +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | ``` ## 更多帮助 -更多窗口函数,参见 SQL 手册 / SQL 函数 / [分析(窗口)函数](../../sql-manual/sql-functions/window-functions/WINDOW-FUNCTION)。 \ No newline at end of file +更多窗口函数,参见 SQL 手册 / SQL 函数 / [分析(窗口)函数](../../sql-manual/sql-functions/window-functions/WINDOW-FUNCTION)。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md index 8e66b6edd24..088535b3813 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md @@ -1,6 +1,6 @@ --- { - "title": "窗口函数", + "title": "窗口函数概述", "language": "zh-CN" } --- @@ -11,10 +11,9 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -## WINDOW FUNCTION ## 描述 -分析函数是一类特殊的内置函数。和聚合函数类似,分析函数也是对于多个输入行做计算得到一个数据值。不同的是,分析函数是在一个特定的窗口内对输入数据做处理,而不是按照 group by 来分组计算。每个窗口内的数据可以用 over() 从句进行排序和分组。分析函数会对结果集的每一行计算出一个单独的值,而不是每个 group by 分组计算一个值。这种灵活的方式允许用户在 select 从句中增加额外的列,给用户提供了更多的机会来对结果集进行重新组织和过滤。分析函数只能出现在 select 列表和最外层的 order by 从句中。在查询过程中,分析函数会在最后生效,就是说,在执行完 join,where 和 group by 等操作之后再执行。分析函数在金融和科学计算领域经常被使用到,用来分析趋势、计算离群值以及对大量数据进行分桶分析等。 +[分析函数](../../../query/query-data/window-function)(窗口函数)是一类特殊的内置函数。和聚合函数类似,分析函数也是对于多个输入行做计算得到一个数据值。不同的是,分析函数是在一个特定的窗口内对输入数据做处理,而不是按照 group by 来分组计算。每个窗口内的数据可以用 over() 从句进行排序和分组。分析函数会对结果集的每一行计算出一个单独的值,而不是每个 group by 分组计算一个值。这种灵活的方式允许用户在 select 从句中增加额外的列,给用户提供了更多的机会来对结果集进行重新组织和过滤。分析函数只能出现在 select 列表和最外层的 order by 从句中。在查询过程中,分析函数会在最后生效,就是说,在执行完 join,where 和 group by 等操作之后再执行。分析函数在金融和科学计算领域经常被使用到,用来分析趋势、计算离群值以及对大量� ��进行分桶分析等。 分析函数的语法: @@ -24,17 +23,17 @@ partition_by_clause ::= PARTITION BY expr [, expr ...] order_by_clause ::= ORDER BY expr [ASC | DESC] [, expr [ASC | DESC] ...] ``` -#### Function +### Function 目前支持的 Function 包括 AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER() 和 SUM()。 -#### PARTITION BY从句 +### PARTITION BY 从句 Partition By 从句和 Group By 类似。它把输入行按照指定的一列或多列分组,相同值的行会被分到一组。 -#### ORDER BY从句 +### ORDER BY 从句 -Order By从句和外层的Order By基本一致。它定义了输入行的排列顺序,如果指定了 Partition By,则 Order By 定义了每个 Partition 分组内的顺序。与外层 Order By 的唯一不同点是,OVER 从句中的 Order By n(n是正整数)相当于不做任何操作,而外层的 Order By n表示按照第n列排序。 +Order By 从句和外层的 Order By 基本一致。它定义了输入行的排列顺序,如果指定了 Partition By,则 Order By 定义了每个 Partition 分组内的顺序。与外层 Order By 的唯一不同点是,OVER 从句中的 Order By n(n是正整数)相当于不做任何操作,而外层的 Order By n表示按照第n列排序。 举例: @@ -47,7 +46,7 @@ c1, c2, c3, c4 FROM events; ``` -#### Window从句 +### Window 从句 Window 从句用来为分析函数指定一个运算范围,以当前行为准,前后若干行作为分析函数运算的对象。Window 从句支持的方法有:AVG(), COUNT(), FIRST_VALUE(), LAST_VALUE() 和 SUM()。对于 MAX() 和 MIN(), window 从句可以指定开始范围 UNBOUNDED PRECEDING @@ -65,15 +64,15 @@ ROWS BETWEEN [ { m | UNBOUNDED } PRECEDING | CURRENT ROW] [ AND [CURRENT ROW | { create table stock_ticker (stock_symbol string, closing_price decimal(8,2), closing_date timestamp); ...load some data... select * from stock_ticker order by stock_symbol, closing_date - | stock_symbol | closing_price | closing_date | - |--------------|---------------|---------------------| - | JDR | 12.86 | 2014-10-02 00:00:00 | - | JDR | 12.89 | 2014-10-03 00:00:00 | - | JDR | 12.94 | 2014-10-04 00:00:00 | - | JDR | 12.55 | 2014-10-05 00:00:00 | - | JDR | 14.03 | 2014-10-06 00:00:00 | - | JDR | 14.75 | 2014-10-07 00:00:00 | - | JDR | 13.98 | 2014-10-08 00:00:00 | +| stock_symbol | closing_price | closing_date | +|--------------|---------------|---------------------| +| JDR | 12.86 | 2014-10-02 00:00:00 | +| JDR | 12.89 | 2014-10-03 00:00:00 | +| JDR | 12.94 | 2014-10-04 00:00:00 | +| JDR | 12.55 | 2014-10-05 00:00:00 | +| JDR | 14.03 | 2014-10-06 00:00:00 | +| JDR | 14.75 | 2014-10-07 00:00:00 | +| JDR | 13.98 | 2014-10-08 00:00:00 | ``` 这个查询使用分析函数产生 moving_average 这一列,它的值是3天的股票均价,即前一天、当前以及后一天三天的均价。第一天没有前一天的值,最后一天没有后一天的值,所以这两行只计算了两天的均值。这里 Partition By 没有起到作用,因为所有的数据都是 JDR 的数据,但如果还有其他股票信息,Partition By 会保证分析函数值作用在本 Partition 之内。 @@ -83,17 +82,17 @@ select stock_symbol, closing_date, closing_price, avg(closing_price) over (partition by stock_symbol order by closing_date rows between 1 preceding and 1 following) as moving_average from stock_ticker; - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | ``` -### keywords +### 关键词 - WINDOW,FUNCTION +WINDOW, FUNCTION diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/window-function.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/overview.md similarity index 67% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/window-function.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/overview.md index c272479d08f..4791e5a3343 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/window-function.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/overview.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION", + "title": "OVERVIEW", "language": "zh-CN" } --- @@ -13,7 +13,7 @@ Unless required by applicable law or agreed to in writing, software distributed ## 描述 -窗口函数(也称为分析函数)是一类特殊的内置函数,它能在保留原始行的基础上进行计算。与聚合函数不同,窗口函数: +[窗口函数](../../../query-data/window-function)(也称为分析函数)是一类特殊的内置函数,它能在保留原始行的基础上进行计算。与聚合函数不同,窗口函数: - 在特定窗口范围内处理数据,而不是按 GROUP BY 分组 - 为结果集的每一行计算一个值 @@ -37,7 +37,7 @@ function(<args>) OVER( | 参数 | 说明 | |------|------| | `<args>` | 窗口函数的输入参数,具体参数根据所使用的函数而定 | -| `<function>` | 支持的函数包括:AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() | +| `<function>` | 支持的函数包括:AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() 和所有聚合函数 | | `<partition_by>` | 类似于 GROUP BY,按指定列对数据进行分组 | | `<order_by>` | 定义窗口内数据的排序方式 | | `<window_clause>` | 定义窗口范围,语法为:ROWS BETWEEN [ { m \| UNBOUNDED } PRECEDING \| CURRENT ROW] [ AND [CURRENT ROW \| { UNBOUNDED \| n } FOLLOWING] ] | @@ -57,15 +57,15 @@ select * from stock_ticker order by stock_symbol, closing_date ``` ```text - | stock_symbol | closing_price | closing_date | - |--------------|---------------|---------------------| - | JDR | 12.86 | 2014-10-02 00:00:00 | - | JDR | 12.89 | 2014-10-03 00:00:00 | - | JDR | 12.94 | 2014-10-04 00:00:00 | - | JDR | 12.55 | 2014-10-05 00:00:00 | - | JDR | 14.03 | 2014-10-06 00:00:00 | - | JDR | 14.75 | 2014-10-07 00:00:00 | - | JDR | 13.98 | 2014-10-08 00:00:00 | +| stock_symbol | closing_price | closing_date | +|--------------|---------------|---------------------| +| JDR | 12.86 | 2014-10-02 00:00:00 | +| JDR | 12.89 | 2014-10-03 00:00:00 | +| JDR | 12.94 | 2014-10-04 00:00:00 | +| JDR | 12.55 | 2014-10-05 00:00:00 | +| JDR | 14.03 | 2014-10-06 00:00:00 | +| JDR | 14.75 | 2014-10-07 00:00:00 | +| JDR | 13.98 | 2014-10-08 00:00:00 | ``` 2. 这个查询使用分析函数产生 moving_average 这一列,它的值是 3 天的股票均价,即前一天、当前以及后一天三天的均价。第一天没有前一天的值,最后一天没有后一天的值,所以这两行只计算了两天的均值。这里 Partition By 没有起到作用,因为所有的数据都是 JDR 的数据,但如果还有其他股票信息,Partition By 会保证分析函数值作用在本 Partition 之内。 @@ -78,13 +78,13 @@ from stock_ticker; ``` ```text - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | -``` \ No newline at end of file +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/window-functions/window-function.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/window-functions/overview.md similarity index 67% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/window-functions/window-function.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/window-functions/overview.md index c272479d08f..4791e5a3343 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/window-functions/window-function.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/window-functions/overview.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION", + "title": "OVERVIEW", "language": "zh-CN" } --- @@ -13,7 +13,7 @@ Unless required by applicable law or agreed to in writing, software distributed ## 描述 -窗口函数(也称为分析函数)是一类特殊的内置函数,它能在保留原始行的基础上进行计算。与聚合函数不同,窗口函数: +[窗口函数](../../../query-data/window-function)(也称为分析函数)是一类特殊的内置函数,它能在保留原始行的基础上进行计算。与聚合函数不同,窗口函数: - 在特定窗口范围内处理数据,而不是按 GROUP BY 分组 - 为结果集的每一行计算一个值 @@ -37,7 +37,7 @@ function(<args>) OVER( | 参数 | 说明 | |------|------| | `<args>` | 窗口函数的输入参数,具体参数根据所使用的函数而定 | -| `<function>` | 支持的函数包括:AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() | +| `<function>` | 支持的函数包括:AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() 和所有聚合函数 | | `<partition_by>` | 类似于 GROUP BY,按指定列对数据进行分组 | | `<order_by>` | 定义窗口内数据的排序方式 | | `<window_clause>` | 定义窗口范围,语法为:ROWS BETWEEN [ { m \| UNBOUNDED } PRECEDING \| CURRENT ROW] [ AND [CURRENT ROW \| { UNBOUNDED \| n } FOLLOWING] ] | @@ -57,15 +57,15 @@ select * from stock_ticker order by stock_symbol, closing_date ``` ```text - | stock_symbol | closing_price | closing_date | - |--------------|---------------|---------------------| - | JDR | 12.86 | 2014-10-02 00:00:00 | - | JDR | 12.89 | 2014-10-03 00:00:00 | - | JDR | 12.94 | 2014-10-04 00:00:00 | - | JDR | 12.55 | 2014-10-05 00:00:00 | - | JDR | 14.03 | 2014-10-06 00:00:00 | - | JDR | 14.75 | 2014-10-07 00:00:00 | - | JDR | 13.98 | 2014-10-08 00:00:00 | +| stock_symbol | closing_price | closing_date | +|--------------|---------------|---------------------| +| JDR | 12.86 | 2014-10-02 00:00:00 | +| JDR | 12.89 | 2014-10-03 00:00:00 | +| JDR | 12.94 | 2014-10-04 00:00:00 | +| JDR | 12.55 | 2014-10-05 00:00:00 | +| JDR | 14.03 | 2014-10-06 00:00:00 | +| JDR | 14.75 | 2014-10-07 00:00:00 | +| JDR | 13.98 | 2014-10-08 00:00:00 | ``` 2. 这个查询使用分析函数产生 moving_average 这一列,它的值是 3 天的股票均价,即前一天、当前以及后一天三天的均价。第一天没有前一天的值,最后一天没有后一天的值,所以这两行只计算了两天的均值。这里 Partition By 没有起到作用,因为所有的数据都是 JDR 的数据,但如果还有其他股票信息,Partition By 会保证分析函数值作用在本 Partition 之内。 @@ -78,13 +78,13 @@ from stock_ticker; ``` ```text - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | -``` \ No newline at end of file +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +``` diff --git a/sidebars.json b/sidebars.json index dc669aa331f..a3d121653bf 100644 --- a/sidebars.json +++ b/sidebars.json @@ -1581,7 +1581,7 @@ "type": "category", "label": "Analytic (Window) Functions", "items": [ - "sql-manual/sql-functions/window-functions/window-function", + "sql-manual/sql-functions/window-functions/overview", "sql-manual/sql-functions/window-functions/rank", "sql-manual/sql-functions/window-functions/dense-rank", "sql-manual/sql-functions/window-functions/percent-rank", diff --git a/versioned_docs/version-2.0/query/query-data/window-function.md b/versioned_docs/version-2.0/query/query-data/window-function.md index 6114a7dc781..14705a9e4f4 100644 --- a/versioned_docs/version-2.0/query/query-data/window-function.md +++ b/versioned_docs/version-2.0/query/query-data/window-function.md @@ -30,27 +30,27 @@ Window functions are a special type of built-in functions in databases. Similar The syntax of window functions as follows: -``` +```sql function(args) OVER(partition_by_clause order_by_clause [window_clause]) partition_by_clause ::= PARTITION BY expr [, expr ...] order_by_clause ::= ORDER BY expr [ASC | DESC] [, expr [ASC | DESC] ...] ``` -#### Function +### Function -The currently supported functions include `AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM().` +The currently supported functions include AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() and all aggregate functions. -#### PARTITION BY clause +### PARTITION BY clause The `Partition By` clause is similar to `Group By`. It groups input rows based on the specified one or more columns, where rows with the same values are placed in the same group. -#### ORDER BY clause +### ORDER BY clause The `Order By` clause within a window function behaves similarly to the outer-level `Order By`. It defines the arrangement of input rows, and when `Partition By` is specified, the `Order By` determines the order within each partition. The only difference from the outer `Order By` is that within the `OVER` clause, using `Order By n` (where n is a positive integer) effectively does nothing, whereas in the outer context, `Order By n` signifies sorting based on the nth column. This example demonstrates adding an `id` column to the select list, where its values are 1, 2, 3, and so on, sorted according to the `date_and_time` column in the `events` table. -``` +```sql SELECT row_number() OVER (ORDER BY date_and_time) AS id, c1, c2, c3, c4 @@ -61,47 +61,53 @@ FROM events; The Window clause is used to specify a computational range for window functions. It considers the current row and a specified number of rows before and after it as the target for the window function's operation. The methods supported by the Window clause include: AVG(), COUNT(), FIRST_VALUE(), LAST_VALUE(), and SUM(). For MAX() and MIN(), the Window clause can specify a starting range of UNBOUNDED PRECEDING. -``` +```sql ROWS BETWEEN [ { m | UNBOUNDED } PRECEDING | CURRENT ROW] [ AND [CURRENT ROW | { UNBOUNDED | n } FOLLOWING] ] ``` -#### Example +### Example Taking the following stock data as an example, the stock code is JDR, and the "closing price" refers to the daily closing quotation. -``` +```sql create table stock_ticker (stock_symbol string, closing_price decimal(8,2), closing_date timestamp); ...load some data... select * from stock_ticker order by stock_symbol, closing_date - | stock_symbol | closing_price | closing_date | - |--------------|---------------|---------------------| - | JDR | 12.86 | 2014-10-02 00:00:00 | - | JDR | 12.89 | 2014-10-03 00:00:00 | - | JDR | 12.94 | 2014-10-04 00:00:00 | - | JDR | 12.55 | 2014-10-05 00:00:00 | - | JDR | 14.03 | 2014-10-06 00:00:00 | - | JDR | 14.75 | 2014-10-07 00:00:00 | - | JDR | 13.98 | 2014-10-08 00:00:00 | ``` -This query utilizes a window function to generate the `moving_average `column, which calculates the average stock price over a three-day span, specifically the previous day, the current day, and the next day. Since there is no previous day's data for the first day and no next day's data for the last day, the average is only calculated based on two days for those rows. In this case, the `Partition By` clause is not relevant because all the data pertains to the stock JDR. However, if there [...] - +```text +| stock_symbol | closing_price | closing_date | +|--------------|---------------|---------------------| +| JDR | 12.86 | 2014-10-02 00:00:00 | +| JDR | 12.89 | 2014-10-03 00:00:00 | +| JDR | 12.94 | 2014-10-04 00:00:00 | +| JDR | 12.55 | 2014-10-05 00:00:00 | +| JDR | 14.03 | 2014-10-06 00:00:00 | +| JDR | 14.75 | 2014-10-07 00:00:00 | +| JDR | 13.98 | 2014-10-08 00:00:00 | ``` + +This query utilizes a window function to generate the `moving_average` column, which calculates the average stock price over a three-day span, specifically the previous day, the current day, and the next day. Since there is no previous day's data for the first day and no next day's data for the last day, the average is only calculated based on two days for those rows. In this case, the `Partition By` clause is not relevant because all the data pertains to the stock JDR. However, if there [...] + +```sql select stock_symbol, closing_date, closing_price, avg(closing_price) over (partition by stock_symbol order by closing_date rows between 1 preceding and 1 following) as moving_average from stock_ticker; - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | ``` -#### See more +```text +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +``` + +### See more -For more window functions, refer to [Window Functions](../../sql-manual/sql-functions/window-functions/WINDOW-FUNCTION). \ No newline at end of file +For more window functions, refer to [Window Functions](../../sql-manual/sql-functions/window-functions/WINDOW-FUNCTION) diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md b/versioned_docs/version-2.0/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md index 7a74fff7445..ebfdf282155 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md @@ -11,10 +11,9 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -## WINDOW FUNCTION -### description +## description -Analytical functions(windown function) are a special class of built-in functions. Similar to aggregate functions, analytic functions also perform calculations on multiple input rows to obtain a data value. The difference is that the analytic function processes the input data within a specific window, rather than grouping calculations by group by. The data within each window can be sorted and grouped using the over() clause. The analytic function computes a single value for each row of th [...] +[Analytical functions](../../../query/query-data/window-function)(windown function) are a special class of built-in functions. Similar to aggregate functions, analytic functions also perform calculations on multiple input rows to obtain a data value. The difference is that the analytic function processes the input data within a specific window, rather than grouping calculations by group by. The data within each window can be sorted and grouped using the over() clause. The analytic functi [...] The syntax of the analytic function: @@ -24,15 +23,15 @@ partition_by_clause ::= PARTITION BY expr [, expr ...] order_by_clause ::= ORDER BY expr [ASC | DESC] [, expr [ASC | DESC] ...] ``` -#### Function +### Function -Support Functions: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() +Support Functions: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() and all aggregate functions -#### PARTITION BY clause +### PARTITION BY clause The Partition By clause is similar to Group By. It groups the input rows according to the specified column or columns, and rows with the same value will be grouped together. -#### ORDER BY clause +### ORDER BY clause The Order By clause is basically the same as the outer Order By. It defines the order in which the input rows are sorted, and if Partition By is specified, Order By defines the order within each Partition grouping. The only difference from the outer Order By is that the Order By n (n is a positive integer) in the OVER clause is equivalent to doing nothing, while the outer Order By n means sorting according to the nth column. @@ -47,7 +46,7 @@ c1, c2, c3, c4 FROM events; ``` -#### Window clause +### Window clause The Window clause is used to specify an operation range for the analytical function, the current row is the criterion, and several rows before and after are used as the object of the analytical function operation. The methods supported by the Window clause are: AVG(), COUNT(), FIRST_VALUE(), LAST_VALUE() and SUM(). For MAX() and MIN(), the window clause can specify the starting range UNBOUNDED PRECEDING @@ -57,7 +56,7 @@ syntax: ROWS BETWEEN [ { m | UNBOUNDED } PRECEDING | CURRENT ROW] [ AND [CURRENT ROW | { UNBOUNDED | n } FOLLOWING] ] ``` -### example +### Example Suppose we have the following stock data, the stock symbol is JDR, and the closing price is the closing price of each day. @@ -94,6 +93,6 @@ from stock_ticker; | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | ``` -### keywords +### Keywords - WINDOW,FUNCTION +WINDOW, FUNCTION diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/window-functions/window-function.md b/versioned_docs/version-2.1/sql-manual/sql-functions/window-functions/overview.md similarity index 78% rename from versioned_docs/version-2.1/sql-manual/sql-functions/window-functions/window-function.md rename to versioned_docs/version-2.1/sql-manual/sql-functions/window-functions/overview.md index c12caa967bd..05351aa4233 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/window-functions/window-function.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/window-functions/overview.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION", + "title": "OVERVIEW", "language": "en" } --- @@ -13,7 +13,7 @@ Unless required by applicable law or agreed to in writing, software distributed ## Description -Window functions (also known as analytic functions) are special built-in functions that perform calculations while preserving the original rows. Unlike aggregate functions, window functions: +[Window functions](../../../query-data/window-function) (also known as analytic functions) are special built-in functions that perform calculations while preserving the original rows. Unlike aggregate functions, window functions: - Process data within a specific window range rather than by GROUP BY grouping - Calculate a value for each row in the result set @@ -37,7 +37,7 @@ function(<args>) OVER( | Parameter | Description | |-----------|-------------| | `<args>` | Input parameters for the window function, specific to the function being used | -| `<function>` | Supported functions include: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() | +| `<function>` | Supported functions include: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() and all aggregate functions | | `<partition_by>` | Similar to GROUP BY, groups data by specified columns | | `<order_by>` | Defines the ordering of data within the window | | `<window_clause>` | Defines the window range, syntax: ROWS BETWEEN [ { m \| UNBOUNDED } PRECEDING \| CURRENT ROW] [ AND [CURRENT ROW \| { UNBOUNDED \| n } FOLLOWING] ] | @@ -78,13 +78,13 @@ from stock_ticker; ``` ```text - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | -``` \ No newline at end of file +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/window-functions/window-function.md b/versioned_docs/version-3.0/sql-manual/sql-functions/window-functions/overview.md similarity index 78% rename from versioned_docs/version-3.0/sql-manual/sql-functions/window-functions/window-function.md rename to versioned_docs/version-3.0/sql-manual/sql-functions/window-functions/overview.md index c12caa967bd..05351aa4233 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/window-functions/window-function.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/window-functions/overview.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION", + "title": "OVERVIEW", "language": "en" } --- @@ -13,7 +13,7 @@ Unless required by applicable law or agreed to in writing, software distributed ## Description -Window functions (also known as analytic functions) are special built-in functions that perform calculations while preserving the original rows. Unlike aggregate functions, window functions: +[Window functions](../../../query-data/window-function) (also known as analytic functions) are special built-in functions that perform calculations while preserving the original rows. Unlike aggregate functions, window functions: - Process data within a specific window range rather than by GROUP BY grouping - Calculate a value for each row in the result set @@ -37,7 +37,7 @@ function(<args>) OVER( | Parameter | Description | |-----------|-------------| | `<args>` | Input parameters for the window function, specific to the function being used | -| `<function>` | Supported functions include: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() | +| `<function>` | Supported functions include: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM() and all aggregate functions | | `<partition_by>` | Similar to GROUP BY, groups data by specified columns | | `<order_by>` | Defines the ordering of data within the window | | `<window_clause>` | Defines the window range, syntax: ROWS BETWEEN [ { m \| UNBOUNDED } PRECEDING \| CURRENT ROW] [ AND [CURRENT ROW \| { UNBOUNDED \| n } FOLLOWING] ] | @@ -78,13 +78,13 @@ from stock_ticker; ``` ```text - | stock_symbol | closing_date | closing_price | moving_average | - |--------------|---------------------|---------------|----------------| - | JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | - | JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | - | JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | - | JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | - | JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | - | JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | - | JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | -``` \ No newline at end of file +| stock_symbol | closing_date | closing_price | moving_average | +|--------------|---------------------|---------------|----------------| +| JDR | 2014-10-02 00:00:00 | 12.86 | 12.87 | +| JDR | 2014-10-03 00:00:00 | 12.89 | 12.89 | +| JDR | 2014-10-04 00:00:00 | 12.94 | 12.79 | +| JDR | 2014-10-05 00:00:00 | 12.55 | 13.17 | +| JDR | 2014-10-06 00:00:00 | 14.03 | 13.77 | +| JDR | 2014-10-07 00:00:00 | 14.75 | 14.25 | +| JDR | 2014-10-08 00:00:00 | 13.98 | 14.36 | +``` diff --git a/versioned_sidebars/version-2.1-sidebars.json b/versioned_sidebars/version-2.1-sidebars.json index acd27452ee2..ee6784aa25f 100644 --- a/versioned_sidebars/version-2.1-sidebars.json +++ b/versioned_sidebars/version-2.1-sidebars.json @@ -1555,7 +1555,7 @@ "type": "category", "label": "Analytic (Window) Functions", "items": [ - "sql-manual/sql-functions/window-functions/window-function", + "sql-manual/sql-functions/window-functions/overview", "sql-manual/sql-functions/window-functions/rank", "sql-manual/sql-functions/window-functions/dense-rank", "sql-manual/sql-functions/window-functions/percent-rank", diff --git a/versioned_sidebars/version-3.0-sidebars.json b/versioned_sidebars/version-3.0-sidebars.json index dc99be50cf9..2f89b927d92 100644 --- a/versioned_sidebars/version-3.0-sidebars.json +++ b/versioned_sidebars/version-3.0-sidebars.json @@ -1623,7 +1623,7 @@ "type": "category", "label": "Analytic (Window) Functions", "items": [ - "sql-manual/sql-functions/window-functions/window-function", + "sql-manual/sql-functions/window-functions/overview", "sql-manual/sql-functions/window-functions/rank", "sql-manual/sql-functions/window-functions/dense-rank", "sql-manual/sql-functions/window-functions/percent-rank", --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org