influxdb: influxql: more robust resultformat-handling (#39330)

This commit is contained in:
Gábor Farkas 2021-09-17 12:33:09 +02:00 committed by GitHub
parent 52d7358d83
commit d116b2d71b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 28 deletions

View File

@ -25,11 +25,6 @@ func (qp *InfluxdbQueryParser) Parse(query backend.DataQuery) (*Query, error) {
measurement := model.Get("measurement").MustString("")
resultFormat, err := model.Get("resultFormat").String()
if err != nil {
return nil, err
}
tags, err := qp.parseTags(model)
if err != nil {
return nil, err
@ -57,7 +52,6 @@ func (qp *InfluxdbQueryParser) Parse(query backend.DataQuery) (*Query, error) {
return &Query{
Measurement: measurement,
Policy: policy,
ResultFormat: resultFormat,
GroupBy: groupBys,
Tags: tags,
Selects: selects,

View File

@ -5,7 +5,6 @@ import "time"
type Query struct {
Measurement string
Policy string
ResultFormat string
Tags []*Tag
GroupBy []*QueryPart
Selects []*Select

View File

@ -20,11 +20,14 @@ export const RawInfluxQLEditor = ({ query, onChange, onRunQuery }: Props): JSX.E
const aliasElementId = useUniqueId();
const selectElementId = useUniqueId();
const resultFormat = query.resultFormat ?? DEFAULT_RESULT_FORMAT;
const applyDelayedChangesAndRunQuery = () => {
onChange({
...query,
query: currentQuery,
alias: currentAlias,
resultFormat,
});
onRunQuery();
};
@ -51,7 +54,7 @@ export const RawInfluxQLEditor = ({ query, onChange, onRunQuery }: Props): JSX.E
onChange({ ...query, resultFormat: v.value });
onRunQuery();
}}
value={query.resultFormat ?? DEFAULT_RESULT_FORMAT}
value={resultFormat}
options={RESULT_FORMATS}
/>
<InlineFormLabel htmlFor={aliasElementId}>Alias by</InlineFormLabel>