

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 窗口函数
<a name="recipe-actions.functions.window"></a>

以下为与配方操作配合使用的窗口函数的参考主题。

**Topics**
+ [FILL](recipe-actions.functions.FILL.md)
+ [NEXT](recipe-actions.functions.NEXT.md)
+ [PREV](recipe-actions.functions.PREV.md)
+ [ROLLING\$1AVERAGE](recipe-actions.functions.ROLLING_AVERAGE.md)
+ [ROLLING\$1COUNT\$1A](recipe-actions.functions.ROLLING_COUNT_A.md)
+ [ROLLING\$1KTH\$1LARGEST](recipe-actions.functions.ROLLING_KTH_LARGEST.md)
+ [ROLLING\$1KTH\$1LARGEST\$1UNIQUE](recipe-actions.functions.ROLLING_KTH_LARGEST_UNIQUE.md)
+ [ROLLING\$1MAX](recipe-actions.functions.ROLLING_MAX.md)
+ [ROLLING\$1MIN](recipe-actions.functions.ROLLING_MIN.md)
+ [ROLLING\$1MODE](recipe-actions.functions.ROLLING_MODE.md)
+ [ROLLING\$1STANDARD\$1DEVIATION](recipe-actions.functions.ROLLING_STANDARD_DEVIATION.md)
+ [ROLLING\$1SUM](recipe-actions.functions.ROLLING_SUM.md)
+ [ROLLING\$1VARIANCE](recipe-actions.functions.ROLLING_VARIANCE.md)
+ [ROW\$1NUMBER](recipe-actions.functions.ROW_NUMBER.md)
+ [SESSION](recipe-actions.functions.SESSION.md)

# FILL
<a name="recipe-actions.functions.FILL"></a>

根据指定的源列返回新列。对于源列中的任何缺失值或 null 值，`FILL` 将从相关源值前后的行窗口中选择最近的非空值。然后，将所选值放到新列中。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "FILL",
        "Parameters": {
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "last_name",
            "targetColumn": "last_name_FILL"
        }
    }
}
```

# NEXT
<a name="recipe-actions.functions.NEXT"></a>

返回一个新列，其中每个值都表示源列中之后 *n* 行的值。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRows`：表示源列中之前 *n* 行的值。例如，如果 `numRows` 为 3，则 `NEXT` 使用接下来的第三个 `sourceColumn` 值作为新 `targetColumn` 值。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "NEXT",
        "Parameters": {
            "numRows": "1",
            "sourceColumn": "age",
            "targetColumn": "age_NEXT"
        }
    }
}
```

# PREV
<a name="recipe-actions.functions.PREV"></a>

返回一个新列，其中每个值都表示源列中之前 *n* 行的值。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRows`：表示源列中之前 *n* 行的值。例如，如果 `numRows` 为 3，则 `PREV` 使用前面的第三个 `sourceColumn` 值作为新 `targetColumn` 值。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "PREV",
        "Parameters": {
            "numRows": "1",
            "sourceColumn": "age",
            "targetColumn": "age_PREV"
        }
    }
}
```

# ROLLING\$1AVERAGE
<a name="recipe-actions.functions.ROLLING_AVERAGE"></a>

在新列中返回指定列中当前行前后指定行数的值的移动平均值。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROLLING_AVERAGE",
        "Parameters": {
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "weight_kg",
            "targetColumn": "weight_kg_ROLLING_AVERAGE"
        }
    }
}
```

# ROLLING\$1COUNT\$1A
<a name="recipe-actions.functions.ROLLING_COUNT_A"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的非 null 值的滚动计数。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROLLING_COUNT_A",
        "Parameters": {
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "weight_kg",
            "targetColumn": "weight_kg_ROLLING_COUNT_A"
        }
    }
}
```

# ROLLING\$1KTH\$1LARGEST
<a name="recipe-actions.functions.ROLLING_KTH_LARGEST"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的第 *k* 大滚动值。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `value`：*k* 的值。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
  {
    "Action": {
      "Operation": "ROLLING_KTH_LARGEST",
      "Parameters": {
        "sourceColumn": "weight_kg",
        "numRowsBefore": "5",
        "numRowsAfter": "5",
        "value": "3"
        "targetColumn": "weight_kg_ROLLING_KTH_LARGEST"
      }
    }
  }
```

# ROLLING\$1KTH\$1LARGEST\$1UNIQUE
<a name="recipe-actions.functions.ROLLING_KTH_LARGEST_UNIQUE"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的第 *k* 大滚动唯一值。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `value`：*k* 的值。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
  {
    "Action": {
      "Operation": "ROLLING_KTH_LARGEST_UNIQUE",
      "Parameters": {
        "sourceColumn": "games_played",
        "numRowsBefore": "3",
        "numRowsAfter": "3",
        "value": "5",
        "targetColumn": "weight_kg_ROLLING_KTH_LARGEST_UNIQUE"
      }
    }
  }
