Elasticsearch: Name fields after template variables values instead of their name (#36035)

This reverts commit 185bf8f9a2.
This commit is contained in:
Giordano Ricci 2021-06-26 18:37:44 +01:00 committed by GitHub
parent e6e7ba209c
commit a97259f07d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,6 @@ import {
import { bucketAggregationConfig } from './components/QueryEditor/BucketAggregationsEditor/utils';
import {
BucketAggregation,
BucketAggregationWithField,
isBucketAggregationWithField,
} from './components/QueryEditor/BucketAggregationsEditor/aggregations';
import { generate, Observable, of, throwError } from 'rxjs';
@ -391,23 +390,7 @@ export class ElasticDatasource extends DataSourceApi<ElasticsearchQuery, Elastic
this.templateSrv.replace(JSON.stringify(expandedQueries), scopedVars)
);
// FIXME: with 8.0 we introduced an undocumented breaking change on how we name frames fields.
// Although the introduced behavior is correct, it wasn't documented.
// The following lines will restore the previous behaviour for 8.0, to be removed with a proper
// changelog in 8.1 by returning `finalQueries` without any further modification
return finalQueries.map((q, queryIndex) => ({
...q,
bucketAggs: q.bucketAggs?.map((bucketAgg, aggIndex) => {
if (isBucketAggregationWithField(bucketAgg)) {
return {
...bucketAgg,
field: (queries[queryIndex].bucketAggs?.[aggIndex] as BucketAggregationWithField).field,
};
}
return bucketAgg;
}),
}));
return finalQueries;
}
testDatasource() {