[v10.1.x] Query splitting: combine nanos attribute con time fields (#73564)
Query splitting: combine nanos attribute con time fields (#73505)
(cherry picked from commit f7355668e7)
Co-authored-by: Matias Chomicki <matyax@gmail.com>
This commit is contained in:
co-authored by
Matias Chomicki
parent
01093b6cdf
commit
cd4e1d1906
@@ -403,6 +403,81 @@ describe('combineResponses', () => {
|
|||||||
expect(combined.errors?.[1]?.message).toBe('errorB');
|
expect(combined.errors?.[1]?.message).toBe('errorB');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('combines frames with nanoseconds', () => {
|
||||||
|
const { logFrameA, logFrameB } = getMockFrames();
|
||||||
|
logFrameA.fields[0].nanos = [333333, 444444];
|
||||||
|
logFrameB.fields[0].nanos = [111111, 222222];
|
||||||
|
const responseA: DataQueryResponse = {
|
||||||
|
data: [logFrameA],
|
||||||
|
};
|
||||||
|
const responseB: DataQueryResponse = {
|
||||||
|
data: [logFrameB],
|
||||||
|
};
|
||||||
|
expect(combineResponses(responseA, responseB)).toEqual({
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
config: {},
|
||||||
|
name: 'Time',
|
||||||
|
type: 'time',
|
||||||
|
values: [1, 2, 3, 4],
|
||||||
|
nanos: [111111, 222222, 333333, 444444],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
config: {},
|
||||||
|
name: 'Line',
|
||||||
|
type: 'string',
|
||||||
|
values: ['line3', 'line4', 'line1', 'line2'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
config: {},
|
||||||
|
name: 'labels',
|
||||||
|
type: 'other',
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
otherLabel: 'other value',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'value',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
otherLabel: 'other value',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
config: {},
|
||||||
|
name: 'tsNs',
|
||||||
|
type: 'string',
|
||||||
|
values: ['1000000', '2000000', '3000000', '4000000'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
config: {},
|
||||||
|
name: 'id',
|
||||||
|
type: 'string',
|
||||||
|
values: ['id3', 'id4', 'id1', 'id2'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
length: 4,
|
||||||
|
meta: {
|
||||||
|
custom: {
|
||||||
|
frameType: 'LabeledTimeValues',
|
||||||
|
},
|
||||||
|
stats: [
|
||||||
|
{
|
||||||
|
displayName: 'Summary: total bytes processed',
|
||||||
|
unit: 'decbytes',
|
||||||
|
value: 33,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
refId: 'A',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('combine stats', () => {
|
describe('combine stats', () => {
|
||||||
const { metricFrameA } = getMockFrames();
|
const { metricFrameA } = getMockFrames();
|
||||||
const makeResponse = (stats?: QueryResultMetaStat[]): DataQueryResponse => ({
|
const makeResponse = (stats?: QueryResultMetaStat[]): DataQueryResponse => ({
|
||||||
|
|||||||
@@ -203,6 +203,10 @@ function combineFrames(dest: DataFrame, source: DataFrame) {
|
|||||||
const totalFields = dest.fields.length;
|
const totalFields = dest.fields.length;
|
||||||
for (let i = 0; i < totalFields; i++) {
|
for (let i = 0; i < totalFields; i++) {
|
||||||
dest.fields[i].values = [].concat.apply(source.fields[i].values, dest.fields[i].values);
|
dest.fields[i].values = [].concat.apply(source.fields[i].values, dest.fields[i].values);
|
||||||
|
if (source.fields[i].nanos) {
|
||||||
|
const nanos: number[] = dest.fields[i].nanos?.slice() || [];
|
||||||
|
dest.fields[i].nanos = source.fields[i].nanos?.concat(nanos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dest.length += source.length;
|
dest.length += source.length;
|
||||||
dest.meta = {
|
dest.meta = {
|
||||||
|
|||||||
Reference in New Issue
Block a user