Hi,
I’m doing a simple join of two tables. The resulting “joined” table I want to display in a grafana table panel.
The problem is the join() function requires me to call yield() on the left consumption table first, otherwise nothing is returned from the join. But this causes an issue in that the grafana table panel shows both the previous left consumption and joined table in the UI as a dropdown. I only want to show the joined table. I remember in older versions of flux it was possible to do this without calling yield() on the prior tables used in the join - has something changed?
import "array"
import "join"
arr = [
{tenant_id: "1", tenant_name: "OrgA", meter_id: "CCC_L01_M9_R514", bill_meter_id: "22"},
{tenant_id: "1", tenant_name: "OrgA", meter_id: "CCC_L01_M1_R45099", bill_meter_id: "22"},
{tenant_id: "2", tenant_name: "OrgB", meter_id: "CCC_L01_M14_R45099", bill_meter_id: "22"}
]
metadata = array.from(rows: arr)
//|> yield(name: "metadata")
consumption = from(bucket: "pe")
|> range(start: 2023-03-01T00:00:00.00Z, stop: 2023-03-01T02:00:00.00Z)
|> filter(fn: (r) => r["_measurement"] == "electricity")
|> yield(name: "consumption")
jj = join.tables(
method: "inner",
left: consumption |> group(),
right: metadata ,
on: (l, r) => l.meter_id == r.meter_id,
as: (l, r) => ({l with bill_meter_id: r.bill_meter_id}),
)
|> yield(name:"joined")