Commit 883d7cb5 by Hugo Häggmark Committed by GitHub

OuterJoin: Fixes transformation when data is missing field to join by (#27453)

parent 023054bc
......@@ -288,4 +288,62 @@ describe('SeriesToColumns Transformer', () => {
expect(filtered.fields).toEqual(expected);
});
});
it('joins if fields are missing', () => {
const cfg: DataTransformerConfig<SeriesToColumnsOptions> = {
id: DataTransformerID.seriesToColumns,
options: {
byField: 'time',
},
};
const frame1 = toDataFrame({
name: 'A',
fields: [
{ name: 'time', type: FieldType.time, values: [1, 2, 3] },
{ name: 'temperature', type: FieldType.number, values: [10, 11, 12] },
],
});
const frame2 = toDataFrame({
name: 'B',
fields: [],
});
const frame3 = toDataFrame({
name: 'C',
fields: [
{ name: 'time', type: FieldType.time, values: [1, 2, 3] },
{ name: 'temperature', type: FieldType.number, values: [20, 22, 24] },
],
});
const filtered = transformDataFrame([cfg], [frame1, frame2, frame3])[0];
expect(filtered.fields).toEqual([
{
name: 'time',
state: { displayName: 'time' },
type: FieldType.time,
values: new ArrayVector([1, 2, 3]),
config: {},
},
{
name: 'temperature',
state: { displayName: 'temperature A' },
type: FieldType.number,
values: new ArrayVector([10, 11, 12]),
config: {},
labels: { name: 'A' },
},
{
name: 'temperature',
state: { displayName: 'temperature C' },
type: FieldType.number,
values: new ArrayVector([20, 22, 24]),
config: {},
labels: { name: 'C' },
},
]);
});
});
......@@ -26,7 +26,7 @@ export const seriesToColumnsTransformer: DataTransformerInfo<SeriesToColumnsOpti
const keyField = findKeyField(frame, keyFieldMatch);
if (!keyField) {
return data;
continue;
}
for (let fieldIndex = 0; fieldIndex < frame.fields.length; fieldIndex++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment