project-reorder
This page explains how to use the project-reorder operator in APL.
The project-reorder
operator in APL allows you to rearrange the fields of a dataset without modifying the underlying data. This operator is useful when you need to control the display order of fields in query results, making your data easier to read and analyze. It can be especially helpful when working with large datasets where field ordering impacts the clarity of the output.
Use project-reorder
when you want to emphasize specific fields by adjusting their order in the result set without changing their values or structure.
For users of other query languages
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Usage
Syntax
Parameters
Field1, Field2, ...
: The names of the fields in the order you want them to appear in the result set.[asc | desc | granny-asc | granny-desc]
: Optional: Specifies the sort order for the reordered fields.asc
ordesc
order fields by field name in ascending or descending manner.granny-asc
orgranny-desc
order by ascending or descending while secondarily sorting by the next numeric value. For example,b50
comes beforeb9
when you usegranny-asc
.
Returns
A table with the specified fields reordered as requested followed by any unspecified fields in their original order. project-reorder
doesn‘t rename or remove fields from the dataset. All fields that existed in the dataset appear in the results table.
Use case examples
In this example, you reorder HTTP log fields to prioritize the most relevant ones for log analysis.
Query
Output
_time | method | status | uri | req_duration_ms | geo.city | geo.country |
---|---|---|---|---|---|---|
2024-10-17 12:34:56 | GET | 200 | /home | 120 | New York | USA |
2024-10-17 12:35:01 | POST | 404 | /api/v1/resource | 250 | Berlin | Germany |
This query rearranges the fields for clarity, placing the most crucial fields (_time
, method
, status
) at the front for easier analysis.
Wildcard
Wildcard refers to a special character or a set of characters that can be used to substitute for any other character in a search pattern. Use wildcards to create more flexible queries and perform more powerful searches.
The syntax for wildcard can either be data*
or ['data.fo']*
.
Here’s how you can use wildcards in project-reorder
:
Reorder all fields in ascending order:
Reorder specific fields to the beginning:
Reorder fields using wildcards and sort in descending order:
Reorder specific fields and keep others in original order:
List of related operators
- project: Use the
project
operator to select and rename fields without changing their order. - extend:
extend
adds new calculated fields while keeping the original ones in place. - summarize: Use
summarize
to perform aggregations on fields, which can then be reordered usingproject-reorder
. - sort: Sorts rows based on field values, and the results can then be reordered with
project-reorder
.
Was this page helpful?