join
This page explains how to use the join operator in APL.
The join operator in Axiom Processing Language (APL) combines rows from two datasets based on matching values in specified columns. Use join to correlate data from different sources or datasets, such as linking logs to traces or enriching logs with additional metadata.
This operator is useful when you want to:
- Combine information from two datasets with shared keys.
- Analyze relationships between different types of events.
- Enrich existing data with supplementary details.
Kinds of join
The join operator supports the following kinds of join:
inner(default): Returns rows where the join conditions exist in both datasets. All matching rows from the right dataset are included for each matching row in the left dataset. Useful to retain all matches without limiting duplicates.innerunique: Keeps one row for each join key in the left dataset. For each of these rows, returns all matching rows from the right dataset. Useful when duplicate rows in the left dataset are irrelevant.leftouter: Returns all rows from the left dataset. If a match exists in the right dataset, the matching rows are included. Otherwise, columns from the right dataset arenull. Retains all data from the left dataset, enriching it with matching data from the right dataset.
APL doesn’t support these kinds of join: rightouter, fullouter, leftanti, rightanti, leftsemi, and rightsemi.
Summary of kinds of join
| Kind of join | Behavior | Matches returned |
|---|---|---|
inner | All matches between left and right datasets | Multiple matches allowed |
innerunique | One left row for each join key, with all right matches | One left row per key |
leftouter | All rows from the left, with matching rows from the right or null | Left-dominant |
Choose the right kind of join
- Use
innerfor standard joins where you need all matches. - Use
inneruniquewhen duplicate join keys in the left dataset are irrelevant. - Use
leftouterwhen you need to retain all rows from the left dataset.
Usage
Syntax
Parameters
LeftDataset: The first dataset, also known as the outer dataset or the left side of the join. If you expect one of the datasets to contain consistently less data than the other, specify the smaller dataset as the left side of the join.RightDataset: The second dataset, also known as the inner dataset or the right side of the join.KindOfJoin: Optionally, the kind of join to perform.Conditions: The conditions for matching rows. The conditions are equality expressions that determine how Axiom matches rows from theLeftDataset(left side of the equality expression) with rows from theRightDataset(right side of the equality expression). The two sides of the equality expression must have the same data type.- To join datasets on a field that has the same name in the two datasets, simply use the field name. For example,
on id. - To join datasets on a field that has different names in the two datasets, define the two field names in an equality expression such as
on id == trace_id. - You can use expressions in the join conditions. For example, to compare two fields of different data types, use
on id_string == tostring(trace_id_int). - You can define multiple join conditions. To separate conditions, use commas (
,). Don’t useand. For example,on id == trace_id, span == span_id.
- To join datasets on a field that has the same name in the two datasets, simply use the field name. For example,
Returns
The join operator returns a new table containing rows that match the specified join condition. The fields from the left and right datasets are included.
Limits
Axiom queries each side of the join separately. Each side has a row limit that grows when the side has fewer fields.
To stay within the limits:
- Filter and aggregate each side before the join.
- Project only the fields that you need on each side.
- Specify the smaller dataset as the left side of the join.
If a side exceeds its limit, Axiom truncates that side, and the result can be incomplete. The query returns one of these warnings:
Left-hand side of join was truncated by a row limit; results may be incompleteRight-hand side of join was truncated by a row limit; results may be incomplete
If the left side has many fields, the query can fail with a join limit error instead of returning a warning. To avoid the error, project fewer fields on the left side.
Use case example
Join HTTP logs with trace data to correlate user activity with performance metrics.
Query
Output
| _time | trace_id | span_id | service.name | duration |
|---|---|---|---|---|
| 2024-12-01 | trace123 | span123 | frontend | 500ms |
This query links user activity in HTTP logs to trace data to investigate performance issues.
List of related operators
- union: Combines rows from multiple datasets without requiring a matching condition.
- where: Filters rows based on conditions, often used with
joinfor more precise results.