fix(query): use query dialect annotations specified in request (#17196)
* fix(query): use query dialect annotations specified in request Signed-off-by: Jakub Bednar <jakub.bednar@gmail.com> * chore(query): add tests Signed-off-by: Jakub Bednar <jakub.bednar@gmail.com>pull/17512/head
parent
2852bf0399
commit
9a71298cc2
|
@ -126,6 +126,9 @@ func (r QueryRequest) ProxyRequest() *ProxyRequest {
|
|||
cfg := csv.DefaultEncoderConfig()
|
||||
cfg.NoHeader = noHeader
|
||||
cfg.Delimiter = delimiter
|
||||
if r.Dialect.Annotations != nil {
|
||||
cfg.Annotations = r.Dialect.Annotations
|
||||
}
|
||||
|
||||
return &ProxyRequest{
|
||||
Compiler: compiler,
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/influxdata/flux/csv"
|
||||
"github.com/influxdata/influxdb/pkg/testing/assert"
|
||||
)
|
||||
|
||||
func TestRequest_ProxyRequest_Annotations(t *testing.T) {
|
||||
|
||||
for _, tt := range []struct {
|
||||
qr *QueryRequest
|
||||
annotations []string
|
||||
}{
|
||||
{
|
||||
qr: &QueryRequest{Query: "from"},
|
||||
annotations: []string{"datatype", "group", "default"},
|
||||
},
|
||||
{
|
||||
qr: &QueryRequest{Query: "from", Dialect: QueryDialect{Annotations: []string{"datatype", "group", "default"}}},
|
||||
annotations: []string{"datatype", "group", "default"},
|
||||
},
|
||||
{
|
||||
qr: &QueryRequest{Query: "from", Dialect: QueryDialect{Annotations: []string{"datatype", "group"}}},
|
||||
annotations: []string{"datatype", "group"},
|
||||
},
|
||||
{
|
||||
qr: &QueryRequest{Query: "from", Dialect: QueryDialect{Annotations: nil}},
|
||||
annotations: []string{"datatype", "group", "default"},
|
||||
},
|
||||
{
|
||||
qr: &QueryRequest{Query: "from", Dialect: QueryDialect{Annotations: []string{}}},
|
||||
annotations: []string{},
|
||||
},
|
||||
} {
|
||||
dialect := tt.qr.ProxyRequest().Dialect.(csv.Dialect)
|
||||
assert.Equal(t, dialect.ResultEncoderConfig.Annotations, tt.annotations, "invalid annotations")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue