This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 fc67e78916f [doc](window function)refactor doc of window (#2566)
fc67e78916f is described below
commit fc67e78916f4ce39f4cb81d7490cee005bd2aa8e
Author: zhangstar333 <[email protected]>
AuthorDate: Fri Jul 4 16:07:39 2025 +0800
[doc](window function)refactor doc of window (#2566)
## Versions
- [x] dev
- [ ] 3.0
- [ ] 2.1
- [ ] 2.0
---
docs/query-data/window-function.md | 121 +++++++---------
.../sql-functions/window-functions/any-value.md | 1 +
.../window-functions/approx-count-distinct.md | 1 +
.../sql-functions/window-functions/approx-top-k.md | 1 +
.../window-functions/approx-top-sum.md | 1 +
.../sql-functions/window-functions/array-agg.md | 1 +
.../sql-functions/window-functions/avg-weighted.md | 1 +
.../sql-functions/window-functions/avg.md | 1 +
.../sql-functions/window-functions/bitmap-agg.md | 1 +
.../window-functions/bitmap-intersect.md | 1 +
.../window-functions/bitmap-union-count.md | 1 +
.../window-functions/bitmap-union-int.md | 1 +
.../sql-functions/window-functions/bitmap-union.md | 1 +
.../sql-functions/window-functions/collect-list.md | 1 +
.../sql-functions/window-functions/collect-set.md | 1 +
.../sql-functions/window-functions/corr.md | 1 +
.../window-functions/count-by-enum.md | 1 +
.../sql-functions/window-functions/count.md | 1 +
.../sql-functions/window-functions/covar-samp.md | 1 +
.../sql-functions/window-functions/covar.md | 1 +
.../sql-functions/window-functions/first-value.md | 6 +-
.../window-functions/group-array-intersect.md | 1 +
.../window-functions/group-bit-and.md | 1 +
.../sql-functions/window-functions/group-bit-or.md | 1 +
.../window-functions/group-bit-xor.md | 1 +
.../window-functions/group-bitmap-xor.md | 1 +
.../sql-functions/window-functions/group-concat.md | 1 +
.../sql-functions/window-functions/grouping-id.md | 1 +
.../sql-functions/window-functions/grouping.md | 1 +
.../sql-functions/window-functions/histogram.md | 1 +
.../sql-functions/window-functions/hll-raw-agg.md | 1 +
.../window-functions/hll-union-agg.md | 1 +
.../window-functions/intersect-count.md | 1 +
.../sql-functions/window-functions/kurt.md | 1 +
.../sql-functions/window-functions/lag.md | 6 +-
.../sql-functions/window-functions/last-value.md | 6 +-
.../sql-functions/window-functions/lead.md | 6 +-
.../window-functions/linear-histogram.md | 1 +
.../sql-functions/window-functions/map-agg.md | 1 +
.../sql-functions/window-functions/max-by.md | 1 +
.../sql-functions/window-functions/max.md | 1 +
.../sql-functions/window-functions/median.md | 1 +
.../sql-functions/window-functions/min-by.md | 1 +
.../sql-functions/window-functions/min.md | 1 +
.../sql-functions/window-functions/nth-value.md | 4 +-
.../sql-functions/window-functions/overview.md | 143 +++++++++++++------
.../window-functions/percentile-approx.md | 1 +
.../window-functions/percentile-array.md | 1 +
.../sql-functions/window-functions/percentile.md | 1 +
.../window-functions/percentile_approx_weighted.md | 1 +
.../window-functions/quantile-union.md | 1 +
.../window-functions/regr-intercept.md | 1 +
.../sql-functions/window-functions/regr-slope.md | 1 +
.../window-functions/regr_intercept.md | 1 +
.../sql-functions/window-functions/regr_slope.md | 1 +
.../sql-functions/window-functions/retention.md | 1 +
.../window-functions/sequence-count.md | 1 +
.../window-functions/sequence-match.md | 1 +
.../sql-functions/window-functions/skew.md | 1 +
.../sql-functions/window-functions/stddev-samp.md | 1 +
.../sql-functions/window-functions/stddev.md | 1 +
.../sql-functions/window-functions/sum.md | 1 +
.../sql-functions/window-functions/sum0.md | 1 +
.../sql-functions/window-functions/topn-array.md | 1 +
.../window-functions/topn-weighted.md | 1 +
.../sql-functions/window-functions/topn.md | 1 +
.../sql-functions/window-functions/var-samp.md | 1 +
.../sql-functions/window-functions/variance.md | 1 +
.../window-functions/window-funnel.md | 1 +
.../current/query-data/window-function.md | 132 +++++++-----------
.../sql-functions/window-functions/any-value.md | 1 +
.../window-functions/approx-count-distinct.md | 1 +
.../sql-functions/window-functions/approx-top-k.md | 1 +
.../window-functions/approx-top-sum.md | 1 +
.../sql-functions/window-functions/array-agg.md | 1 +
.../sql-functions/window-functions/avg-weighted.md | 1 +
.../sql-functions/window-functions/avg.md | 1 +
.../sql-functions/window-functions/bitmap-agg.md | 1 +
.../window-functions/bitmap-intersect.md | 1 +
.../window-functions/bitmap-union-count.md | 1 +
.../window-functions/bitmap-union-int.md | 1 +
.../sql-functions/window-functions/bitmap-union.md | 1 +
.../sql-functions/window-functions/collect-list.md | 1 +
.../sql-functions/window-functions/collect-set.md | 1 +
.../sql-functions/window-functions/corr.md | 1 +
.../window-functions/count-by-enum.md | 1 +
.../sql-functions/window-functions/count.md | 1 +
.../sql-functions/window-functions/covar-samp.md | 1 +
.../sql-functions/window-functions/covar.md | 1 +
.../sql-functions/window-functions/cume-dist.md | 1 +
.../sql-functions/window-functions/dense-rank.md | 1 +
.../sql-functions/window-functions/first-value.md | 12 +-
.../window-functions/group-array-intersect.md | 1 +
.../window-functions/group-bit-and.md | 1 +
.../sql-functions/window-functions/group-bit-or.md | 1 +
.../window-functions/group-bit-xor.md | 1 +
.../window-functions/group-bitmap-xor.md | 1 +
.../sql-functions/window-functions/group-concat.md | 1 +
.../sql-functions/window-functions/grouping-id.md | 1 +
.../sql-functions/window-functions/grouping.md | 1 +
.../sql-functions/window-functions/histogram.md | 1 +
.../sql-functions/window-functions/hll-raw-agg.md | 1 +
.../window-functions/hll-union-agg.md | 1 +
.../window-functions/intersect-count.md | 1 +
.../sql-functions/window-functions/kurt.md | 1 +
.../sql-functions/window-functions/lag.md | 7 +-
.../sql-functions/window-functions/last-value.md | 6 +-
.../sql-functions/window-functions/lead.md | 7 +-
.../window-functions/linear-histogram.md | 1 +
.../sql-functions/window-functions/map-agg.md | 1 +
.../sql-functions/window-functions/max-by.md | 1 +
.../sql-functions/window-functions/max.md | 1 +
.../sql-functions/window-functions/median.md | 1 +
.../sql-functions/window-functions/min-by.md | 1 +
.../sql-functions/window-functions/min.md | 1 +
.../sql-functions/window-functions/nth-value.md | 4 +-
.../sql-functions/window-functions/ntile.md | 2 +
.../sql-functions/window-functions/overview.md | 152 +++++++++++++++------
.../sql-functions/window-functions/percent-rank.md | 2 +
.../window-functions/percentile-approx.md | 1 +
.../window-functions/percentile-array.md | 1 +
.../sql-functions/window-functions/percentile.md | 1 +
.../window-functions/percentile_approx_weighted.md | 1 +
.../window-functions/quantile-union.md | 1 +
.../sql-functions/window-functions/rank.md | 2 +
.../window-functions/regr-intercept.md | 1 +
.../sql-functions/window-functions/regr-slope.md | 1 +
.../window-functions/regr_intercept.md | 1 +
.../sql-functions/window-functions/regr_slope.md | 1 +
.../sql-functions/window-functions/retention.md | 1 +
.../sql-functions/window-functions/row-number.md | 2 +
.../window-functions/sequence-count.md | 1 +
.../window-functions/sequence-match.md | 1 +
.../sql-functions/window-functions/skew.md | 1 +
.../sql-functions/window-functions/stddev-samp.md | 1 +
.../sql-functions/window-functions/stddev.md | 1 +
.../sql-functions/window-functions/sum.md | 1 +
.../sql-functions/window-functions/sum0.md | 1 +
.../sql-functions/window-functions/topn-array.md | 1 +
.../window-functions/topn-weighted.md | 1 +
.../sql-functions/window-functions/topn.md | 1 +
.../sql-functions/window-functions/var-samp.md | 1 +
.../sql-functions/window-functions/variance.md | 1 +
.../window-functions/window-funnel.md | 1 +
sidebars.json | 12 +-
145 files changed, 488 insertions(+), 270 deletions(-)
diff --git a/docs/query-data/window-function.md
b/docs/query-data/window-function.md
index e0d0412a7e1..5689212b5cd 100644
--- a/docs/query-data/window-function.md
+++ b/docs/query-data/window-function.md
@@ -6,15 +6,17 @@
---
Analytic functions, also known as window functions, are functions in SQL
queries that perform complex calculations on rows in a data set. The
characteristic of window functions is that they do not reduce the number of
rows in the query result, but instead add a new computed result for each row.
Window functions are applicable to various analysis scenarios, such as
calculating running totals, rankings, and moving averages.
+The specific syntax can be
[refer](../sql-manual/sql-functions/window-functions/overview.md)
Below is an example of using a window function to calculate the three-day
moving average of sales for each store before and after a given date:
```sql
-CREATE TABLE daily_sales
-(store_id INT, sales_date DATE, sales_amount DECIMAL(10, 2))
-PROPERTIES (
- "replication_num" = "1"
-);
+CREATE TABLE daily_sales (
+ store_id INT,
+ sales_date DATE,
+ sales_amount DECIMAL(10, 2)
+) PROPERTIES ("replication_num" = "1");
+
INSERT INTO daily_sales (store_id, sales_date, sales_amount) VALUES (1,
'2023-01-01', 100.00), (1, '2023-01-02', 150.00), (1, '2023-01-03', 200.00),
(1, '2023-01-04', 250.00), (1, '2023-01-05', 300.00), (1, '2023-01-06',
350.00), (1, '2023-01-07', 400.00), (1, '2023-01-08', 450.00), (1,
'2023-01-09', 500.00), (2, '2023-01-01', 110.00), (2, '2023-01-02', 160.00),
(2, '2023-01-03', 210.00), (2, '2023-01-04', 260.00), (2, '2023-01-05',
310.00), (2, '2023-01-06', 360.00), (2, '2023-01-07', 4 [...]
SELECT
@@ -61,7 +63,7 @@ The query result is as follows:
The processing of queries using analytic functions can be divided into three
stages.
-1. Execute all joins, WHERE, GROUP BY, and HAVING clauses.
+1. Execute all JOIN, WHERE, GROUP BY, and HAVING clauses.
2. Provide the result set to the analytic functions and perform all necessary
calculations.
@@ -83,23 +85,23 @@ The term "partition" used in analytic functions is
unrelated to the table partit
### Window
-For each row in a partition, you can define a sliding data window. This window
determines the range of rows involved in performing calculations for the
current row. A window has a starting row and an ending row, and depending on
its definition, the window can slide at one or both ends. For example, for a
cumulative sum function, the starting row is fixed at the first row of its
partition, while the ending row slides from the start to the last row of the
partition. Conversely, for a movin [...]
+For each row in a partition, you can define a sliding data window. This window
determines the range of rows involved in performing calculations for the
current row. A window has a starting row and an ending row, and depending on
its definition, the window can slide at one or both ends. For example ROWS
BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, for a cumulative sum function, the
starting row is fixed at the first row of its partition, while the ending row
slides from the start to the l [...]
The size of the window can be set to be as large as all rows in the partition
or as small as a sliding window that only includes one row within the
partition. It should be noted that when the window is near the boundaries of
the partition, due to boundary restrictions, the range of calculations may be
reduced, and the function only returns the computed results of the available
rows.
-When using window functions, the current row is included in the calculation.
Therefore, when processing n items, it should be specified as (n-1). For
example, if you need to calculate a five-day average, the window should be
specified as "rows between 4 preceding and current row," which can also be
abbreviated as "rows 4 preceding."
+When using window functions, the current row is included in the calculation.
Therefore, when processing n items, it should be specified as (n-1). For
example, if you need to calculate a five-day average, the window should be
specified as "ROWS BETWEEN 4 PRECEDING AND CURRENT ROW," which can also be
abbreviated as "ROWS 4 PRECEDING."
### Current Row
Each calculation performed using analytic functions is based on the current
row within the partition. The current row serves as the reference point for
determining the start and end of the window, as illustrated below.
-For instance, a window can be used to define a centered moving average
calculation that includes the current row, the 6 rows before the current row,
and the 6 rows after the current row. This creates a sliding window containing
13 rows.
+For example ROWS BETWEEN 6 PRECEDING AND 6 FOLLOWING, a window can be used to
define a centered moving average calculation that includes the current row, the
6 rows before the current row, and the 6 rows after the current row. This
creates a sliding window containing 13 rows.

## Sorting Function
-In a sorting function, query results are deterministic only when the specified
sorting column is unique; if the sorting column contains duplicate values, the
query results may vary each time.
+In a sorting function, query results are deterministic only when the specified
sorting column is unique; if the sorting column contains duplicate values, the
query results may vary each time. The more functions can be
[refer](../sql-manual/sql-functions/window-functions/overview.md)
### NTILE Function
@@ -489,79 +491,60 @@ The query results are as follows:
8 rows in set (0.16 sec)
```
-## Unique Ordering for Analytic Function Data
-**1. Issue of Inconsistent Return Results**
+## Examples
-When the `ORDER BY` clause of a window function fails to produce a unique
ordering of the data, such as when the `ORDER BY` expression results in
duplicate values, the order of the rows becomes indeterminate. This means that
the return order of these rows may vary across multiple query executions,
leading to inconsistent results from the window function.
-
-The following example illustrates how the query returns different results on
successive runs. The inconsistency arises primarily because `ORDER BY dateid`
does not provide a unique ordering for the `SUM` window function.
+1. Assume we have the following stock data, with stock symbol JDR and daily
closing prices:
```sql
-CREATE TABLE test_window_order
- (item_id int,
- date_time date,
- sales double)
-distributed BY hash(item_id)
-properties("replication_num" = 1);
-
-INSERT INTO test_window_order VALUES
-(1, '2024-07-01', 100),
-(2, '2024-07-01', 100),
-(3, '2024-07-01', 140);
-
-SELECT
- item_id, date_time, sales,
- sum(sales) OVER (ORDER BY date_time ROWS BETWEEN
- UNBOUNDED PRECEDING AND CURRENT ROW) sum
-FROM
- test_window_order;
+create table stock_ticker (stock_symbol string, closing_price decimal(8,2),
closing_date timestamp);
+
+INSERT INTO stock_ticker VALUES
+ ("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")
+;
+
+select * from stock_ticker order by stock_symbol, closing_date
```
-Due to duplicate values in the sorting column `date_time`, the following two
query results may be observed:
-
-```sql
-+---------+------------+-------+------+
-| item_id | date_time | sales | sum |
-+---------+------------+-------+------+
-| 1 | 2024-07-01 | 100 | 100 |
-| 3 | 2024-07-01 | 140 | 240 |
-| 2 | 2024-07-01 | 100 | 340 |
-+---------+------------+-------+------+
-3 rows in set (0.03 sec)
+```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 |
```
-**2. Solution**
-
-To address this issue, you can add a unique value column, such as `item_id`,
to the `ORDER BY` clause to ensure the uniqueness of the ordering.
+2. This query uses an analytic function to generate a moving_average column,
which calculates the 3-day average stock price (previous day, current day, and
next day). The first day has no previous day value, and the last day has no
next day value, so these rows only calculate a two-day average. The Partition
By clause has no effect here since all data is for JDR, but if there were other
stock information, Partition By would ensure the analytic function only
operates within its own partition.
```sql
-SELECT
- item_id,
- date_time,
- sales,
- sum(sales) OVER (
- ORDER BY item_id,
- date_time ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum
-FROM
- test_window_order;
+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;
```
-This results in a consistent query output:
-
-```sql
-+---------+------------+-------+------+
-| item_id | date_time | sales | sum |
-+---------+------------+-------+------+
-| 1 | 2024-07-01 | 100 | 100 |
-| 2 | 2024-07-01 | 100 | 200 |
-| 3 | 2024-07-01 | 140 | 340 |
-+---------+------------+-------+------+
-3 rows in set (0.03 sec)
+```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 |
```
-For more information on analytic functions, refer to the Oracle official
documentation [SQL for Analysis and
Reporting](https://docs.oracle.com/en/database/oracle/oracle-database/23/dwhsg/sql-analysis-reporting-data-warehouses.html#GUID-20EFBF1E-F79D-4E4A-906C-6E496EECA684)
-
## Reference
The table creation statement used in the example is as follows:
diff --git a/docs/sql-manual/sql-functions/window-functions/any-value.md
b/docs/sql-manual/sql-functions/window-functions/any-value.md
new file mode 120000
index 00000000000..4103943db7c
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/any-value.md
@@ -0,0 +1 @@
+../aggregate-functions/any-value.md
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/window-functions/approx-count-distinct.md
b/docs/sql-manual/sql-functions/window-functions/approx-count-distinct.md
new file mode 120000
index 00000000000..3d741fcf642
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/approx-count-distinct.md
@@ -0,0 +1 @@
+../aggregate-functions/approx-count-distinct.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/approx-top-k.md
b/docs/sql-manual/sql-functions/window-functions/approx-top-k.md
new file mode 120000
index 00000000000..9dff71fbf54
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/approx-top-k.md
@@ -0,0 +1 @@
+../aggregate-functions/approx-top-k.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/approx-top-sum.md
b/docs/sql-manual/sql-functions/window-functions/approx-top-sum.md
new file mode 120000
index 00000000000..00dbd4bebd8
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/approx-top-sum.md
@@ -0,0 +1 @@
+../aggregate-functions/approx-top-sum.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/array-agg.md
b/docs/sql-manual/sql-functions/window-functions/array-agg.md
new file mode 120000
index 00000000000..700ff7c643f
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/array-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/array-agg.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/avg-weighted.md
b/docs/sql-manual/sql-functions/window-functions/avg-weighted.md
new file mode 120000
index 00000000000..c948744c8c8
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/avg-weighted.md
@@ -0,0 +1 @@
+../aggregate-functions/avg-weighted.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/avg.md
b/docs/sql-manual/sql-functions/window-functions/avg.md
new file mode 120000
index 00000000000..1c7aefeec8e
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/avg.md
@@ -0,0 +1 @@
+../aggregate-functions/avg.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/bitmap-agg.md
b/docs/sql-manual/sql-functions/window-functions/bitmap-agg.md
new file mode 120000
index 00000000000..ada6ce4cbd5
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/bitmap-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-agg.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/bitmap-intersect.md
b/docs/sql-manual/sql-functions/window-functions/bitmap-intersect.md
new file mode 120000
index 00000000000..c12fcadf265
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/bitmap-intersect.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-intersect.md
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/window-functions/bitmap-union-count.md
b/docs/sql-manual/sql-functions/window-functions/bitmap-union-count.md
new file mode 120000
index 00000000000..19049af5c4f
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/bitmap-union-count.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-union-count.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/bitmap-union-int.md
b/docs/sql-manual/sql-functions/window-functions/bitmap-union-int.md
new file mode 120000
index 00000000000..5dedfc7227e
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/bitmap-union-int.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-union-int.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/bitmap-union.md
b/docs/sql-manual/sql-functions/window-functions/bitmap-union.md
new file mode 120000
index 00000000000..39a0562d78a
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/bitmap-union.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-union.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/collect-list.md
b/docs/sql-manual/sql-functions/window-functions/collect-list.md
new file mode 120000
index 00000000000..64030cc4e32
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/collect-list.md
@@ -0,0 +1 @@
+../aggregate-functions/collect-list.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/collect-set.md
b/docs/sql-manual/sql-functions/window-functions/collect-set.md
new file mode 120000
index 00000000000..ced8dce6d14
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/collect-set.md
@@ -0,0 +1 @@
+../aggregate-functions/collect-set.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/corr.md
b/docs/sql-manual/sql-functions/window-functions/corr.md
new file mode 120000
index 00000000000..e684a9eeed1
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/corr.md
@@ -0,0 +1 @@
+../aggregate-functions/corr.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/count-by-enum.md
b/docs/sql-manual/sql-functions/window-functions/count-by-enum.md
new file mode 120000
index 00000000000..5c0eda56ad5
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/count-by-enum.md
@@ -0,0 +1 @@
+../aggregate-functions/count-by-enum.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/count.md
b/docs/sql-manual/sql-functions/window-functions/count.md
new file mode 120000
index 00000000000..118dc2b9746
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/count.md
@@ -0,0 +1 @@
+../aggregate-functions/count.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/covar-samp.md
b/docs/sql-manual/sql-functions/window-functions/covar-samp.md
new file mode 120000
index 00000000000..c1c033b4a61
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/covar-samp.md
@@ -0,0 +1 @@
+../aggregate-functions/covar-samp.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/covar.md
b/docs/sql-manual/sql-functions/window-functions/covar.md
new file mode 120000
index 00000000000..07fa3e05b1e
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/covar.md
@@ -0,0 +1 @@
+../aggregate-functions/covar.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/first-value.md
b/docs/sql-manual/sql-functions/window-functions/first-value.md
index 1d21825b54e..f8a4795ae30 100644
--- a/docs/sql-manual/sql-functions/window-functions/first-value.md
+++ b/docs/sql-manual/sql-functions/window-functions/first-value.md
@@ -7,7 +7,7 @@
## Description
-FIRST_VALUE() is a window function that returns the first value in an ordered
set of values within a window partition. The handling of null values can be
controlled using the IGNORE NULLS options.
+FIRST_VALUE() is a window function that returns the first value in an ordered
set of values within a window partition. The handling of null values can be
controlled using the IGNORE NULL options.
## Syntax
@@ -18,8 +18,8 @@ FIRST_VALUE(expr[, ignore_null])
## Parameters
| Parameter | Description
|
| ------------------- |
-------------------------------------------------------------------------------------------------------------------
|
-| expr | The expression from which to get the first value
|
-| ignore_null | Optional. When set, null values are ignored, returning
the first non-null value |
+| expr | The expression from which to get the first
value,supported:
tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/array/struct/map/bitmap
|
+| ignore_null | Optional boolean Type. When set, null values are
ignored, returning the first non-null value
|
## Return Value
diff --git
a/docs/sql-manual/sql-functions/window-functions/group-array-intersect.md
b/docs/sql-manual/sql-functions/window-functions/group-array-intersect.md
new file mode 120000
index 00000000000..a8bfeebbdb1
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/group-array-intersect.md
@@ -0,0 +1 @@
+../aggregate-functions/group-array-intersect.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/group-bit-and.md
b/docs/sql-manual/sql-functions/window-functions/group-bit-and.md
new file mode 120000
index 00000000000..e44111f2fba
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/group-bit-and.md
@@ -0,0 +1 @@
+../aggregate-functions/group-bit-and.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/group-bit-or.md
b/docs/sql-manual/sql-functions/window-functions/group-bit-or.md
new file mode 120000
index 00000000000..3262a959c6b
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/group-bit-or.md
@@ -0,0 +1 @@
+../aggregate-functions/group-bit-or.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/group-bit-xor.md
b/docs/sql-manual/sql-functions/window-functions/group-bit-xor.md
new file mode 120000
index 00000000000..bd86f034822
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/group-bit-xor.md
@@ -0,0 +1 @@
+../aggregate-functions/group-bit-xor.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/group-bitmap-xor.md
b/docs/sql-manual/sql-functions/window-functions/group-bitmap-xor.md
new file mode 120000
index 00000000000..b0ab9c0118e
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/group-bitmap-xor.md
@@ -0,0 +1 @@
+../aggregate-functions/group-bitmap-xor.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/group-concat.md
b/docs/sql-manual/sql-functions/window-functions/group-concat.md
new file mode 120000
index 00000000000..47517568f8b
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/group-concat.md
@@ -0,0 +1 @@
+../aggregate-functions/group-concat.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/grouping-id.md
b/docs/sql-manual/sql-functions/window-functions/grouping-id.md
new file mode 120000
index 00000000000..8caf06c2b1b
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/grouping-id.md
@@ -0,0 +1 @@
+../aggregate-functions/grouping-id.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/grouping.md
b/docs/sql-manual/sql-functions/window-functions/grouping.md
new file mode 120000
index 00000000000..13f73128503
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/grouping.md
@@ -0,0 +1 @@
+../aggregate-functions/grouping.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/histogram.md
b/docs/sql-manual/sql-functions/window-functions/histogram.md
new file mode 120000
index 00000000000..aa6cc9dc4e3
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/histogram.md
@@ -0,0 +1 @@
+../aggregate-functions/histogram.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/hll-raw-agg.md
b/docs/sql-manual/sql-functions/window-functions/hll-raw-agg.md
new file mode 120000
index 00000000000..fdad6cae306
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/hll-raw-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/hll-raw-agg.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/hll-union-agg.md
b/docs/sql-manual/sql-functions/window-functions/hll-union-agg.md
new file mode 120000
index 00000000000..460811203ee
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/hll-union-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/hll-union-agg.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/intersect-count.md
b/docs/sql-manual/sql-functions/window-functions/intersect-count.md
new file mode 120000
index 00000000000..16823248f72
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/intersect-count.md
@@ -0,0 +1 @@
+../aggregate-functions/intersect-count.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/kurt.md
b/docs/sql-manual/sql-functions/window-functions/kurt.md
new file mode 120000
index 00000000000..a23aa42c05a
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/kurt.md
@@ -0,0 +1 @@
+../aggregate-functions/kurt.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/lag.md
b/docs/sql-manual/sql-functions/window-functions/lag.md
index d47f2d684a9..b91fe4d326e 100644
--- a/docs/sql-manual/sql-functions/window-functions/lag.md
+++ b/docs/sql-manual/sql-functions/window-functions/lag.md
@@ -18,9 +18,9 @@ LAG ( <expr> [, <offset> [, <default> ] ] )
## Parameters
| Parameter | Description
|
| ------------------- |
--------------------------------------------------------------------------------------------------
|
-| expr | The expression whose value is to be retrieved
|
-| offset | Optional. Number of rows to look ahead. Default is 1. |
-| default | Optional. Value to return when the offset goes beyond
window bounds. Default is NULL |
+| expr | The expression whose value is to be retrieved,
supported type:
tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/
|
+| offset | Optional Bigint Type. Number of rows to look ahead.
Default is 1. |
+| default | Optional Type is same as first param. Value to return
when the offset goes beyond window bounds. Default is NULL |
## Return Value
diff --git a/docs/sql-manual/sql-functions/window-functions/last-value.md
b/docs/sql-manual/sql-functions/window-functions/last-value.md
index c97e7fcce2a..3599e3b201f 100644
--- a/docs/sql-manual/sql-functions/window-functions/last-value.md
+++ b/docs/sql-manual/sql-functions/window-functions/last-value.md
@@ -7,7 +7,7 @@
## Description
-LAST_VALUE() is a window function that returns the last value within the
window frame. The handling of null values can be controlled using the IGNORE
NULLS options.
+LAST_VALUE() is a window function that returns the last value within the
window frame. The handling of null values can be controlled using the IGNORE
NULL options.
## Syntax
@@ -18,8 +18,8 @@ LAST_VALUE(<expr>[, <ignore_null>])
## Parameters
| Parameter | Description
|
| ------------------- |
-----------------------------------------------------------------------------------------------------------
|
-| expr | The expression from which to get the last value
|
-| ignore_null | Optional. When set, null values are ignored, returning
the last non-null value |
+| expr | The expression from which to get the last
value,supported:
tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/array/struct/map/bitmap
|
+| ignore_null | Optional Boolean Type. When set, null values are
ignored, returning the last non-null value |
## Return Value
diff --git a/docs/sql-manual/sql-functions/window-functions/lead.md
b/docs/sql-manual/sql-functions/window-functions/lead.md
index f5ccf79471c..cfb9efa690b 100644
--- a/docs/sql-manual/sql-functions/window-functions/lead.md
+++ b/docs/sql-manual/sql-functions/window-functions/lead.md
@@ -18,9 +18,9 @@ LEAD ( <expr> [ , <offset> [ , <default> ] ] )
## Parameters
| Parameter | Description
|
| ------------------- |
---------------------------------------------------------------------------------------------------------------------------------------------------------
|
-| expr | The expression whose value needs to be retrieved
|
-| offset | Optional. Number of rows to look backward. Default is
1. |
-| default | Optional. Default value to return when the offset goes
beyond the window range. Default is NULL
|
+| expr | The expression whose value needs to be retrieved,
supported type:
tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/
|
+| offset | Optional bigInt type. Number of rows to look backward.
Default is 1. |
+| default | Optional type is same as first param. Default value to
return when the offset goes beyond the window range. Default is NULL
|
## Return Value
diff --git a/docs/sql-manual/sql-functions/window-functions/linear-histogram.md
b/docs/sql-manual/sql-functions/window-functions/linear-histogram.md
new file mode 120000
index 00000000000..71c1a5c530c
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/linear-histogram.md
@@ -0,0 +1 @@
+../aggregate-functions/linear-histogram.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/map-agg.md
b/docs/sql-manual/sql-functions/window-functions/map-agg.md
new file mode 120000
index 00000000000..a195dee8c75
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/map-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/map-agg.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/max-by.md
b/docs/sql-manual/sql-functions/window-functions/max-by.md
new file mode 120000
index 00000000000..5a96ae85219
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/max-by.md
@@ -0,0 +1 @@
+../aggregate-functions/max-by.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/max.md
b/docs/sql-manual/sql-functions/window-functions/max.md
new file mode 120000
index 00000000000..70aa0f54722
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/max.md
@@ -0,0 +1 @@
+../aggregate-functions/max.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/median.md
b/docs/sql-manual/sql-functions/window-functions/median.md
new file mode 120000
index 00000000000..b3113a98806
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/median.md
@@ -0,0 +1 @@
+../aggregate-functions/median.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/min-by.md
b/docs/sql-manual/sql-functions/window-functions/min-by.md
new file mode 120000
index 00000000000..6ef66ef549f
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/min-by.md
@@ -0,0 +1 @@
+../aggregate-functions/min-by.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/min.md
b/docs/sql-manual/sql-functions/window-functions/min.md
new file mode 120000
index 00000000000..42f38a3f3d9
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/min.md
@@ -0,0 +1 @@
+../aggregate-functions/min.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/nth-value.md
b/docs/sql-manual/sql-functions/window-functions/nth-value.md
index 3eebafeddb2..4536c14bfbc 100644
--- a/docs/sql-manual/sql-functions/window-functions/nth-value.md
+++ b/docs/sql-manual/sql-functions/window-functions/nth-value.md
@@ -18,8 +18,8 @@ NTH_VALUE(<expr>, <offset>)
## Parameters
| Parameter | Description
|
| ------------------- |
-------------------------------------------------------------------------------------------------------------------
|
-| expr | The expression from which will get the value value
|
-| offset | The parameter offset must be a positive integer greater
than 0, indicating the Nth element value to retrieve, with the starting index
at 1. |
+| expr | The expression from which will get the value
value,supported:
tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/array/struct/map/bitmap
|
+| offset | Bigint type and The parameter offset must be a positive
integer greater than 0, indicating the Nth element value to retrieve, with the
starting index at 1. |
## Return Value
diff --git a/docs/sql-manual/sql-functions/window-functions/overview.md
b/docs/sql-manual/sql-functions/window-functions/overview.md
index f21b56339a9..304d809b90b 100644
--- a/docs/sql-manual/sql-functions/window-functions/overview.md
+++ b/docs/sql-manual/sql-functions/window-functions/overview.md
@@ -19,66 +19,125 @@ Window functions are commonly used in financial and
scientific computing for tre
## Syntax
```sql
-function(<args>) OVER(
- [PARTITION BY <expr> [, <expr> ...]]
- [ORDER BY <expr> [ASC | DESC] [, <expr> [ASC | DESC] ...]]
- [<window_clause>]
-)
+<FUNCTION> ( [ <ARGUMENTS> ] ) OVER ( [ <windowDefinition> ] )
+```
+
+And:
+```sql
+windowDefinition ::=
+
+[ PARTITION BY <expr1> [, ...] ]
+[ ORDER BY <expr2> [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ]
+[ <windowFrameClause> ]
+```
+
+And:
+```sql
+windowFrameClause ::=
+{
+ | { ROWS } <n> PRECEDING
+ | { ROWS } CURRENT ROW
+ | { ROWS } BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ | { ROWS | RANGE } UNBOUNDED PRECEDING
+ | { ROWS | RANGE } BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ | { ROWS | RANGE } BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ | { ROWS } BETWEEN <n> { PRECEDING | FOLLOWING } AND <n> { PRECEDING |
FOLLOWING }
+ | { ROWS } BETWEEN UNBOUNDED PRECEDING AND <n> { PRECEDING | FOLLOWING }
+ | { ROWS } BETWEEN <n> { PRECEDING | FOLLOWING } AND UNBOUNDED FOLLOWING
+}
```
## Parameters
-| 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(), NTH_VALUE() 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] ] |
+`<FUNCTION>`
+> The name of the window function. Includes all aggregate functions plus
special window functions: DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(),
LEAD(), RANK(), ROW_NUMBER(), NTH_VALUE(), PERCENT_RANK(), CUME_DIST(), NTILE().
+
+`<ARGUMENTS>`
+> Optional. The input arguments for the window function. The argument types
and quantity depend on the specific function being used.
+
+`<PARTITION_BY>`
+> Optional. Similar to GROUP BY, it groups data by specified columns, then
performs calculations within each partition.
+
+`<ORDER_BY>`
+> Optional. Used to sort data within each partition. If no partition is
specified, it will sort the entire dataset. However, this `ORDER BY` is
different from the common `ORDER BY` that appears at the end of an SQL
statement. The sorting specified in the `OVER` clause only applies to the data
within that partition, whereas the `ORDER BY` at the end of an SQL statement
controls the order of all rows in the final query results. These two can
coexist.
+> Additionally, if `ORDER BY` is not explicitly specified in the `OVER`
clause, the data within the partition may be random, potentially leading to
unpredictable final results. If sorting columns are explicitly provided but
contain duplicate values, the results may still be unstable. For specific
examples, refer to the [case study](#section1) below.
+
+`<windowFrameClause>`
+> Optional. Used to define the window frame. Currently, two types are
supported: `RANGE` and `ROWS`.
+> For `N PRECEDING/FOLLOWING`, where `N` is a positive integer, it represents
the sliding window range relative to the current row. Currently, this is only
supported in `ROWS` windows, so it indicates a physical offset relative to the
current row. The `RANGE` type currently has some limitations: it must be either
`BOTH UNBOUNDED BOUNDARY` or `ONE UNBOUNDED BOUNDARY AND ONE CURRENT ROW`. If
no frame is specified, the default implicit frame is `RANGE BETWEEN UNBOUNDED
PRECEDING AND CURRENT ROW`.
## Return Value
Returns the same data type as the input expression.
-## Examples
+<a id="section1"></a>
+## Unique Ordering for Analytic Function Data
+
+**1. Issue of Inconsistent Return Results**
+
+When the `ORDER BY` clause of a window function fails to produce a unique
ordering of the data, such as when the `ORDER BY` expression results in
duplicate values, the order of the rows becomes indeterminate. This means that
the return order of these rows may vary across multiple query executions,
leading to inconsistent results from the window function.
-1. Assume we have the following stock data, with stock symbol JDR and daily
closing prices:
+The following example illustrates how the query returns different results on
successive runs. The inconsistency arises primarily because `ORDER BY dateid`
does not provide a unique ordering for the `SUM` window function.
```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
+CREATE TABLE test_window_order
+ (item_id int,
+ date_time date,
+ sales double)
+distributed BY hash(item_id)
+properties("replication_num" = 1);
+
+INSERT INTO test_window_order VALUES
+(1, '2024-07-01', 100),
+(2, '2024-07-01', 100),
+(3, '2024-07-01', 140);
+
+SELECT
+ item_id, date_time, sales,
+ sum(sales) OVER (ORDER BY date_time ROWS BETWEEN
+ UNBOUNDED PRECEDING AND CURRENT ROW) sum
+FROM
+ test_window_order;
```
-```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 |
+Due to duplicate values in the sorting column `date_time`, the following two
query results may be observed:
+
+```sql
++---------+------------+-------+------+
+| item_id | date_time | sales | sum |
++---------+------------+-------+------+
+| 1 | 2024-07-01 | 100 | 100 |
+| 3 | 2024-07-01 | 140 | 240 |
+| 2 | 2024-07-01 | 100 | 340 |
++---------+------------+-------+------+
+3 rows in set (0.03 sec)
```
-2. This query uses an analytic function to generate a moving_average column,
which calculates the 3-day average stock price (previous day, current day, and
next day). The first day has no previous day value, and the last day has no
next day value, so these rows only calculate a two-day average. The Partition
By clause has no effect here since all data is for JDR, but if there were other
stock information, Partition By would ensure the analytic function only
operates within its own partition.
+**2. Solution**
+
+To address this issue, you can add a unique value column, such as `item_id`,
to the `ORDER BY` clause to ensure the uniqueness of the ordering.
```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;
+SELECT
+ item_id,
+ date_time,
+ sales,
+ sum(sales) OVER (
+ ORDER BY item_id,
+ date_time ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum
+FROM
+ test_window_order;
```
-```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 |
+This results in a consistent query output:
+
+```sql
++---------+------------+-------+------+
+| item_id | date_time | sales | sum |
++---------+------------+-------+------+
+| 1 | 2024-07-01 | 100 | 100 |
+| 2 | 2024-07-01 | 100 | 200 |
+| 3 | 2024-07-01 | 140 | 340 |
++---------+------------+-------+------+
+3 rows in set (0.03 sec)
```
diff --git
a/docs/sql-manual/sql-functions/window-functions/percentile-approx.md
b/docs/sql-manual/sql-functions/window-functions/percentile-approx.md
new file mode 120000
index 00000000000..a4ad830ebb9
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/percentile-approx.md
@@ -0,0 +1 @@
+../aggregate-functions/percentile-approx.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/percentile-array.md
b/docs/sql-manual/sql-functions/window-functions/percentile-array.md
new file mode 120000
index 00000000000..62088376770
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/percentile-array.md
@@ -0,0 +1 @@
+../aggregate-functions/percentile-array.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/percentile.md
b/docs/sql-manual/sql-functions/window-functions/percentile.md
new file mode 120000
index 00000000000..4744359c30b
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/percentile.md
@@ -0,0 +1 @@
+../aggregate-functions/percentile.md
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/window-functions/percentile_approx_weighted.md
b/docs/sql-manual/sql-functions/window-functions/percentile_approx_weighted.md
new file mode 120000
index 00000000000..e5e294e625b
--- /dev/null
+++
b/docs/sql-manual/sql-functions/window-functions/percentile_approx_weighted.md
@@ -0,0 +1 @@
+../aggregate-functions/percentile_approx_weighted.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/quantile-union.md
b/docs/sql-manual/sql-functions/window-functions/quantile-union.md
new file mode 120000
index 00000000000..19bebc142b6
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/quantile-union.md
@@ -0,0 +1 @@
+../aggregate-functions/quantile-union.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/regr-intercept.md
b/docs/sql-manual/sql-functions/window-functions/regr-intercept.md
new file mode 120000
index 00000000000..857a57a38f8
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/regr-intercept.md
@@ -0,0 +1 @@
+../aggregate-functions/regr-intercept.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/regr-slope.md
b/docs/sql-manual/sql-functions/window-functions/regr-slope.md
new file mode 120000
index 00000000000..ba882fcd44e
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/regr-slope.md
@@ -0,0 +1 @@
+../aggregate-functions/regr-slope.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/regr_intercept.md
b/docs/sql-manual/sql-functions/window-functions/regr_intercept.md
new file mode 120000
index 00000000000..36b6a9d226d
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/regr_intercept.md
@@ -0,0 +1 @@
+../aggregate-functions/regr_intercept.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/regr_slope.md
b/docs/sql-manual/sql-functions/window-functions/regr_slope.md
new file mode 120000
index 00000000000..bc5d9c64cf4
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/regr_slope.md
@@ -0,0 +1 @@
+../aggregate-functions/regr_slope.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/retention.md
b/docs/sql-manual/sql-functions/window-functions/retention.md
new file mode 120000
index 00000000000..90924e30f52
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/retention.md
@@ -0,0 +1 @@
+../aggregate-functions/retention.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/sequence-count.md
b/docs/sql-manual/sql-functions/window-functions/sequence-count.md
new file mode 120000
index 00000000000..cf625afe6d7
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/sequence-count.md
@@ -0,0 +1 @@
+../aggregate-functions/sequence-count.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/sequence-match.md
b/docs/sql-manual/sql-functions/window-functions/sequence-match.md
new file mode 120000
index 00000000000..576a1bd745a
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/sequence-match.md
@@ -0,0 +1 @@
+../aggregate-functions/sequence-match.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/skew.md
b/docs/sql-manual/sql-functions/window-functions/skew.md
new file mode 120000
index 00000000000..1cf20c294f0
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/skew.md
@@ -0,0 +1 @@
+../aggregate-functions/skew.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/stddev-samp.md
b/docs/sql-manual/sql-functions/window-functions/stddev-samp.md
new file mode 120000
index 00000000000..8e801372498
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/stddev-samp.md
@@ -0,0 +1 @@
+../aggregate-functions/stddev-samp.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/stddev.md
b/docs/sql-manual/sql-functions/window-functions/stddev.md
new file mode 120000
index 00000000000..8dfddbc2328
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/stddev.md
@@ -0,0 +1 @@
+../aggregate-functions/stddev.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/sum.md
b/docs/sql-manual/sql-functions/window-functions/sum.md
new file mode 120000
index 00000000000..2afe4c1185e
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/sum.md
@@ -0,0 +1 @@
+../aggregate-functions/sum.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/sum0.md
b/docs/sql-manual/sql-functions/window-functions/sum0.md
new file mode 120000
index 00000000000..bc67df7083e
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/sum0.md
@@ -0,0 +1 @@
+../aggregate-functions/sum0.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/topn-array.md
b/docs/sql-manual/sql-functions/window-functions/topn-array.md
new file mode 120000
index 00000000000..02bec6851e9
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/topn-array.md
@@ -0,0 +1 @@
+../aggregate-functions/topn-array.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/topn-weighted.md
b/docs/sql-manual/sql-functions/window-functions/topn-weighted.md
new file mode 120000
index 00000000000..ae383927255
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/topn-weighted.md
@@ -0,0 +1 @@
+../aggregate-functions/topn-weighted.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/topn.md
b/docs/sql-manual/sql-functions/window-functions/topn.md
new file mode 120000
index 00000000000..d3bf7036a99
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/topn.md
@@ -0,0 +1 @@
+../aggregate-functions/topn.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/var-samp.md
b/docs/sql-manual/sql-functions/window-functions/var-samp.md
new file mode 120000
index 00000000000..bd32134e30e
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/var-samp.md
@@ -0,0 +1 @@
+../aggregate-functions/var-samp.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/variance.md
b/docs/sql-manual/sql-functions/window-functions/variance.md
new file mode 120000
index 00000000000..0dd8d4f8705
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/variance.md
@@ -0,0 +1 @@
+../aggregate-functions/variance.md
\ No newline at end of file
diff --git a/docs/sql-manual/sql-functions/window-functions/window-funnel.md
b/docs/sql-manual/sql-functions/window-functions/window-funnel.md
new file mode 120000
index 00000000000..d4de6f93304
--- /dev/null
+++ b/docs/sql-manual/sql-functions/window-functions/window-funnel.md
@@ -0,0 +1 @@
+../aggregate-functions/window-funnel.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/window-function.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/window-function.md
index 48633e71fd0..5de15eb9b9f 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/window-function.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/window-function.md
@@ -6,15 +6,17 @@
---
分析函数,也称为窗口函数,是一种在 SQL
查询中对数据集中的行进行复杂计算的函数。窗口函数的特点在于,它们不会减少查询结果的行数,而是为每一行增加一个新的计算结果。窗口函数适用于多种分析场景,如计算滚动合计、排名以及移动平均等。
+具体的语法介绍可以[参阅](../../current/sql-manual/sql-functions/window-functions/overview.md)
下面是一个使用窗口函数计算每个商店的前后三天的销售移动平均值的例子:
```sql
-CREATE TABLE daily_sales
-(store_id INT, sales_date DATE, sales_amount DECIMAL(10, 2))
-PROPERTIES (
- "replication_num" = "1"
-);
+CREATE TABLE daily_sales (
+ store_id INT,
+ sales_date DATE,
+ sales_amount DECIMAL(10, 2)
+) PROPERTIES ("replication_num" = "1");
+
INSERT INTO daily_sales (store_id, sales_date, sales_amount) VALUES (1,
'2023-01-01', 100.00), (1, '2023-01-02', 150.00), (1, '2023-01-03', 200.00),
(1, '2023-01-04', 250.00), (1, '2023-01-05', 300.00), (1, '2023-01-06',
350.00), (1, '2023-01-07', 400.00), (1, '2023-01-08', 450.00), (1,
'2023-01-09', 500.00), (2, '2023-01-01', 110.00), (2, '2023-01-02', 160.00),
(2, '2023-01-03', 210.00), (2, '2023-01-04', 260.00), (2, '2023-01-05',
310.00), (2, '2023-01-06', 360.00), (2, '2023-01-07', 4 [...]
SELECT
@@ -61,7 +63,7 @@ FROM
使用分析函数的查询处理可以分为三个阶段。
-1. 执行所有的连接、WHERE、GROUP BY 和 HAVING 子句。
+1. 执行所有的JOIN、WHERE、GROUP BY 和 HAVING 子句。
2. 将结果集提供给分析函数,并进行所有必要的计算。
@@ -73,7 +75,7 @@ FROM
### 结果集分区
-分区是在使用 PARTITION BY 子句定义的组之后创建的。分析函数允许用户将查询结果集划分为称为分区的行组。
+分区是在使用 PARTITION BY 子句定义的组之后创建的。
:::caution 注意
分析函数中使用的术语“分区”与表分区功能无关。在本章中,术语“分区”仅指与分析函数相关的含义。
@@ -81,23 +83,23 @@ FROM
### 窗口
-对于分区中的每一行,你可以定义一个滑动数据窗口。此窗口确定了用于执行当前行计算所涉及的行范围。窗口具有一个起始行和一个结束行,根据其定义,窗口可以在一端或两端进行滑动。例如,为累积和函数定义的窗口,其起始行固定在其分区的第一行,而其结束行则从起点一直滑动到分区的最后一行。相反,为移动平均值定义的窗口,其起点和终点都会进行滑动。
+对于分区中的每一行,你可以定义一个滑动数据窗口,此窗口确定了用于执行当前行计算所涉及的行范围。窗口具有一个起始行和一个结束行,根据其定义,窗口可以在一端或两端进行滑动。例如ROWS
BETWEEN UNBOUNDED PRECEDING AND CURRENT
ROW,为累积和函数定义的窗口,其起始行固定在其分区的第一行,而其结束行则从起点一直滑动到分区的最后一行。相反ROWS BETWEEN 3 PRECEDING
AND 3 FOLLOWING,为移动平均值定义的窗口,其起点和终点都会进行滑动。
窗口的大小可以设置为与分区中的所有行一样大,也可以设置为在分区内仅包含一行的滑动窗口。需要注意的是,当窗口靠近分区的边界时,由于边界的限制,计算的范围可能会缩减行数,此时函数仅返回可用行的计算结果。
-在使用窗口函数时,当前行会被包含在计算之中。因此,在处理 n 个项目时,应指定为 (n-1)。例如,如果您需要计算五天的平均值,窗口应指定为“rows
between 4 preceding and current row”,这也可以简写为“rows 4 preceding”。
+在使用窗口函数时,当前行会被包含在计算之中。因此,在处理 n 个项目时,应指定为 (n-1)。例如,如果您需要计算五天的平均值,窗口应指定为“ROWS
BETWEEN 4 PRECEDING AND CURRENT ROW”,这也可以简写为“ROWS 4 PRECEDING”。
### 当前行
使用分析函数执行的每个计算都是基于分区内的当前行。当前行作为确定窗口开始和结束的参考点,具体如图所示。
-例如,可以使用一个窗口来定义中心移动平均值计算,该窗口包含当前行、当前行之前的 6 行以及当前行之后的 6 行。这样就创建了一个包含 13 行的滑动窗口。
+例如: ROWS BETWEEN 6 PRECEDING AND 6
FOLLOWING,可以使用一个窗口来定义中心移动平均值计算,该窗口包含当前行、当前行之前的 6 行以及当前行之后的 6 行。这样就创建了一个包含 13
行的滑动窗口。

## 排序函数
-排序函数中,只有当指定的排序列是唯一值列时,查询结果才是确定的;如果排序列包含重复值,则每次的查询结果可能不同。
+排序函数中,只有当指定的排序列是唯一值列时,查询结果才是确定的;如果排序列包含重复值,则每次的查询结果可能不同。更多相关函数可以[参阅](../../current/sql-manual/sql-functions/window-functions/overview.md)
### NTILE 函数
@@ -473,87 +475,57 @@ where year in (1999, 2000, 2001, 2002)
8 rows in set (0.16 sec)
```
-## 分析函数数据的唯一排序
-
-**1. 存在返回结果不一致的问题**
-
-当使用窗口函数的 `ORDER BY` 子句未能产生数据的唯一排序时,例如当 `ORDER BY`
表达式导致重复值时,行的顺序会变得不确定。这意味着在多次执行查询时,这些行的返回顺序可能会有所不同,进而导致窗口函数返回不一致的结果。
-
-通过以下示例可以看出,该查询在多次运行时返回了不同的结果。出现不一致性的情况主要由于 `ORDER BY dateid` 没有为 `SUM`
窗口函数提供产生数据的唯一排序。
+1. 假设我们有如下的股票数据,股票代码是 JDR,closing price 是每天的收盘价。
```sql
-CREATE TABLE test_window_order
- (item_id int,
- date_time date,
- sales double)
-distributed BY hash(item_id)
-properties("replication_num" = 1);
-
-INSERT INTO test_window_order VALUES
-(1, '2024-07-01', 100),
-(2, '2024-07-01', 100),
-(3, '2024-07-01', 140);
-
-SELECT
- item_id, date_time, sales,
- sum(sales) OVER (ORDER BY date_time ROWS BETWEEN
- UNBOUNDED PRECEDING AND CURRENT ROW) sum
-FROM
- test_window_order;
+create table stock_ticker (stock_symbol string, closing_price decimal(8,2),
closing_date timestamp);
+
+INSERT INTO stock_ticker VALUES
+ ("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")
+;
+
+select * from stock_ticker order by stock_symbol, closing_date
```
-由于排序列 `date_time`存在重复值,可能呈现以下两种查询结果:
-
-```sql
-+---------+------------+-------+------+
-| item_id | date_time | sales | sum |
-+---------+------------+-------+------+
-| 1 | 2024-07-01 | 100 | 100 |
-| 3 | 2024-07-01 | 140 | 240 |
-| 2 | 2024-07-01 | 100 | 340 |
-+---------+------------+-------+------+
-3 rows in set (0.03 sec)
-+---------+------------+-------+------+
-| item_id | date_time | sales | sum |
-+---------+------------+-------+------+
-| 2 | 2024-07-01 | 100 | 100 |
-| 1 | 2024-07-01 | 100 | 200 |
-| 3 | 2024-07-01 | 140 | 340 |
-+---------+------------+-------+------+
-3 rows in set (0.02 sec)
+```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 |
```
-**2. 解决方法**
-
-为了解决这个问题,可以在 `ORDER BY` 子句中添加一个唯一值列,如 `item_id`,以确保排序的唯一性。
+2. 这个查询使用分析函数产生 moving_average 这一列,它的值是 3
天的股票均价,即前一天、当前以及后一天三天的均价。第一天没有前一天的值,最后一天没有后一天的值,所以这两行只计算了两天的均值。这里 Partition By
没有起到作用,因为所有的数据都是 JDR 的数据,但如果还有其他股票信息,Partition By 会保证分析函数值作用在本 Partition 之内。
```sql
-SELECT
- item_id,
- date_time,
- sales,
- sum(sales) OVER (
- ORDER BY item_id,
- date_time ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum
-FROM
- test_window_order;
+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;
```
-则查询结果固定为:
-
-```sql
-+---------+------------+-------+------+
-| item_id | date_time | sales | sum |
-+---------+------------+-------+------+
-| 1 | 2024-07-01 | 100 | 100 |
-| 2 | 2024-07-01 | 100 | 200 |
-| 3 | 2024-07-01 | 140 | 340 |
-+---------+------------+-------+------+
-3 rows in set (0.03 sec)
+```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 |
```
-了解更多有关分析函数信息,可以参考 Oracle 官网文档 [SQL for Analysis and
Reporting](https://docs.oracle.com/en/database/oracle/oracle-database/23/dwhsg/sql-analysis-reporting-data-warehouses.html#GUID-20EFBF1E-F79D-4E4A-906C-6E496EECA684)
-
## 附录
示例中使用到的表的建表语句如下:
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/any-value.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/any-value.md
new file mode 120000
index 00000000000..4103943db7c
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/any-value.md
@@ -0,0 +1 @@
+../aggregate-functions/any-value.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-count-distinct.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-count-distinct.md
new file mode 120000
index 00000000000..3d741fcf642
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-count-distinct.md
@@ -0,0 +1 @@
+../aggregate-functions/approx-count-distinct.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-top-k.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-top-k.md
new file mode 120000
index 00000000000..9dff71fbf54
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-top-k.md
@@ -0,0 +1 @@
+../aggregate-functions/approx-top-k.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-top-sum.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-top-sum.md
new file mode 120000
index 00000000000..00dbd4bebd8
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/approx-top-sum.md
@@ -0,0 +1 @@
+../aggregate-functions/approx-top-sum.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/array-agg.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/array-agg.md
new file mode 120000
index 00000000000..700ff7c643f
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/array-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/array-agg.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/avg-weighted.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/avg-weighted.md
new file mode 120000
index 00000000000..c948744c8c8
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/avg-weighted.md
@@ -0,0 +1 @@
+../aggregate-functions/avg-weighted.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/avg.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/avg.md
new file mode 120000
index 00000000000..1c7aefeec8e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/avg.md
@@ -0,0 +1 @@
+../aggregate-functions/avg.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-agg.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-agg.md
new file mode 120000
index 00000000000..ada6ce4cbd5
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-agg.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-intersect.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-intersect.md
new file mode 120000
index 00000000000..c12fcadf265
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-intersect.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-intersect.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union-count.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union-count.md
new file mode 120000
index 00000000000..19049af5c4f
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union-count.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-union-count.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union-int.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union-int.md
new file mode 120000
index 00000000000..5dedfc7227e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union-int.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-union-int.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union.md
new file mode 120000
index 00000000000..39a0562d78a
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/bitmap-union.md
@@ -0,0 +1 @@
+../aggregate-functions/bitmap-union.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/collect-list.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/collect-list.md
new file mode 120000
index 00000000000..64030cc4e32
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/collect-list.md
@@ -0,0 +1 @@
+../aggregate-functions/collect-list.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/collect-set.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/collect-set.md
new file mode 120000
index 00000000000..ced8dce6d14
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/collect-set.md
@@ -0,0 +1 @@
+../aggregate-functions/collect-set.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/corr.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/corr.md
new file mode 120000
index 00000000000..e684a9eeed1
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/corr.md
@@ -0,0 +1 @@
+../aggregate-functions/corr.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/count-by-enum.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/count-by-enum.md
new file mode 120000
index 00000000000..5c0eda56ad5
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/count-by-enum.md
@@ -0,0 +1 @@
+../aggregate-functions/count-by-enum.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/count.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/count.md
new file mode 120000
index 00000000000..118dc2b9746
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/count.md
@@ -0,0 +1 @@
+../aggregate-functions/count.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/covar-samp.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/covar-samp.md
new file mode 120000
index 00000000000..c1c033b4a61
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/covar-samp.md
@@ -0,0 +1 @@
+../aggregate-functions/covar-samp.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/covar.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/covar.md
new file mode 120000
index 00000000000..07fa3e05b1e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/covar.md
@@ -0,0 +1 @@
+../aggregate-functions/covar.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/cume-dist.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/cume-dist.md
index 8c1c4b0a20d..f87506bb621 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/cume-dist.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/cume-dist.md
@@ -8,6 +8,7 @@
## 描述
CUME_DIST (Cumulative Distribution)
是一种窗口函数,它计算当前行值在排序后结果集中的相对排名。它返回的是当前行值在结果集中的累积分布值,范围从 0 到
1。对于给定的行,其累积分布值等于:(小于或等于当前行值的行数) / (窗口分区中的总行数)。
+如果未显示指定窗口,会隐式生成`RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` 类型,且当前仅支持此类。
## 语法
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/dense-rank.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/dense-rank.md
index efeb38fb07e..ba3f03ab2a6 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/dense-rank.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/dense-rank.md
@@ -8,6 +8,7 @@
## 描述
DENSE_RANK() 是一种窗口函数,用于计算分组内值的排名,与 RANK() 不同的是,DENSE_RANK()
返回的排名是连续的,不会出现空缺数字。排名值从 1 开始按顺序递增,如果出现相同的值,它们将具有相同的排名。
+如果未显示指定窗口,会隐式生成`RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` 类型,且当前仅支持此类。
## 语法
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/first-value.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/first-value.md
index b6acee5831c..4d8191ca939 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/first-value.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/first-value.md
@@ -7,7 +7,7 @@
## 描述
-FIRST_VALUE() 是一个窗口函数,用于返回窗口分区中有序数据集的第一个值。可以通过 IGNORE NULLS 选项来控制是否忽略空值。
+FIRST_VALUE() 是一个窗口函数,用于返回窗口分区中有序数据集的第一个值。可以通过 IGNORE NULL 选项来控制是否忽略NULL值。
## 语法
@@ -18,8 +18,8 @@ FIRST_VALUE(<expr>[, <ignore_null>])
## 参数
| 参数 | 说明
|
| ------------------- |
---------------------------------------------------------------------------------------
|
-| expr | 需要获取第一个值的表达式
|
-| ignore_null | 可选。参数 ignore_null 默认值为 false, 设置后会忽略空值
|
+| expr | 需要获取第一个值的表达式,支持类型:
tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/array/struct/map/bitmap
|
+| ignore_null | 可选 boolean 类型。参数 ignore_null 默认值为 false, 设置后会忽略NULL值
|
## 返回值
@@ -49,11 +49,11 @@ SELECT
column2,
FIRST_VALUE(column2) OVER (
PARTITION BY column1
- ORDER BY column2 NULLS LAST
+ ORDER BY column2 NULLS LAST -- 定义NULL值位置在最后
) AS first_value_default,
FIRST_VALUE(column2, true) OVER (
PARTITION BY column1
- ORDER BY column2
+ ORDER BY column2 NULLS FIRST -- 定义NULL值位置在最前
) AS first_value_ignore_null
FROM example_data
ORDER BY column1, column2;
@@ -65,7 +65,7 @@ ORDER BY column1, column2;
+------------+---------+---------+---------------------+-------------------------+
| A | 1 | NULL | 10 |
NULL |
| A | 1 | NULL | 10 |
NULL |
-| A | 1 | 10 | 10 |
10 |
+| A | 1 | 10 | 10 |
10 | --- 跳过前面的NULL行
| A | 1 | 20 | 10 |
10 |
| B | 2 | NULL | 30 |
NULL |
| B | 2 | 30 | 30 |
30 |
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-array-intersect.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-array-intersect.md
new file mode 120000
index 00000000000..a8bfeebbdb1
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-array-intersect.md
@@ -0,0 +1 @@
+../aggregate-functions/group-array-intersect.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-and.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-and.md
new file mode 120000
index 00000000000..e44111f2fba
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-and.md
@@ -0,0 +1 @@
+../aggregate-functions/group-bit-and.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-or.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-or.md
new file mode 120000
index 00000000000..3262a959c6b
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-or.md
@@ -0,0 +1 @@
+../aggregate-functions/group-bit-or.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-xor.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-xor.md
new file mode 120000
index 00000000000..bd86f034822
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bit-xor.md
@@ -0,0 +1 @@
+../aggregate-functions/group-bit-xor.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bitmap-xor.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bitmap-xor.md
new file mode 120000
index 00000000000..b0ab9c0118e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-bitmap-xor.md
@@ -0,0 +1 @@
+../aggregate-functions/group-bitmap-xor.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-concat.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-concat.md
new file mode 120000
index 00000000000..47517568f8b
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/group-concat.md
@@ -0,0 +1 @@
+../aggregate-functions/group-concat.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/grouping-id.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/grouping-id.md
new file mode 120000
index 00000000000..8caf06c2b1b
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/grouping-id.md
@@ -0,0 +1 @@
+../aggregate-functions/grouping-id.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/grouping.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/grouping.md
new file mode 120000
index 00000000000..13f73128503
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/grouping.md
@@ -0,0 +1 @@
+../aggregate-functions/grouping.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/histogram.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/histogram.md
new file mode 120000
index 00000000000..aa6cc9dc4e3
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/histogram.md
@@ -0,0 +1 @@
+../aggregate-functions/histogram.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/hll-raw-agg.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/hll-raw-agg.md
new file mode 120000
index 00000000000..fdad6cae306
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/hll-raw-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/hll-raw-agg.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/hll-union-agg.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/hll-union-agg.md
new file mode 120000
index 00000000000..460811203ee
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/hll-union-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/hll-union-agg.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/intersect-count.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/intersect-count.md
new file mode 120000
index 00000000000..16823248f72
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/intersect-count.md
@@ -0,0 +1 @@
+../aggregate-functions/intersect-count.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/kurt.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/kurt.md
new file mode 120000
index 00000000000..a23aa42c05a
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/kurt.md
@@ -0,0 +1 @@
+../aggregate-functions/kurt.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/lag.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/lag.md
index 921df69bc47..8a548751e96 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/lag.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/lag.md
@@ -8,6 +8,7 @@
## 描述
LAG() 是一个窗口函数,用于访问当前行之前的行数据,而无需进行自连接。它可以获取分区内当前行之前第 N 行的值。
+不需要未显示指定窗口,会隐式生成`ROWS BETWEEN UNBOUNDED PRECEDING AND N PRECEDING` 类型,且当前仅支持此类。
## 语法
@@ -18,9 +19,9 @@ LAG ( <expr> [, <offset> [, <default> ] ] )
## 参数
| 参数 | 说明
|
| ------------------- |
---------------------------------------------------------------------- |
-| expr | 需要获取值的表达式
|
-| offset | 可选。向前偏移的行数。默认值为 1。|
-| default | 可选。当偏移超出窗口范围时返回的默认值。默认为 NULL |
+| expr | 需要获取值的表达式:
支持类型:tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/
|
+| offset | 可选, 类型: bigint。向前偏移的行数。默认值为 1。|
+| default | 可选, 类型和第一个参数保持一致。当偏移超出窗口范围时返回的默认值。默认为 NULL
|
## 返回值
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/last-value.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/last-value.md
index f68a2ebfe86..b88921bb0b9 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/last-value.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/last-value.md
@@ -7,7 +7,7 @@
## 描述
-LAST_VALUE() 是一个窗口函数,用于返回窗口范围内的最后一个值。可以通过 IGNORE NULLS 选项来控制是否忽略空值。
+LAST_VALUE() 是一个窗口函数,用于返回窗口范围内的最后一个值。可以通过 IGNORE NULL 选项来控制是否忽略NULL值。
## 语法
@@ -18,8 +18,8 @@ LAST_VALUE(<expr>[, <ignore_null>])
## 参数
| 参数 | 说明 |
| ----------- | ------------------------------------------------------- |
-| expr | 需要获取最后一个值的表达式 |
-| ignore_null | 可选。参数 ignore_null 默认值为 false, 设置后会忽略空值 |
+| expr |
需要获取最后一个值的表达式,支持类型:tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/array/struct/map/bitmap
|
+| ignore_null | 可选 boolean 类型。参数 ignore_null 默认值为 false, 设置后会忽略NULL值 |
## 返回值
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/lead.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/lead.md
index 6fd691a82be..9014bb454e0 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/lead.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/lead.md
@@ -8,6 +8,7 @@
## 描述
LEAD() 是一个窗口函数,用于访问当前行之后的行数据,而无需进行自连接。它可以获取分区内当前行之后第 N 行的值。
+不需要未显示指定窗口,会隐式生成`ROWS BETWEEN UNBOUNDED PRECEDING AND N FOLLOWING` 类型,且当前仅支持此类。
## 语法
@@ -18,9 +19,9 @@ LEAD ( <expr> [ , <offset> [ , <default> ] ] )
## 参数
| 参数 | 说明
|
| ------------------- |
-----------------------------------------------------------------------------------------------------------------
|
-| expr | 需要获取值的表达式
|
-| offset | 可选。向后偏移的行数。默认值为 1。|
-| default | 可选。当偏移超出窗口范围时返回的默认值。默认为 NULL
|
+| expr | 需要获取值的表达式:
支持类型:tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/
|
+| offset | 可选, 类型: bigint。向后偏移的行数。默认值为 1。|
+| default | 可选, 类型和第一个参数保持一致。当偏移超出窗口范围时返回的默认值。默认为 NULL
|
## 返回值
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/linear-histogram.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/linear-histogram.md
new file mode 120000
index 00000000000..71c1a5c530c
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/linear-histogram.md
@@ -0,0 +1 @@
+../aggregate-functions/linear-histogram.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/map-agg.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/map-agg.md
new file mode 120000
index 00000000000..a195dee8c75
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/map-agg.md
@@ -0,0 +1 @@
+../aggregate-functions/map-agg.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/max-by.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/max-by.md
new file mode 120000
index 00000000000..5a96ae85219
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/max-by.md
@@ -0,0 +1 @@
+../aggregate-functions/max-by.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/max.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/max.md
new file mode 120000
index 00000000000..70aa0f54722
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/max.md
@@ -0,0 +1 @@
+../aggregate-functions/max.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/median.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/median.md
new file mode 120000
index 00000000000..b3113a98806
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/median.md
@@ -0,0 +1 @@
+../aggregate-functions/median.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/min-by.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/min-by.md
new file mode 120000
index 00000000000..6ef66ef549f
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/min-by.md
@@ -0,0 +1 @@
+../aggregate-functions/min-by.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/min.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/min.md
new file mode 120000
index 00000000000..42f38a3f3d9
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/min.md
@@ -0,0 +1 @@
+../aggregate-functions/min.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/nth-value.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/nth-value.md
index 1205cdb2eac..82871e8be09 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/nth-value.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/nth-value.md
@@ -18,8 +18,8 @@ NTH_VALUE(<expr>, <offset>)
## 参数
| 参数 | 说明
|
| ------------------- |
---------------------------------------------------------------------------------------
|
-| expr | 需要获取值的表达式
|
-| offset | 参数 offset 的值为大于0的正整数,用于表示获取的第N的元素值,起始值从1开始
|
+| expr |
需要获取值的表达式,支持类型:tinyint/smallint/int/bigint/float/double/decimal/string/date/datetime/array/struct/map/bitmap
|
+| offset | 类型: bigint, 参数 offset 的值为大于0的正整数,用于表示获取的第N的元素值,起始值从1开始
|
## 返回值
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/ntile.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/ntile.md
index 711e6357114..3b862159284 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/ntile.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/ntile.md
@@ -8,6 +8,8 @@
## 描述
NTILE() 是一个窗口函数,用于将有序数据集平均分配到指定数量的桶中。桶的编号从 1
开始顺序编号,直到指定的桶数。当数据无法平均分配时,优先将多出的记录分配给编号较小的桶,使得各个桶中的行数最多相差 1。
+如果未显示指定窗口,会隐式生成`ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` 类型,且当前仅支持此类。
+
## 语法
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/overview.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/overview.md
index e4700ac170f..0d354c11b75 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/overview.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/overview.md
@@ -19,66 +19,134 @@
## 语法
```sql
-function(<args>) OVER(
- [PARTITION BY <expr> [, <expr> ...]]
- [ORDER BY <expr> [ASC | DESC] [, <expr> [ASC | DESC] ...]]
- [<window_clause>]
-)
+<FUNCTION> ( [ <ARGUMENTS> ] ) OVER ( [ <windowDefinition> ] )
+```
+
+其中:
+```sql
+windowDefinition ::=
+
+[ PARTITION BY <expr1> [, ...] ]
+[ ORDER BY <expr2> [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ]
+[ <windowFrameClause> ]
+```
+
+其中:
+```sql
+windowFrameClause ::=
+{
+ | { ROWS } <n> PRECEDING
+ | { ROWS } CURRENT ROW
+ | { ROWS } BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
+ | { ROWS | RANGE } UNBOUNDED PRECEDING
+ | { ROWS | RANGE } BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+ | { ROWS | RANGE } BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
+ | { ROWS } BETWEEN <n> { PRECEDING | FOLLOWING } AND <n> { PRECEDING |
FOLLOWING }
+ | { ROWS } BETWEEN UNBOUNDED PRECEDING AND <n> { PRECEDING | FOLLOWING }
+ | { ROWS } BETWEEN <n> { PRECEDING | FOLLOWING } AND UNBOUNDED FOLLOWING
+}
```
## 参数
-| 参数 | 说明 |
-|------|------|
-| `<args>` | 窗口函数的输入参数,具体参数根据所使用的函数而定 |
-| `<function>` | 支持的函数包括:AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(),
LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM(), NTH_VALUE()
和所有聚合函数 |
-| `<partition_by>` | 类似于 GROUP BY,按指定列对数据进行分组 |
-| `<order_by>` | 定义窗口内数据的排序方式 |
-| `<window_clause>` | 定义窗口范围,语法为:ROWS BETWEEN [ { m \| UNBOUNDED } PRECEDING
\| CURRENT ROW] [ AND [CURRENT ROW \| { UNBOUNDED \| n } FOLLOWING] ] |
+`<FUNCTION>`
+> 窗口函数的名字。所有聚合函数以及 DENSE_RANK(), FIRST_VALUE(), LAG(), LAST_VALUE(), LEAD(),
RANK(), ROW_NUMBER(), NTH_VALUE(), PERCENT_RANK(), CUME_DIST(), NTILE() 特殊窗口函数。
+
+`<ARGUMENTS>`
+> 可选,窗口函数的输入参数,参数类型和个数需要根据所使用的具体函数而定。
+
+`<PARTITION_BY>`
+> 可选,类似于 GROUP BY,按指定列对数据进行分组,然后在每个分区中进行相关计算。
+
+`<ORDER_BY>`
+> 可选,用于对每个分区内的数据进行排序,如果未指定任何分区,则会对整体进行排序。但此ORDER BY 和常见的出现在SQL 末尾中的ORDER BY
不同。出现在OVER 子句的排序,仅对此分区中数据进行排序,而出现在SQL 末尾中的排序,是控制查询最终结果中所有行的顺序,这两者是可以共存的。
+> 另外如果在OVER没有显示的写出ORDER
BY,则会导致分区内的数据是随机的,进而可能使得最终结果是随机的。如果显示的给出了排序列,但是可能由于排序出现重复值,也会引起结果不稳定,具体可参阅下述的[案例](#section1)
+
+`<windowFrameClause>`
+> 可选,用于定义窗口范围, 目前支持`RANGE/ROWS` 两种类型。
+其中,`N PRECEDING/FOLLOWING`,`N` 是一个正整数,表示的是滑动窗口相对当前行的范围,目前仅支持在ROWS
窗口中,所以表示的是相对当前行的物理偏移。当前RANGE 类型有些限制, 必须是 `BOTH UNBOUNDED BOUNDARY OR ONE
UNBOUNDED BOUNDARY AND ONE CURRENT ROW`。如果未指定任何的Frame,默认会生成隐式的 `RANGE BETWEEN
UNBOUNDED PRECEDING AND CURRENT ROW`。
+
## 返回值
返回与输入表达式相同的数据类型。
-## 举例
+<a id="section1"></a>
+## 分析函数数据的唯一排序
+
+**1. 存在返回结果不一致的问题**
+
+当使用窗口函数的 `ORDER BY` 子句未能产生数据的唯一排序时,例如当 `ORDER BY`
表达式导致重复值时,行的顺序会变得不确定。这意味着在多次执行查询时,这些行的返回顺序可能会有所不同,进而导致窗口函数返回不一致的结果。
-1. 假设我们有如下的股票数据,股票代码是 JDR,closing price 是每天的收盘价。
+通过以下示例可以看出,该查询在多次运行时返回了不同的结果。出现不一致性的情况主要由于 `ORDER BY dateid` 没有为 `SUM`
窗口函数提供产生数据的唯一排序。
```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
+CREATE TABLE test_window_order (
+ item_id int,
+ date_time date,
+ sales double)
+distributed BY hash(item_id)
+properties("replication_num" = 1);
+
+INSERT INTO test_window_order VALUES
+(1, '2024-07-01', 100),
+(2, '2024-07-01', 100),
+(3, '2024-07-01', 140);
+
+SELECT
+ item_id, date_time, sales,
+ sum(sales) OVER (ORDER BY date_time ROWS BETWEEN
+ UNBOUNDED PRECEDING AND CURRENT ROW) sum
+FROM
+ test_window_order;
```
-```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 |
+由于排序列 `date_time`存在重复值,可能呈现以下两种查询结果:
+
+```sql
++---------+------------+-------+------+
+| item_id | date_time | sales | sum |
++---------+------------+-------+------+
+| 1 | 2024-07-01 | 100 | 100 |
+| 3 | 2024-07-01 | 140 | 240 |
+| 2 | 2024-07-01 | 100 | 340 |
++---------+------------+-------+------+
+3 rows in set (0.03 sec)
++---------+------------+-------+------+
+| item_id | date_time | sales | sum |
++---------+------------+-------+------+
+| 2 | 2024-07-01 | 100 | 100 |
+| 1 | 2024-07-01 | 100 | 200 |
+| 3 | 2024-07-01 | 140 | 340 |
++---------+------------+-------+------+
+3 rows in set (0.02 sec)
```
-2. 这个查询使用分析函数产生 moving_average 这一列,它的值是 3
天的股票均价,即前一天、当前以及后一天三天的均价。第一天没有前一天的值,最后一天没有后一天的值,所以这两行只计算了两天的均值。这里 Partition By
没有起到作用,因为所有的数据都是 JDR 的数据,但如果还有其他股票信息,Partition By 会保证分析函数值作用在本 Partition 之内。
+**2. 解决方法**
+
+为了解决这个问题,可以在 `ORDER BY` 子句中添加一个唯一值列,如 `item_id`,以确保排序的唯一性。
```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;
+SELECT
+ item_id,
+ date_time,
+ sales,
+ sum(sales) OVER (
+ ORDER BY item_id,
+ date_time ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum
+FROM
+ test_window_order;
```
-```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
++---------+------------+-------+------+
+| item_id | date_time | sales | sum |
++---------+------------+-------+------+
+| 1 | 2024-07-01 | 100 | 100 |
+| 2 | 2024-07-01 | 100 | 200 |
+| 3 | 2024-07-01 | 140 | 340 |
++---------+------------+-------+------+
+3 rows in set (0.03 sec)
```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percent-rank.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percent-rank.md
index cacc9d23bf3..c66943d47e6 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percent-rank.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percent-rank.md
@@ -8,6 +8,8 @@
## 描述
PERCENT_RANK() 是一个窗口函数,用于计算分区或结果集中行的相对排名,返回值范围从 0.0 到 1.0。对于给定的行,其计算公式为:(rank
- 1) / (total_rows - 1),其中 rank 是当前行的排名,total_rows 是分区中的总行数。
+如果未显示指定窗口,会隐式生成`RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` 类型,且当前仅支持此类。
+
## 语法
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile-approx.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile-approx.md
new file mode 120000
index 00000000000..a4ad830ebb9
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile-approx.md
@@ -0,0 +1 @@
+../aggregate-functions/percentile-approx.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile-array.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile-array.md
new file mode 120000
index 00000000000..62088376770
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile-array.md
@@ -0,0 +1 @@
+../aggregate-functions/percentile-array.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile.md
new file mode 120000
index 00000000000..4744359c30b
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile.md
@@ -0,0 +1 @@
+../aggregate-functions/percentile.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile_approx_weighted.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile_approx_weighted.md
new file mode 120000
index 00000000000..e5e294e625b
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/percentile_approx_weighted.md
@@ -0,0 +1 @@
+../aggregate-functions/percentile_approx_weighted.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/quantile-union.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/quantile-union.md
new file mode 120000
index 00000000000..19bebc142b6
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/quantile-union.md
@@ -0,0 +1 @@
+../aggregate-functions/quantile-union.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/rank.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/rank.md
index 403ef9e941b..f71e98a4bf4 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/rank.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/rank.md
@@ -8,6 +8,8 @@
## 描述
RANK() 是一个窗口函数,用于返回有序数据集中值的排名。排名从 1
开始按顺序递增。当出现相同值时,这些值获得相同的排名,但会导致排名序列出现间隔。例如,如果前两行并列排名第 1,则下一个不同的值将排名第 3(而不是第 2)。
+如果未显示指定窗口,会隐式生成`RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` 类型,且当前仅支持此类。
+
## 语法
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr-intercept.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr-intercept.md
new file mode 120000
index 00000000000..857a57a38f8
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr-intercept.md
@@ -0,0 +1 @@
+../aggregate-functions/regr-intercept.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr-slope.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr-slope.md
new file mode 120000
index 00000000000..ba882fcd44e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr-slope.md
@@ -0,0 +1 @@
+../aggregate-functions/regr-slope.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr_intercept.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr_intercept.md
new file mode 120000
index 00000000000..36b6a9d226d
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr_intercept.md
@@ -0,0 +1 @@
+../aggregate-functions/regr_intercept.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr_slope.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr_slope.md
new file mode 120000
index 00000000000..bc5d9c64cf4
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/regr_slope.md
@@ -0,0 +1 @@
+../aggregate-functions/regr_slope.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/retention.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/retention.md
new file mode 120000
index 00000000000..90924e30f52
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/retention.md
@@ -0,0 +1 @@
+../aggregate-functions/retention.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/row-number.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/row-number.md
index a82b0e67fc7..8be00cb5702 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/row-number.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/row-number.md
@@ -8,6 +8,8 @@
## 描述
ROW_NUMBER() 是一个窗口函数,用于为分区内的每一行分配一个唯一的序号。序号从 1 开始连续递增。与 RANK() 和 DENSE_RANK()
不同,ROW_NUMBER() 即使对于相同的值也会分配不同的序号,确保每行都有唯一的编号。
+如果未显示指定窗口,会隐式生成`ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` 类型,且当前仅支持此类。
+
## 语法
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sequence-count.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sequence-count.md
new file mode 120000
index 00000000000..cf625afe6d7
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sequence-count.md
@@ -0,0 +1 @@
+../aggregate-functions/sequence-count.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sequence-match.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sequence-match.md
new file mode 120000
index 00000000000..576a1bd745a
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sequence-match.md
@@ -0,0 +1 @@
+../aggregate-functions/sequence-match.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/skew.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/skew.md
new file mode 120000
index 00000000000..1cf20c294f0
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/skew.md
@@ -0,0 +1 @@
+../aggregate-functions/skew.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/stddev-samp.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/stddev-samp.md
new file mode 120000
index 00000000000..8e801372498
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/stddev-samp.md
@@ -0,0 +1 @@
+../aggregate-functions/stddev-samp.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/stddev.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/stddev.md
new file mode 120000
index 00000000000..8dfddbc2328
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/stddev.md
@@ -0,0 +1 @@
+../aggregate-functions/stddev.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sum.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sum.md
new file mode 120000
index 00000000000..2afe4c1185e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sum.md
@@ -0,0 +1 @@
+../aggregate-functions/sum.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sum0.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sum0.md
new file mode 120000
index 00000000000..bc67df7083e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/sum0.md
@@ -0,0 +1 @@
+../aggregate-functions/sum0.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn-array.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn-array.md
new file mode 120000
index 00000000000..02bec6851e9
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn-array.md
@@ -0,0 +1 @@
+../aggregate-functions/topn-array.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn-weighted.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn-weighted.md
new file mode 120000
index 00000000000..ae383927255
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn-weighted.md
@@ -0,0 +1 @@
+../aggregate-functions/topn-weighted.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn.md
new file mode 120000
index 00000000000..d3bf7036a99
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/topn.md
@@ -0,0 +1 @@
+../aggregate-functions/topn.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/var-samp.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/var-samp.md
new file mode 120000
index 00000000000..bd32134e30e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/var-samp.md
@@ -0,0 +1 @@
+../aggregate-functions/var-samp.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/variance.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/variance.md
new file mode 120000
index 00000000000..0dd8d4f8705
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/variance.md
@@ -0,0 +1 @@
+../aggregate-functions/variance.md
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/window-funnel.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/window-funnel.md
new file mode 120000
index 00000000000..d4de6f93304
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/window-functions/window-funnel.md
@@ -0,0 +1 @@
+../aggregate-functions/window-funnel.md
\ No newline at end of file
diff --git a/sidebars.json b/sidebars.json
index 4af3b0a8dcc..034c6bce803 100644
--- a/sidebars.json
+++ b/sidebars.json
@@ -1718,16 +1718,16 @@
"label": "Analytic (Window) Functions",
"items": [
"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",
"sql-manual/sql-functions/window-functions/cume-dist",
+
"sql-manual/sql-functions/window-functions/dense-rank",
"sql-manual/sql-functions/window-functions/first-value",
+
"sql-manual/sql-functions/window-functions/lag",
"sql-manual/sql-functions/window-functions/last-value",
"sql-manual/sql-functions/window-functions/lead",
-
"sql-manual/sql-functions/window-functions/lag",
-
"sql-manual/sql-functions/window-functions/row-number",
-
"sql-manual/sql-functions/window-functions/ntile"
+
"sql-manual/sql-functions/window-functions/ntile",
+
"sql-manual/sql-functions/window-functions/percent-rank",
+
"sql-manual/sql-functions/window-functions/rank",
+
"sql-manual/sql-functions/window-functions/row-number"
]
},
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]