Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d8b4ed3a
Unverified
Commit
d8b4ed3a
authored
Jan 13, 2021
by
Giordano Ricci
Committed by
GitHub
Jan 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Elasticsearch: fix handling of null values in query_builder (#30234)
parent
a21c1b08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
public/app/plugins/datasource/elasticsearch/query_builder.ts
+5
-4
public/app/plugins/datasource/elasticsearch/specs/query_builder.test.ts
+16
-0
No files found.
public/app/plugins/datasource/elasticsearch/query_builder.ts
View file @
d8b4ed3a
...
...
@@ -334,10 +334,11 @@ export class ElasticQueryBuilder {
metricAgg
=
{
field
:
metric
.
field
};
}
metricAgg
=
{
...
metricAgg
,
...(
isMetricAggregationWithSettings
(
metric
)
&&
metric
.
settings
),
};
if
(
isMetricAggregationWithSettings
(
metric
))
{
Object
.
entries
(
metric
.
settings
||
{})
.
filter
(([
_
,
v
])
=>
v
!==
null
)
.
forEach
(([
k
,
v
])
=>
(
metricAgg
[
k
]
=
v
));
}
aggField
[
metric
.
type
]
=
metricAgg
;
nestedAggs
.
aggs
[
metric
.
id
]
=
aggField
;
...
...
public/app/plugins/datasource/elasticsearch/specs/query_builder.test.ts
View file @
d8b4ed3a
...
...
@@ -24,6 +24,22 @@ describe('ElasticQueryBuilder', () => {
expect
(
query
.
aggs
[
'1'
].
date_histogram
.
extended_bounds
.
min
).
toBe
(
'$timeFrom'
);
});
it
(
'should clean settings from null values'
,
()
=>
{
const
query
=
builder
.
build
({
refId
:
'A'
,
// The following `missing: null as any` is because previous versions of the DS where
// storing null in the query model when inputting an empty string,
// which were then removed in the query builder.
// The new version doesn't store empty strings at all. This tests ensures backward compatinility.
metrics
:
[{
type
:
'avg'
,
id
:
'0'
,
settings
:
{
missing
:
null
as
any
,
script
:
'1'
}
}],
timeField
:
'@timestamp'
,
bucketAggs
:
[{
type
:
'date_histogram'
,
field
:
'@timestamp'
,
id
:
'1'
}],
});
expect
(
query
.
aggs
[
'1'
].
aggs
[
'0'
].
avg
.
missing
).
not
.
toBeDefined
();
expect
(
query
.
aggs
[
'1'
].
aggs
[
'0'
].
avg
.
script
).
toBeDefined
();
});
it
(
'with multiple bucket aggs'
,
()
=>
{
const
query
=
builder
.
build
({
refId
:
'A'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment