project-reorder 运算符project-reorder operator

对结果输出中的列重新排序。Reorders columns in the result output.

T | project-reorder Col2, Col1, Col* asc

语法Syntax

T | project-reorder ColumnNameOrPattern [asc|desc] [, ...] T | project-reorder ColumnNameOrPattern [asc|desc] [, ...]

参数Arguments

  • T :输入表。T : The input table.
  • ColumnNameOrPattern:添加到输出中的列或列通配符模式的名称。ColumnNameOrPattern: The name of the column or column wildcard pattern added to the output.
  • 对于通配符模式:指定 ascdesc 使用其名称按升序或降序对列进行排序。For wildcard patterns: specifying asc or desc orders columns using their names in ascending or descending order. 如果未指定 ascdesc,则顺序取决于源表中显示的匹配列。If asc or desc aren't specified, the order is determined by the matching columns as they appear in the source table.

备注

  • 在 ColumnNameOrPattern 模糊匹配中,该列出现在与模式匹配的第一个位置。In ambiguous ColumnNameOrPattern matching, the column appears in the first position matching the pattern.
  • project-reorder 指定列是可选操作。Specifying columns for the project-reorder is optional. 未显式指定的列将显示为输出表的最后一列。Columns that aren't specified explicitly appear as the last columns of the output table.
  • 若要删除列,请使用 project-awayTo remove columns, use project-away.
  • 若要选择要保留的列,请使用 project-keepTo choose which columns to keep, use project-keep.
  • 若要重命名列,请使用 project-renameTo rename columns, use project-rename.

返回Returns

一张表,其中包含按运算符参数指定的顺序排列的列。A table that contains columns in the order specified by the operator arguments. project-reorder 不会重命名或删除表中的列,因此,源表中存在的所有列都将出现在结果表中。project-reorder doesn't rename or remove columns from the table, therefore, all columns that existed in the source table, appear in the result table.

示例Examples

对包含三列 (a, b, c) 的表重新排序,使第二列 (b) 显示在最前面。Reorder a table with three columns (a, b, c) so the second column (b) will appear first.

print a='a', b='b', c='c'
|  project-reorder b
bb aa cc
bb aa cc

对表中的列重新排序,使以 a 开头的列显示在其他列之前。Reorder columns of a table so that columns starting with a will appear before other columns.

print b = 'b', a2='a2', a3='a3', a1='a1'
|  project-reorder a* asc
a1a1 a2a2 a3a3 bb
a1a1 a2a2 a3a3 bb