influxdata / flux

Flux is a lightweight scripting language for querying databases (like InfluxDB) and working with data. It's part of InfluxDB 1.7 and 2.0, but can be run independently of those.
https://influxdata.com
MIT License
769 stars 153 forks source link

Join does not work properly: maybe missing documentation #5429

Closed FStefanni closed 1 year ago

FStefanni commented 1 year ago

Hi,

I have taken the example of the documentation on the left join, and changed a little, and tested on InfluxDB. This is the code:

import "array"
import "join"

left =
    array.from(
        rows: [
            {_time: 2022-01-01T00:00:00Z, _value: 1, label: "a"},
            {_time: 2022-01-02T00:00:00Z, _value: 2, label: "b"},
            {_time: 2022-01-03T00:00:00Z, _value: 3, label: "d"},
        ],
    )

right =
    array.from(
        rows: [
            {_time: 2022-01-01T00:00:00Z, _value: 0.4, id: "a"},
            {_time: 2022-01-02T00:00:00Z, _value: 0.5, id: "c"},
            {_time: 2022-01-03T00:00:00Z, _value: 0.6, id: "d"},
        ],
    )

join.left(
    left: left,
    right: right,
    on: (l, r) => l.label == r.id and l._time == r._time,
    as: (l, r) => r,
)

And the result is:

In general, I have also done a lot of other tests on actual data, and very often the join result is bugged/unexpected. So I am wandering whether there is a huge bug on join, or maybe there are some assumptions not written in the documentation.

Regards

github-actions[bot] commented 1 year ago

This issue has had no recent activity and will be closed soon.