Search code examples
influxdbinfluxdb-2

Flux Query : join.inner() returns nothing if I don't limit my stream used


I get an issue understanding how to use the join.inner() function. It seems I can only have a result (and the correct one) if I use the limit() function to the stream I want to use the join.inner function with.

If don't limit this left stream, I don't get any error but just no result. It is because of how I get my left stream ? Do you have any idea what I am doing wrong here ?

I am pretty new using InfluxDB therefore the flux language so it must be me.

Thank you all for your answers !

import "array"
import "join"

left =
    from(bucket: "TestBucket")
    |> range(start: 0)
    |> filter(fn: (r) => r["_measurement"] == "TestMeasurement")
    |> limit(n : 1000000000000000000)
    |> group()
     //|> yield(name: "LEFT")
    

right =
    array.from(
        rows: [
            {arrayValue: "123", _time: 2023-02-07T12:00:00.000Z}, //This timestamp exists in the left stream
        ],
    )
    //|> yield(name: "RIGHT")

result = join.inner(
    left: left,
    right: right,
    on: (l, r) => l._time == r._time, // I made sure that there is indeed a common time 
    as: (l, r) => ({l with rightValue: r.arrayValue}),
)
    |> yield(name: "RESULT") 

Solution

  • Ok, the solution was to group by _time column the stream AND the table : |> group(columns: ["_time"])