project-reorder operator
Reorders columns in the result output.
T | project-reorder Col2, Col1, Col* asc
Syntax
T | project-reorder ColumnNameOrPattern [asc | desc | granny-asc | granny-desc] [, ...]
Arguments
- T: The input table.
- ColumnNameOrPattern: The name of the column or column wildcard pattern added to the output.
- For wildcard patterns: Specifying
ascordescorders columns using their names in ascending or descending manner. Additionally,granny-ascandgranny-desckeywords indicate ascending or descending order that takes numeric values into account (for example,a100comes beforea20whengranny-ascis specified.) If no explicit ordering is specified, the order is determined by the matching columns as they appear in the source table.
Note
- In ambiguous ColumnNameOrPattern matching, the column appears in the first position matching the pattern.
- Specifying columns for the
project-reorderis optional. Columns that aren't specified explicitly appear as the last columns of the output table. - To remove columns, use
project-away. - To choose which columns to keep, use
project-keep. - To rename columns, use
project-rename.
Returns
A table that contains columns in the order specified by the operator arguments. 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
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
| b | a | c |
|---|---|---|
| b | a | c |
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
| a1 | a2 | a3 | b |
|---|---|---|---|
| a1 | a2 | a3 | b |
Feedback
Submit and view feedback for