```

# ROLLING\$1MAX
<a name="recipe-actions.functions.ROLLING_MAX"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的值的滚动最大值。

**参数**
+ `sourceColumn`：现有列的名称。

  `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROLLING_MAX",
        "Parameters": {
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "weight_kg",
            "targetColumn": "weight_kg_ROLLING_MAX"
        }
    }
}
```

# ROLLING\$1MIN
<a name="recipe-actions.functions.ROLLING_MIN"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的值的滚动最小值。

**参数**
+ `sourceColumn`：现有列的名称。

  `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROLLING_MIN",
        "Parameters": {
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "weight_kg",
            "targetColumn": "weight_kg_ROLLING_MIN"
        }
    }
}
```

# ROLLING\$1MODE
<a name="recipe-actions.functions.ROLLING_MODE"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的滚动模式（最常见的值）。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ modeType：要应用于窗口的模态函数。有效值为 `NONE`、`MINIMUM`、`MAXIMUM` 和 `AVERAGE`。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROLLING_MODE",
        "Parameters": {
            "modeType": "MINIMUM",
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "weight_kg",
            "targetColumn": "weight_kg_ROLLING_MODE"
        }
    }
}
```

# ROLLING\$1STANDARD\$1DEVIATION
<a name="recipe-actions.functions.ROLLING_STANDARD_DEVIATION"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的值的滚动标准差。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROLLING_STDEV",
        "Parameters": {
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "weight_kg",
            "targetColumn": "weight_kg_ROLLING_STDEV"
        }
    }
}
```

# ROLLING\$1SUM
<a name="recipe-actions.functions.ROLLING_SUM"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的值的滚动总和。

**参数**
+ `sourceColumn`：现有列的名称。

  `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROLLING_SUM",
        "Parameters": {
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "weight_kg",
            "targetColumn": "weight_kg_ROLLING_SUM"
        }
    }
}
```

# ROLLING\$1VARIANCE
<a name="recipe-actions.functions.ROLLING_VARIANCE"></a>

在新列中返回指定列中当前行之前指定行数到当前行之后指定行数的值的滚动方差。

**参数**
+ `sourceColumn`：现有列的名称。
+ `numRowsBefore`：当前源行之前的行数，表示窗口开始。
+ `numRowsAfter`：当前源行之后的行数，表示窗口结束。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROLLING_VAR",
        "Parameters": {
            "numRowsAfter": "10",
            "numRowsBefore": "10",
            "sourceColumn": "weight_kg",
            "targetColumn": "weight_kg_ROLLING_VAR"
        }
    }
}
```

# ROW\$1NUMBER
<a name="recipe-actions.functions.ROW_NUMBER"></a>

根据按“分组依据”和“排序依据”语句中的列名称创建的窗口，在新列中返回会话标识符。

**参数**
+ `groupByColumns`：描述“分组依据”列的 JSON 编码字符串。
+ `orderByColumns`：描述“排序依据”列的 JSON 编码字符串。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "ROW_NUMBER",
        "Parameters": {
            "groupByColumns": "[\"is public domain\"]",
            "orderByColumns": "[\"dimensions\"]",
            "targetColumn": "Row number"
        }
    }
}
```

# SESSION
<a name="recipe-actions.functions.SESSION"></a>

根据按“分组依据”和“排序依据”语句中的列名称创建的窗口，在新列中返回会话标识符。

**参数**
+ `sourceColumn`：现有列的名称。
+ `units`：描述会话时长的计量单位。有效值为 `MONTHS`、`YEARS`、`MILLISECONDS`、`QUARTERS`、`HOURS`、`MICROSECONDS`、`WEEKS`、`SECONDS`、`DAYS` 和 `MINUTES`。
+ `value`：用于定义时间段的 `units` 数。
+ `groupByColumns`：描述“分组依据”列的 JSON 编码字符串。
+ `orderByColumns`：描述“排序依据”列的 JSON 编码字符串。
+ `targetColumn`：新创建的列的名称。

**Example 示例**  
  

```
{
    "Action": {
        "Operation": "SESSION",
        "Parameters": {
            "sourceColumn": "object number",
            "units": "MINUTES",
            "value": "10",
            "groupByColumns": "[\"is public domain\"]",
            "orderByColumns": "[\"dimensions\"]",
            "targetColumn": "object number_SESSION",
        }
    }
}
```