Documentation

experimental.join() function

The experimental.join() function is subject to change at any time. By using this function, you accept the risks of experimental functions.

The experimental.join() function joins two streams of tables on the group key and _time column. Use the fn parameter to map new output tables using values from input tables.

To join streams of tables with different fields or measurements, use group() or drop() to remove _field and _measurement from the group key before joining. See an example below.

Function type: Transformation

import "experimental"

// ...

experimental.join(
  left: left,
  right: right,
  fn: (left, right) => ({left with lv: left._value, rv: right._value })
)

This function will likely replace the join function when sufficiently vetted.

Parameters

left

First of two streams of tables to join.

Data type: Stream of tables

Second of two streams of tables to join.

Data type: Stream of tables

fn

A function with left and right arguments that maps a new output record using values from the left and right input records. The return value must be a record.

Data type: Function

Examples

Input and output tables

Given the following input tables:

left
_time_field_value
0001temp80.1
0002temp80.2
0003temp79.9
0004temp80.0
_time_field_value
0001temp72.1
0002temp72.2
0003temp71.9
0004temp72.0

The following experimental.join() function would output:

import "experimental"

experimental.join(
  left: left,
  right: right,
  fn: (left, right) => ({
    left with
    lv: left._value,
    rv: right._value,
    diff: left._value - right._value
  })
)
_time_fieldlvrvdiff
0001temp80.172.18.0
0002temp80.272.28.0
0003temp79.971.98.0
0004temp80.072.08.0

Join two streams of tables
import "experimental"

s1 = from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "foo")

s2 = from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "bar")

experimental.join(
  left: s1,
  right: s2,
  fn: (left, right) => ({
    left with
    s1_value: left._value,
    s2_value: right._value
  })
)
Join two streams of tables with different fields and measurements
import "experimental"

s1 = from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "foo" and r._field == "bar")
  |> group(columns: ["_time", "_measurement", "_field", "_value"], mode: "except")

s2 = from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "baz" and r._field == "quz")
  |> group(columns: ["_time", "_measurement", "_field", "_value"], mode: "except")

experimental.join(
  left: s1,
  right: s2,
  fn: (left, right) => ({
    left with
    bar_value: left._value,
    quz_value: right._value
  })
)

New! Cloud or OSS?

InfluxDB OSS 2.0 release candidate 0

InfluxDB OSS v2.0.rc0 includes breaking changes that require a manual upgrade from all alpha and beta versions. For information, see:

Upgrade to InfluxDB OSS v2.0.rc0