Documentation

testing.diff() function

testing.diff() produces a diff between two streams.

The function matches tables from each stream based on group keys. For each matched table, it produces a diff. Any added or removed rows are added to the table as a row. An additional string column with the name diff is created and contains a - if the row was present in the got table and not in the want table or + if the opposite is true.

diff() function emits at least one row if the tables are different and no rows if the tables are the same. The exact diff produced may change. diff() can be used to perform in-line diffs in a query.

Function type signature
(
    <-got: stream[A],
    want: stream[A],
    ?epsilon: B,
    ?nansEqual: C,
    ?verbose: D,
) => stream[{A with _diff: string}]

For more information, see Function type signatures.

Parameters

got

Stream containing data to test. Default is piped-forward data (<-).

want

(Required) Stream that contains data to test against.

epsilon

Specify how far apart two float values can be, but still considered equal. Defaults to 0.000000001.

verbose

Include detailed differences in output. Default is false.

nansEqual

Consider NaN float values equal. Default is false.

Examples

Output a diff between two streams of tables

import "sampledata"
import "testing"

want = sampledata.int()
got =
    sampledata.int()
        |> map(fn: (r) => ({r with _value: if r._value > 15 then r._value + 1 else r._value}))

testing.diff(got: got, want: want)

View example input

Return a diff between a stream of tables an the expected output

import "testing"

want = from(bucket: "backup-example-bucket") |> range(start: -5m)

from(bucket: "example-bucket")
    |> range(start: -5m)
    |> testing.diff(want: want)

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB v3 enhancements and InfluxDB Clustered is now generally available

New capabilities, including faster query performance and management tooling advance the InfluxDB v3 product line. InfluxDB Clustered is now generally available.

InfluxDB v3 performance and features

The InfluxDB v3 product line has seen significant enhancements in query performance and has made new management tooling available. These enhancements include an operational dashboard to monitor the health of your InfluxDB cluster, single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management APIs for tokens and databases.

Learn about the new v3 enhancements


InfluxDB Clustered general availability

InfluxDB Clustered is now generally available and gives you the power of InfluxDB v3 in your self-managed stack.

Talk to us about InfluxDB Clustered