influxdata / influxdb-client-go

InfluxDB 2 Go Client
MIT License
609 stars 116 forks source link

TableChanged() doesn't detect yield() boundaries #372

Closed redbaron closed 1 year ago

redbaron commented 1 year ago

Specifications

Steps to reproduce

Iterate over result from following query

import "sampledata"

s = sampledata.int() |> filter(fn: (r) => r.tag == "t1")
s |> map(fn: (r) => ({r with xyz: 99})) |> yield(name: "t1")
s |> map(fn: (r) => ({r with abc: ""})) |> yield(name: "t2")

using standard pattern:

for r.Next() {
  if r.TableChanged() {
     row := r.Record()
     fmt.Printf("result=%s table=%s\n" , row.Result(), row.Table())
  }
}

Expected behavior

I'd expect TableChanged() to trigger twice

Actual behavior

TableChanged() doesn't take into account change of result created by yield.

Additional info

No response

redbaron commented 1 year ago

OK, it seems that TablChanged() correctly reports new .Result(), but not .Record().Table() within Result(), which has to be tracked manually.