Back to Influxdb

join.time() function

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

latest2.9 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#L265-L272 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

join.time() joins two table streams together exclusively on the _time column.

This function calls join.tables() with the on parameter set to (l, r) => l._time == r._time.

Function type signature
js
(
    <-left: stream[{A with _time: B}],
    as: (l: {A with _time: B}, r: {C with _time: D}) => E,
    right: stream[{C with _time: D}],
    ?method: string,
) => stream[E] where B: Equatable, D: Equatable, E: Record

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

Parameters

left

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

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

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.

method

String that specifies the join method. Default is inner.

Supported methods:

  • inner
  • left
  • right
  • full

Examples

Join two tables by timestamp

js
import "sampledata"
import "join"

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

join.time(left: ints, right: strings, 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 >}}