# WINDOW FUNCTION WINDOW FUNCTION 算子用于实现 SQL 中的分析函数(也叫窗口函数),计算窗口下的相关行的结果。 窗口函数与聚集函数不同的是,聚集函数一组只能返回一行,而窗口函数每组可以返回多行,组内每一行都是基于窗口的逻辑计算的结果。因此,在执行含有 WINDOW FUNCTION 的 SQL 时 (格式一般为`OVER(...)`),都会在生成执行计划的时候分配一个 WINDOW FUNCTION 算子。 示例:含 WINDOW FUNCTION 算子的执行计划 ~~~ obclient>CREATE TABLE t1(c1 INT, c2 INT); Query OK, 0 rows affected (0.12 sec) obclient>INSERT INTO t1 VALUES(1, 1); Query OK, 1 rows affected (0.12 sec) obclient>INSERT INTO t1 VALUES(2, 2); Query OK, 1 rows affected (0.12 sec) obclient>INSERT INTO t1 VALUES(3, 3); Query OK, 1 rows affected (0.12 sec) Q1: obclient>EXPLAIN SELECT MAX(c1) OVER(PARTITION BY c1 ORDER BY c2) FROM t1\G; *************************** 1. row *************************** Query Plan: | ======================================== |ID|OPERATOR |NAME|EST. ROWS|COST| ---------------------------------------- |0 |WINDOW FUNCTION| |3 |45 | |1 | SORT | |3 |44 | |2 | TABLE SCAN |T1 |3 |37 | ======================================== Outputs & filters: ------------------------------------- 0 - output([T_FUN_MAX(T1.C1)]), filter(nil), win_expr(T_FUN_MAX(T1.C1)), partition_by([T1.C1]), order_by([T1.C2, ASC]), window_type(RANGE), upper(UNBOUNDED PRECEDING), lower(CURRENT ROW) 1 - output([T1.C1], [T1.C2]), filter(nil), sort_keys([T1.C1, ASC], [T1.C2, ASC]) 2 - output([T1.C1], [T1.C2]), filter(nil), access([T1.C1], [T1.C2]), partitions(p0) ~~~ 其中,窗口函数中指定了一个 ORDER BY/PARTITION BY 的时候,会在下层分配一个 SORT 算子,将排序结果返回给窗口函数算子使用。 上述示例中,Q1 查询的执行计划展示中的 outputs & filters 详细列出了 WINDOW FUNCTION 算子的输出信息如下: <div data-card-value="data:%7B%22rows%22%3A9%2C%22cols%22%3A2%2C%22html%22%3A%22%3Ctable%20class%3D%5C%22lake-table%5C%22%20style%3D%5C%22width%3A%20746px%3B%5C%22%3E%3Ccolgroup%3E%3Ccol%20span%3D%5C%221%5C%22%20width%3D%5C%22140%5C%22%20%2F%3E%3Ccol%20span%3D%5C%221%5C%22%20width%3D%5C%22606%5C%22%20%2F%3E%3C%2Fcolgroup%3E%3Ctbody%3E%3Ctr%20style%3D%5C%22height%3A%2033px%3B%5C%22%3E%3Ctd%3E%3Cp%20data-lake-id%3D%5C%22cb3078e95c28ae8e47cb93545771ead1%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%3Cstrong%3E%E4%BF%A1%E6%81%AF%E5%90%8D%E7%A7%B0%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3Ctd%20rowspan%3D%5C%221%5C%22%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%20style%3D%5C%22color%3A%20%23262626%3B%5C%22%3E%3Cstrong%3E%3Cspan%3E%E5%90%AB%E4%B9%89%3C%2Fspan%3E%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%20style%3D%5C%22height%3A%2033px%3B%5C%22%3E%3Ctd%20rowspan%3D%5C%221%5C%22%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Eoutput%3C%2Fspan%3E%3C%2Ftd%3E%3Ctd%20rowspan%3D%5C%221%5C%22%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E8%AF%A5%E7%AE%97%E5%AD%90%E8%BE%93%E5%87%BA%E7%9A%84%E8%A1%A8%E8%BE%BE%E5%BC%8F%E3%80%82%3C%2Fspan%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%20style%3D%5C%22height%3A%2033px%3B%5C%22%3E%3Ctd%20rowspan%3D%5C%221%5C%22%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Efilter%3C%2Fspan%3E%3C%2Ftd%3E%3Ctd%20rowspan%3D%5C%221%5C%22%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%3Cspan%3E%E8%AF%A5%E7%AE%97%E5%AD%90%E4%B8%8A%E7%9A%84%E8%BF%87%E6%BB%A4%E6%9D%A1%E4%BB%B6%E3%80%82%E7%94%B1%E4%BA%8E%C2%A0%3C%2Fspan%3E%3Cspan%3E%3Cspan%3Ewindow%20function%3C%2Fspan%3E%3C%2Fspan%3E%3Cspan%3E%3Cspan%3E%20%E7%AE%97%E5%AD%90%3C%2Fspan%3E%3C%2Fspan%3E%3Cspan%3E%E4%B8%8D%E5%AD%98%E5%9C%A8%20filter%3C%2Fspan%3E%3Cspan%3E%3Cspan%3E%3C%2Fspan%3E%3C%2Fspan%3E%3Cspan%3E%EF%BC%8C%E6%89%80%E4%BB%A5%E4%B8%BA%20nil%3C%2Fspan%3E%E3%80%82%3C%2Fspan%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%20style%3D%5C%22height%3A%2033px%3B%5C%22%3E%3Ctd%20colspan%3D%5C%221%5C%22%20rowspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%22a9a28d64625b7ac6b49488b7b2978c8c%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Ewin_expr%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3Ctd%20colspan%3D%5C%221%5C%22%20rowspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%225912800298c38f95bfbed226646c1c9a%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E8%A1%A8%E7%A4%BA%E5%9C%A8%E7%AA%97%E5%8F%A3%E4%B8%AD%E4%BD%BF%E7%94%A8%E4%BD%95%E7%A7%8D%E8%81%9A%E5%90%88%E5%87%BD%E6%95%B0%E3%80%82%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E4%BE%8B%E5%A6%82%20Q1%20%E6%9F%A5%E8%AF%A2%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E4%B8%BA%E6%B1%82%20c1%20%E5%88%97%E7%9A%84%E6%9C%80%E5%A4%A7%E5%80%BC%EF%BC%8C%E5%9B%A0%E6%AD%A4%E4%B8%BAT_FUN_MAX(T1.C1)%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E3%80%82%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%3E%3Ctd%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%20background-color%3A%20%23FFFFFF%3B%20color%3A%20%23404040%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%22a20d224c568e48b9d67847a2c66a8c01_p_0%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Epartition_by%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3Ctd%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%20background-color%3A%20%23FFFFFF%3B%20color%3A%20%23404040%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%22a20d224c568e48b9d67847a2c66a8c01_p_0%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E8%A1%A8%E7%A4%BA%E5%9C%A8%E7%AA%97%E5%8F%A3%E4%B8%AD%E6%8C%89%E7%85%A7%E4%BD%95%E7%A7%8D%E6%96%B9%E5%BC%8F%E5%88%86%E7%BB%84%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E3%80%82%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E4%BE%8B%E5%A6%82%20Q1%20%E6%9F%A5%E8%AF%A2%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E4%B8%BA%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E6%8C%89%E7%85%A7%20c1%20%E5%88%97%E5%88%86%E7%BB%84%EF%BC%8C%E5%9B%A0%E6%AD%A4%E4%B8%BA%20T1.C1%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%20style%3D%5C%22height%3A%2033px%3B%5C%22%3E%3Ctd%20colspan%3D%5C%221%5C%22%20rowspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%223aa985e181ffefaa68e0dc9337cab38c%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Eorder_by%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3Ctd%20colspan%3D%5C%221%5C%22%20rowspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%22a11a5eec3a422975d2f76d553cf376a2%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E8%A1%A8%E7%A4%BA%E5%9C%A8%E7%AA%97%E5%8F%A3%E4%B8%AD%E6%8C%89%E7%85%A7%E4%BD%95%E7%A7%8D%E6%96%B9%E5%BC%8F%E6%8E%92%E5%BA%8F%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E3%80%82%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E4%BE%8B%E5%A6%82%20Q1%20%E6%9F%A5%E8%AF%A2%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E4%B8%BA%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E6%8C%89%E7%85%A7%20c2%20%E5%88%97%E6%8E%92%E5%BA%8F%EF%BC%8C%E5%9B%A0%E6%AD%A4%E4%B8%BA%20T1.C2%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E3%80%82%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%3E%3Ctd%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%20background-color%3A%20%23FFFFFF%3B%20color%3A%20%23404040%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%22a20d224c568e48b9d67847a2c66a8c01_p_0%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Ewindow_type%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3Ctd%20colspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%20background-color%3A%20%23FFFFFF%3B%20color%3A%20%23404040%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%22a20d224c568e48b9d67847a2c66a8c01_p_0%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E8%A1%A8%E7%A4%BA%E7%AA%97%E5%8F%A3%E7%B1%BB%E5%9E%8B%EF%BC%8C%E6%9C%89%E4%B8%A4%E7%A7%8D(range%2Frows)%EF%BC%8C%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Erange%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%20%E8%A1%A8%E7%A4%BA%E6%8C%89%E7%85%A7%E9%80%BB%E8%BE%91%E4%BD%8D%E7%BD%AE%E5%81%8F%E7%A7%BB%E8%BF%9B%E8%A1%8C%E8%AE%A1%E7%AE%97%E7%AA%97%E5%8F%A3%E4%B8%8A%E4%B8%8B%E7%95%8C%E9%99%90%EF%BC%8C%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Erows%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%20%E8%A1%A8%E7%A4%BA%E6%8C%89%E7%85%A7%E5%AE%9E%E9%99%85%E7%89%A9%E7%90%86%E4%BD%8D%E7%BD%AE%E5%81%8F%E7%A7%BB%E8%BF%9B%E8%A1%8C%E8%AE%A1%E7%AE%97%E7%AA%97%E5%8F%A3%E4%B8%8A%E4%B8%8B%E7%95%8C%E9%99%90%EF%BC%9B%E9%BB%98%E8%AE%A4%E4%BD%BF%E7%94%A8%C2%A0%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Erange%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%20%E6%96%B9%E5%BC%8F%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E3%80%82%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E4%BE%8B%E5%A6%82%20Q1%20%E6%9F%A5%E8%AF%A2%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E6%9C%AA%E8%AE%BE%E7%BD%AE%EF%BC%8C%E5%9B%A0%E6%AD%A4%E9%80%89%E6%8B%A9%E4%BA%86%E9%BB%98%E8%AE%A4%E6%96%B9%E5%BC%8F%C2%A0%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3Erange%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E3%80%82%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%3E%3Ctd%20colspan%3D%5C%221%5C%22%20rowspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%20background-color%3A%20%23FFFFFF%3B%20color%3A%20%23404040%3B%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%20style%3D%5C%22color%3A%20%23404040%3B%5C%22%3Eupper%3C%2Fspan%3E%3C%2Ftd%3E%3Ctd%20colspan%3D%5C%221%5C%22%20rowspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%20background-color%3A%20%23FFFFFF%3B%20color%3A%20%23404040%3B%5C%22%3E%3Cp%20data-lake-id%3D%5C%228a0596435002b87c24273c18cedf5861%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E8%AE%BE%E5%AE%9A%E7%AA%97%E5%8F%A3%E7%9A%84%E4%B8%8A%E8%BE%B9%E7%95%8C%EF%BC%9A%3C%2Fspan%3E%3C%2Fp%3E%3Cul%20data-lake-id%3D%5C%22362607c81d2efc4cfc1ef39733da2a2d%5C%22%3E%3Cli%20data-lake-id%3D%5C%22b6c1cb71b97e2c9fa12052423f50f19d%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3EUNBOUNDED%E8%A1%A8%E7%A4%BA%E6%97%A0%E8%BE%B9%E7%95%8C%EF%BC%8C%E6%8C%89%E7%85%A7%E6%9C%80%E5%A4%A7%E7%9A%84%E9%80%89%E6%8B%A9%EF%BC%88%E9%BB%98%E8%AE%A4%EF%BC%89%E3%80%82%3C%2Fspan%3E%3C%2Fli%3E%3Cli%20data-lake-id%3D%5C%22072762c367f7543fa654b46a3fb2231f%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3ECURRENT%20ROW%E8%A1%A8%E7%A4%BA%E4%BB%8E%E5%BD%93%E5%89%8D%E8%A1%8C%E5%BC%80%E5%A7%8B%EF%BC%8C%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E5%A6%82%E6%9E%9C%E5%87%BA%E7%8E%B0%E6%95%B0%E5%AD%97%E5%88%99%E8%A1%A8%E7%A4%BA%E7%A7%BB%E5%8A%A8%E7%9A%84%E8%A1%8C%E6%95%B0%E3%80%82%3C%2Fspan%3E%3C%2Fli%3E%3Cli%20data-lake-id%3D%5C%2241c310acc219d457ef20cdfff9387834%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3EPRECEDING%E8%A1%A8%E7%A4%BA%E5%90%91%E5%89%8D%E5%8F%96%E8%BE%B9%E7%95%8C%EF%BC%8CFOLLOWING%E5%88%99%E8%A1%A8%E7%A4%BA%E5%90%91%E5%90%8E%E5%8F%96%E8%BE%B9%E7%95%8C%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E3%80%82%3C%2Fspan%3E%3C%2Fli%3E%3C%2Ful%3E%3Cp%20data-lake-id%3D%5C%220fa4bf31319796d87e0fa19c745e07d9%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%3Cspan%3E%E4%BE%8B%E5%A6%82%20Q1%20%E6%9F%A5%E8%AF%A2%3C%2Fspan%3E%3C%2Fspan%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%3E%E8%AE%BE%E7%BD%AE%E7%9A%84%E4%B8%8A%E8%BE%B9%E7%95%8C%E4%B8%BA%E5%90%91%E5%89%8D%E6%97%A0%E8%BE%B9%E7%95%8C%E3%80%82%3C%2Fspan%3E%3C%2Fp%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%3E%3Ctd%20colspan%3D%5C%221%5C%22%20rowspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%20background-color%3A%20%23FFFFFF%3B%20color%3A%20%23404040%3B%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%20style%3D%5C%22color%3A%20%23404040%3B%5C%22%3Elower%3C%2Fspan%3E%3C%2Ftd%3E%3Ctd%20colspan%3D%5C%221%5C%22%20rowspan%3D%5C%221%5C%22%20style%3D%5C%22vertical-align%3A%20top%3B%20background-color%3A%20%23FFFFFF%3B%20color%3A%20%23404040%3B%5C%22%3E%3Cspan%20class%3D%5C%22lake-fontsize-11%5C%22%20style%3D%5C%22color%3A%20%23404040%3B%5C%22%3E%E8%AE%BE%E5%AE%9A%E7%AA%97%E5%8F%A3%E7%9A%84%E4%B8%8B%E8%BE%B9%E7%95%8C%EF%BC%8C%E8%BE%B9%E7%95%8C%E5%B1%9E%E6%80%A7%E8%AE%BE%E7%BD%AE%E5%90%8C%20upper%E3%80%82%3Cspan%3E%3Cspan%3E%E4%BE%8B%E5%A6%82%20Q1%20%E6%9F%A5%E8%AF%A2%3C%2Fspan%3E%3C%2Fspan%3E%E8%AE%BE%E7%BD%AE%E7%9A%84%E4%B8%8B%E8%BE%B9%E7%95%8C%E4%B8%BA%E5%BD%93%E5%89%8D%E8%A1%8C%E3%80%82%3C%2Fspan%3E%3C%2Ftd%3E%3C%2Ftr%3E%3C%2Ftbody%3E%3C%2Ftable%3E%22%2C%22margin%22%3Afalse%2C%22hideBorder%22%3Afalse%2C%22id%22%3A%2218kRY%22%7D" id="18kRY" data-tag="div" class="div"><table data-tag="table" id="table-5ga-h0g-i98" class="table"><colgroup span="1" width="140" data-tag="col" id="col-rxu-5a6-cjf" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup span="1" width="606" data-tag="col" id="col-1yz-eq1-fct" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-t5d-08w-d0r" class="thead"><tr id="tr-pb8-ytr-3uc"><th id="td-79l-2f4-x6f"><p id="p-vem-1h6-ba6"><b>信息名称</b></p></th><th id="td-4d6-dew-nwy"><p id="p-u8g-npj-oge"><b>含义</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-zqr-mca-y11" class="tbody"><tr data-tag="tr" id="tr-0ns-3wh-tey" class="tr"><td data-tag="td" id="td-zht-y4d-lja" class="td"><p id="p-mpt-2dm-zgk">output</p></td><td data-tag="td" id="td-1de-d2i-y1e" class="td"><p id="p-48c-jf1-htr">该算子输出的表达式。</p></td></tr><tr data-tag="tr" id="tr-124-57x-t57" class="tr"><td data-tag="td" id="td-08r-a3l-nun" class="td"><p id="p-3v4-w84-ws7">filter</p></td><td data-tag="td" id="td-uee-3mt-sfd" class="td"><p id="p-jk1-8f2-b5i">该算子上的过滤条件。</p><p id="p-vy2-7ut-9xn">由于示例中 WINDOW FUNCTION 算子没有设置 filter,所以为 nil。</p></td></tr><tr data-tag="tr" id="tr-nqr-pxn-fuz" class="tr"><td data-tag="td" id="td-277-qvw-nde" class="td"><p data-tag="p" id="p-0m9-cdd-79g" class="p">win_expr</p></td><td data-tag="td" id="td-4jn-mfq-gv5" class="td"><p data-tag="p" id="p-qml-5nz-xee" class="p">在窗口中使用何种聚合函数。</p><p data-tag="p" id="p-flu-1fz-if9" class="p">例如,Q1 查询为求 c1 列的最大值,因此为<code data-tag="code" class="code">T_FUN_MAX(t1.c1)</code>。</p></td></tr><tr data-tag="tr" id="tr-3rj-7mu-kpd" class="tr"><td data-tag="td" id="td-cya-izy-zp6" class="td"><p data-tag="p" id="p-tdy-qp9-u0y" class="p">partition_by</p></td><td data-tag="td" id="td-85m-cjl-r9c" class="td"><p data-tag="p" id="p-gek-72k-80p" class="p">在窗口中按照何种方式分组。</p><p data-tag="p" id="p-nn4-5pw-tcc" class="p">例如,Q1 查询为按照 c1 列分组,因此为 <code data-tag="code" class="code">t1.c1</code>。</p></td></tr><tr data-tag="tr" id="tr-7if-p4x-0mv" class="tr"><td data-tag="td" id="td-uw4-4eq-kqa" class="td"><p data-tag="p" id="p-lad-1nw-4f4" class="p">order_by</p></td><td data-tag="td" id="td-0cn-19z-ut6" class="td"><p data-tag="p" id="p-jix-hs3-fad" class="p">在窗口中按照何种方式排序。</p><p data-tag="p" id="p-zhm-lmz-wi8" class="p">例如,Q1 查询为按照 c2 列排序,因此为 <code data-tag="code" class="code">t1.c2</code>。</p></td></tr><tr data-tag="tr" id="tr-kz3-4ow-5fg" class="tr"><td data-tag="td" id="td-vvq-cn9-heb" class="td"><p data-tag="p" id="p-odm-fqu-ow0" class="p">window_type</p></td><td data-tag="td" id="td-o08-1v8-2w8" class="td"><p data-tag="p" id="p-mdg-lwn-259" class="p">窗口类型,包括 range 和 rows 两种:</p><ul id="ul-8cd-krc-8de"><li id="li-449-8r3-nwp"><p data-tag="p" id="p-ece-5jm-e7u" class="p">range :按照逻辑位置偏移进行计算窗口上下界限,默认使用 range 方式。</p></li><li id="li-dbe-mfu-iw2"><p data-tag="p" id="p-t1r-1ha-aca" class="p">rows :按照实际物理位置偏移进行计算窗口上下界限。</p></li></ul><p data-tag="p" id="p-4im-llg-xl3" class="p">例如,Q1 查询未设置窗口类型,因此选择了默认方式 range。</p></td></tr><tr data-tag="tr" id="tr-n5t-bci-oks" class="tr"><td data-tag="td" id="td-ict-0wr-4ut" class="td"><p id="p-hmu-0t3-sf5">upper</p></td><td data-tag="td" id="td-m16-eru-76d" class="td"><p data-tag="p" id="p-td0-3v1-g05" class="p">设定窗口的上边界:</p><ul lake-indent="0" data-tag="ul" id="ul-58c-qi9-lbd" class="ul"><li data-tag="li" id="li-mp9-cxr-08m" class="li"><p id="p-cmb-fb9-a5w">UNBOUNDED :无边界,选择最大的值(默认)。</p></li><li data-tag="li" id="li-ih2-ns5-9r7" class="li"><p id="p-53z-998-24u">CURRENT ROW :从当前行开始,如果出现数字则表示移动的行数。</p></li><li data-tag="li" id="li-btb-10v-275" class="li"><p id="p-wsu-u8h-or8">PRECEDING :向前取边</p></li><li data-tag="li" id="li-xem-cgl-cyx" class="li"><p id="p-thv-ckg-etb">FOLLOWING:向后取边界。</p></li></ul><p data-tag="p" id="p-p5o-7zx-x77" class="p">例如,Q1 查询设置的上边界为向前无边界。</p></td></tr><tr data-tag="tr" id="tr-sjx-9wn-nwi" class="tr"><td data-tag="td" id="td-2mq-ns0-hrm" class="td"><p id="p-riz-mm6-84i">lower</p></td><td data-tag="td" id="td-v1y-syf-h8g" class="td"><p id="p-u3t-3a8-mwr">设定窗口的下边界,边界属性设置同 upper。</p><p id="p-127-k3y-1bd">例如,Q1 查询设置的下边界为当前行。</p></td></tr></tbody></table></div>