influxdb-client-go icon indicating copy to clipboard operation
influxdb-client-go copied to clipboard

`*api.QueryTableResult` `TableChanged` and `TablePosition` not working

Open paulheg opened this issue 11 months ago • 1 comments

Specifications

  • Client Version: v2.12.4
  • InfluxDB Version: v2.7.5
  • Platform: Linux

Steps to reproduce

  1. Write a query with different tables
  2. Try to scan them:
res, err := q.api.Query(context.Background(), query)
if err != nil {
	return nil, err
}

for res.Next() {

	// should be true if table position changes?
	if res.TableChanged() {

	}

	// table position
	i1 := res.TablePosition()

        valueMap := res.Record().Values()
	i2 := valueMap["table"].(int64)

	if i1 != i2 {
		log.Printf("Table positions differ: %d, %d", i1, i2)
	}
}

Expected behavior

TableChanged should be true if the table number changes and TablePosition should contain the current table number.

Actual behavior

TableChanged returns true only once TablePosition is stuck at 0.

Additional info

Im not shure if this is the intended behaviour. As a workaroud I used:

valueMap := res.Record().Values()
tablePosition := valueMap["table"].(int64)

paulheg avatar Mar 06 '24 15:03 paulheg

Hi @paulheg,

Thank you for using our client and taking the time to report the issue you've encountered. Your feedback is invaluable to us as it helps improve the quality and reliability of our software.

To address the issue more effectively, we would greatly appreciate your assistance. If you're open to contributing, we welcome Pull Requests (PRs) and would be more than happy to review your submission.

Alternatively, if you could provide a unit test case that simulates the issue, it would greatly aid us in diagnosing and addressing the problem more efficiently.

Best Regards

bednar avatar Mar 07 '24 13:03 bednar

@paulheg, I see your point. However, the problem is in the annotated-cvs format, where the term table is overloaded:

  1. Table is the block of data starting with annotations. It is also referred as result
  2. Table is a column indicating change in series (grouping columns combinations)

This client uses TableChanged and TablePosition fields for the 1st definition because they indicate a change in the data structure.

Edit: You can use FluxRecord.Table() to read value of the table column

vlastahajek avatar Jul 31 '24 12:07 vlastahajek