Back to Influxdb

join.inner() function

content/flux/v0/stdlib/join/inner.md

latest3.0 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/join/join.flux#L311-L318 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

join.inner() performs an inner join on two table streams.

The function calls join.tables() with the method parameter set to "inner".

Function type signature
js
(<-left: stream[A], as: (l: A, r: B) => C, on: (l: A, r: B) => bool, right: stream[B]) => stream[C] where A: Record, B: Record, C: Record

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

left

Left input stream. Default is piped-forward data (<-).

({{< req >}}) Right input stream.

on

({{< req >}}) Function that takes a left and right record (l, and r respectively), and returns a boolean.

The body of the function must be a single boolean expression, consisting of one or more equality comparisons between a property of l and a property of r, each chained together by the and operator.

as

({{< req >}}) Function that takes a left and a right record (l and r respectively), and returns a record. The returned record is included in the final output.

Examples

Perform an inner join

js
import "sampledata"
import "join"

ints = sampledata.int()
strings = sampledata.string()

join.inner(
    left: ints,
    right: strings,
    on: (l, r) => l._time == r._time,
    as: (l, r) => ({l with label: r._value}),
)

{{< expand-wrapper >}} {{% expand "View example output" %}}

Output data

_time_valuelabel*tag
2021-01-01T00:00:00Z-2smpl_g9qczst1
2021-01-01T00:00:10Z10smpl_0mgv9nt1
2021-01-01T00:00:20Z7smpl_phw664t1
2021-01-01T00:00:30Z17smpl_guvzy4t1
2021-01-01T00:00:40Z15smpl_5v3ccet1
2021-01-01T00:00:50Z4smpl_s9fmgyt1
_time_valuelabel*tag
2021-01-01T00:00:00Z19smpl_b5eidat2
2021-01-01T00:00:10Z4smpl_eu4oxpt2
2021-01-01T00:00:20Z-3smpl_5g7tz4t2
2021-01-01T00:00:30Z19smpl_sox1utt2
2021-01-01T00:00:40Z13smpl_wfm757t2
2021-01-01T00:00:50Z1smpl_dtn2bvt2

{{% /expand %}} {{< /expand-wrapper >}}