project 运算符project operator

选择要包含、重命名或删除的列,并插入新的计算列。Select the columns to include, rename or drop, and insert new computed columns.

结果中的列顺序由参数的顺序指定。The order of the columns in the result is specified by the order of the arguments. 只有在参数中指定的列才包含在结果中。Only the columns specified in the arguments are included in the result. 输入中的任何其他列都会被删除。Any other columns in the input are dropped. (另请参阅 extend。)(See also extend.)

T | project cost=price*quantity, price


T | project ColumnName [= Expression ] [, ...]T | project ColumnName [= Expression ] [, ...]


T | project [ ColumnName | (ColumnName [,]) =] Expression [, ...]T | project [ ColumnName | (ColumnName [,]) =] Expression [, ...]


  • T :输入表。T : The input table.

  • ColumnName:要在输出中显示的列的可选名称。ColumnName: Optional name of a column to appear in the output. 如果没有 Expression,则 ColumnName 是必需的,输入中必须出现该名称的列。If there is no Expression , then ColumnName is mandatory and a column of that name must appear in the input. 如果省略该项,则会自动生成名称。If omitted, the name will be automatically generated. 如果 Expression 返回多个列,则可在括号中指定列名列表。If Expression returns more than one column, a list of column names can be specified in parentheses. 在这种情况下,会将指定的名称赋予 Expression 的输出列,并会删除所有其余的输出列(如果有)。In this case Expression 's output columns will be given the specified names, dropping all rest of the output columns, if there are any. 如果未指定列名列表,则 Expression 的所有具有生成名称的输出列都将添加到输出中。If list of the column names is not specified, all Expression 's output columns with generated names will be added to the output.

  • Expression :引用输入列的可选标量表达式。Expression: Optional scalar expression referencing the input columns. 如果未省略 ColumnName,则 Expression 是必需的。If ColumnName is not omitted then Expression is mandatory.

    允许返回与输入中现有列具有相同名称的新计算列。It is legal to return a new calculated column with the same name as an existing column in the input.


一个表,其中包含名为参数的列和与输入表中相同数量的行。A table that has the columns named as arguments, and as many rows as the input table.


以下示例演示可使用 project 运算符执行的几种操作。The following example shows several kinds of manipulations that can be done using the project operator. 输入表 T 具有属于 int 类型的三列:ABCThe input table T has three columns of type int: A, B, and C.

| project
    X=C,                       // Rename column C to X
    A=2*B,                     // Calculate a new column A from the old B
    C=strcat("-",tostring(C)), // Calculate a new column C from the old C
    B=2*B                      // Calculate a new column B from the old B

series_stats 是返回多个列的函数的示例。series_stats is an example of a function that returns multiple columns.