Using the two datasets above, I mocked up my own join and it works:
import "array"
import "join"
measuresData = array.from(rows: [
{_start: 2024-04-14T13:48:05.430187948Z, _stop: 2024-04-24T13:48:05.430187948Z, _time: 2024-04-23T06:50:49.729Z, _value: 144.06561, _field: "value", _measurement: "ActivePower", datatype: "0", measure_id: "12"},
{_start: 2024-04-14T13:48:05.430187948Z, _stop: 2024-04-24T13:48:05.430187948Z, _time: 2024-04-23T06:50:50.227Z, _value: 143.37552, _field: "value", _measurement: "ActivePower", datatype: "0", measure_id: "12"},
{_start: 2024-04-14T13:48:05.430187948Z, _stop: 2024-04-24T13:48:05.430187948Z, _time: 2024-04-23T06:50:50.728Z, _value: 143.27747, _field: "value", _measurement: "ActivePower", datatype: "0", measure_id: "12"},
{_start: 2024-04-14T13:48:05.430187948Z, _stop: 2024-04-24T13:48:05.430187948Z, _time: 2024-04-23T06:50:51.227Z, _value: 146.62433, _field: "value", _measurement: "ActivePower", datatype: "0", measure_id: "12"},
{_start: 2024-04-14T13:48:05.430187948Z, _stop: 2024-04-24T13:48:05.430187948Z, _time: 2024-04-23T06:50:51.729Z, _value: 149.68327, _field: "value", _measurement: "ActivePower", datatype: "0", measure_id: "12"},
])
measuresInfos = array.from(rows: [
{id: 8, description: "Air flow", type: "FlowRate", input_type: 4},
{id: 9, description: "Glycoled water flow", type: "FlowRate", input_type: 4},
{id: 10, description: "Temp IN", type: "Temperature", input_type: 1},
{id: 11, description: "Temp OUT", type: "Temperature", input_type: 1},
{id: 12, description: "Global active power", type: "ActivePower", input_type: 4},
{id: 13, description: "Global reactive power", type: "ReactivePower", input_type: 4},
{id: 14, description: "Global apparent power", type: "ApparentPower", input_type: 4},
])
|> map(fn: (r) => ({r with id: string(v: r.id)}))
join.left(
left: measuresData,
right: measuresInfos,
on: (l, r) => l.measure_id == r.id,
as: (l, r) => ({l with description: r.description, id: r.id}),
)
Which returns the following (with the _start
and _stop
columns removed for brevity):
_field |
_measurement |
_time |
_value |
datatype |
description |
id |
measure_id |
value |
ActivePower |
2024-04-23T06:50:49.729Z |
144.06561 |
|
Global active power |
12 |
12 |
value |
ActivePower |
2024-04-23T06:50:50.227Z |
143.37552 |
|
Global active power |
12 |
12 |
value |
ActivePower |
2024-04-23T06:50:50.728Z |
143.27747 |
|
Global active power |
12 |
12 |
value |
ActivePower |
2024-04-23T06:50:51.227Z |
146.62433 |
|
Global active power |
12 |
12 |
value |
ActivePower |
2024-04-23T06:50:51.729Z |
149.68327 |
|
Global active power |
12 |
12 |
Assuming my datatypes are correct in measuresInfo
, your join should work.