project
This page explains how to use the project operator in APL.
project operator
The project
operator in Axiom Processing Language (APL) is used to select specific fields from a dataset, potentially renaming them or applying calculations on the fly. With project
, you can control which fields are returned by the query, allowing you to focus on only the data you need.
This operator is useful when you want to refine your query results by reducing the number of fields, renaming them, or deriving new fields based on existing data. It’s a powerful tool for filtering out unnecessary fields and performing light transformations on your dataset.
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
Or
Or
Parameters
FieldName
: The names of the fields in the order you want them to appear in the result set. If there is no Expression, then FieldName is compulsory and a field of that name must appear in the input.Expression
: Optional scalar expression referencing the input fields.
Returns
The project
operator returns a dataset containing only the specified fields.
Use case examples
In this example, you’ll extract the timestamp, HTTP status code, and request URI from the sample HTTP logs.
Query
Output
_time | status | uri |
---|---|---|
2024-10-17 12:00:00 | 200 | /api/v1/getData |
2024-10-17 12:01:00 | 404 | /api/v1/getUser |
The query returns only the timestamp, HTTP status code, and request URI, reducing unnecessary fields from the dataset.
List of related operators
- extend: Use
extend
to add new fields or calculate values without removing any existing fields. - summarize: Use
summarize
to aggregate data across groups of rows, which is useful when you’re calculating totals or averages. - where: Use
where
to filter rows based on conditions, often paired withproject
to refine your dataset further.
Was this page helpful?