mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
influxdb: influxql: more robust resultformat-handling (#39330)
This commit is contained in:
parent
52d7358d83
commit
d116b2d71b
@ -25,11 +25,6 @@ func (qp *InfluxdbQueryParser) Parse(query backend.DataQuery) (*Query, error) {
|
|||||||
|
|
||||||
measurement := model.Get("measurement").MustString("")
|
measurement := model.Get("measurement").MustString("")
|
||||||
|
|
||||||
resultFormat, err := model.Get("resultFormat").String()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
tags, err := qp.parseTags(model)
|
tags, err := qp.parseTags(model)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -55,17 +50,16 @@ func (qp *InfluxdbQueryParser) Parse(query backend.DataQuery) (*Query, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &Query{
|
return &Query{
|
||||||
Measurement: measurement,
|
Measurement: measurement,
|
||||||
Policy: policy,
|
Policy: policy,
|
||||||
ResultFormat: resultFormat,
|
GroupBy: groupBys,
|
||||||
GroupBy: groupBys,
|
Tags: tags,
|
||||||
Tags: tags,
|
Selects: selects,
|
||||||
Selects: selects,
|
RawQuery: rawQuery,
|
||||||
RawQuery: rawQuery,
|
Interval: interval,
|
||||||
Interval: interval,
|
Alias: alias,
|
||||||
Alias: alias,
|
UseRawQuery: useRawQuery,
|
||||||
UseRawQuery: useRawQuery,
|
Tz: tz,
|
||||||
Tz: tz,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,17 +3,16 @@ package influxdb
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type Query struct {
|
type Query struct {
|
||||||
Measurement string
|
Measurement string
|
||||||
Policy string
|
Policy string
|
||||||
ResultFormat string
|
Tags []*Tag
|
||||||
Tags []*Tag
|
GroupBy []*QueryPart
|
||||||
GroupBy []*QueryPart
|
Selects []*Select
|
||||||
Selects []*Select
|
RawQuery string
|
||||||
RawQuery string
|
UseRawQuery bool
|
||||||
UseRawQuery bool
|
Alias string
|
||||||
Alias string
|
Interval time.Duration
|
||||||
Interval time.Duration
|
Tz string
|
||||||
Tz string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tag struct {
|
type Tag struct {
|
||||||
|
@ -20,11 +20,14 @@ export const RawInfluxQLEditor = ({ query, onChange, onRunQuery }: Props): JSX.E
|
|||||||
const aliasElementId = useUniqueId();
|
const aliasElementId = useUniqueId();
|
||||||
const selectElementId = useUniqueId();
|
const selectElementId = useUniqueId();
|
||||||
|
|
||||||
|
const resultFormat = query.resultFormat ?? DEFAULT_RESULT_FORMAT;
|
||||||
|
|
||||||
const applyDelayedChangesAndRunQuery = () => {
|
const applyDelayedChangesAndRunQuery = () => {
|
||||||
onChange({
|
onChange({
|
||||||
...query,
|
...query,
|
||||||
query: currentQuery,
|
query: currentQuery,
|
||||||
alias: currentAlias,
|
alias: currentAlias,
|
||||||
|
resultFormat,
|
||||||
});
|
});
|
||||||
onRunQuery();
|
onRunQuery();
|
||||||
};
|
};
|
||||||
@ -51,7 +54,7 @@ export const RawInfluxQLEditor = ({ query, onChange, onRunQuery }: Props): JSX.E
|
|||||||
onChange({ ...query, resultFormat: v.value });
|
onChange({ ...query, resultFormat: v.value });
|
||||||
onRunQuery();
|
onRunQuery();
|
||||||
}}
|
}}
|
||||||
value={query.resultFormat ?? DEFAULT_RESULT_FORMAT}
|
value={resultFormat}
|
||||||
options={RESULT_FORMATS}
|
options={RESULT_FORMATS}
|
||||||
/>
|
/>
|
||||||
<InlineFormLabel htmlFor={aliasElementId}>Alias by</InlineFormLabel>
|
<InlineFormLabel htmlFor={aliasElementId}>Alias by</InlineFormLabel>
|
||||||
|
Loading…
Reference in New Issue
Block a user