Repository: influxdata/influxdb-client-go (go)

Issue:
Query API does not expose table's name
I have a Flux query that yields two distinct tables:

```
import "generate"

generate.from(count: 1, fn: (n) => 0, start: now(), stop: now())
  |> yield(name: "foo")

generate.from(count: 1, fn: (n) => 1, start: now(), stop: now())
  |> yield(name: "bar")
```

The resulting CSV is formatted like this:

```csv
#group,false,false,false,false
#datatype,string,long,dateTime:RFC3339,long
#default,foo,,,
,result,table,_time,_value
,,0,2021-11-09T20:50:58.440510582Z,0

#group,false,false,false,false
#datatype,string,long,dateTime:RFC3339,long
#default,bar,,,
,result,table,_time,_value
,,0,2021-11-09T20:50:58.440510582Z,1
```

The raw data view in the UI understands the table names:

![Screen Shot 2021-11-09 at 3 52 59 PM](https://user-images.githubusercontent.com/290647/141002865-846e0395-39f2-41a9-98ac-83f86a03b278.png)

However, the Go client only exposes the table numbers: https://pkg.go.dev/github.com/influxdata/influxdb-client-go/v2@v2.5.1/api/query#FluxTableMetadata

AFAICS there is no way to access the table name, which prevents me from easily consuming queries with yield. To the best of my knowledge, with real queries that take time to execute, the table ID is unpredictable and cannot be used to determine which table is which.

Pull request:
feat: adding FluxRecord.Result() function
Closes #283

## Proposed Changes

Added *FluxRecord.Result()* function as a convenient way to retrieve the Flux result name of data.
The `Result()` function extends collection of already existing accessor functions: `Table(), Start(), Stop(), Time(),  Measurement() and Value()`

## Checklist

<!-- Checkboxes below this note can be erased if not applicable to your Pull Request. -->

- [X] CHANGELOG.md updated
- [X] Rebased/mergeable
- [X] A test has been added if appropriate
- [X] Tests pass
- [X] Commit messages are in [semantic format](https://seesparkbox.com/foundry/semantic_commit_messages)



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 740b23f..8c9a781 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
 ### Features
 - [#285](https://github.com/influxdata/influxdb-client-go/pull/285) Added *Client.Ping()* function as the only validation method available in both OSS and Cloud.
 - [#286](https://github.com/influxdata/influxdb-client-go/pull/286) Synced generated server API with the latest [oss.yml](https://github.com/influxdata/openapi/blob/master/contracts/oss.yml).
+- [#287](https://github.com/influxdata/influxdb-client-go/pull/287) Added *FluxRecord.Result()* function as a convenient way to retrieve the Flux result name of data.
 
 ### Bug fixes
 - [#285](https://github.com/influxdata/influxdb-client-go/pull/285) Functions *Client.Health()* and *Client.Ready()* correctly report an error when called against InfluxDB Cloud.
diff --git a/api/query/table.go b/api/query/table.go
index fc30fa5..7d8bf6c 100644
--- a/api/query/table.go
+++ b/api/query/table.go
@@ -180,6 +180,12 @@ func (r *FluxRecord) Field() string {
 	return stringValue(r.values, "_field")
 }
 
+// Result returns the value of the _result column, which represents result name.
+// Returns empty string if there is no column "result".
+func (r *FluxRecord) Result() string {
+	return stringValue(r.values, "result")
+}
+
 // Measurement returns the measurement name of the record
 // Returns empty string if there is no column "_measurement".
 func (r *FluxRecord) Measurement() string {


Test patch:
diff --git a/api/query/table_test.go b/api/query/table_test.go
index f8a34b4..6adefb7 100644
--- a/api/query/table_test.go
+++ b/api/query/table_test.go
@@ -85,6 +85,7 @@ func TestRecord(t *testing.T) {
 	assert.Equal(t, mustParseTime("2020-02-17T22:19:49.747562847Z"), record.Start())
 	assert.Equal(t, mustParseTime("2020-02-18T22:19:49.747562847Z"), record.Stop())
 	assert.Equal(t, mustParseTime("2020-02-18T10:34:08.135814545Z"), record.Time())
+	assert.Equal(t, "_result", record.Result())
 	assert.Equal(t, "f", record.Field())
 	assert.Equal(t, 1.4, record.Value())
 	assert.Equal(t, "test", record.Measurement())
@@ -92,18 +93,18 @@ func TestRecord(t *testing.T) {
 
 	agRec := &FluxRecord{table: 0,
 		values: map[string]interface{}{
-			"result": "_result",
 			"room":   "bathroom",
 			"sensor": "SHT",
 			"temp":   24.3,
 			"hum":    42,
 		},
 	}
-	require.Len(t, agRec.values, 5)
+	require.Len(t, agRec.values, 4)
 	assert.Equal(t, time.Time{}, agRec.Start())
 	assert.Equal(t, time.Time{}, agRec.Stop())
 	assert.Equal(t, time.Time{}, agRec.Time())
 	assert.Equal(t, "", agRec.Field())
+	assert.Equal(t, "", agRec.Result())
 	assert.Nil(t, agRec.Value())
 	assert.Equal(t, "", agRec.Measurement())
 	assert.Equal(t, 0, agRec.Table())
diff --git a/api/query_test.go b/api/query_test.go
index 4e70c0d..971df3a 100644
--- a/api/query_test.go
+++ b/api/query_test.go
@@ -382,7 +382,7 @@ func TestQueryCVSResultMultiTables(t *testing.T) {
 	require.Equal(t, queryResult.table, expectedTable4)
 	require.NotNil(t, queryResult.Record())
 	require.Equal(t, queryResult.Record(), expectedRecord42)
-	assert.Equal(t, "_result4", queryResult.Record().ValueByKey("result"))
+	assert.Equal(t, "_result4", queryResult.Record().Result())
 
 	require.False(t, queryResult.Next())
 	require.Nil(t, queryResult.Err())