Transformations: Fix duplicate field names when joinBy follows groupBy (#104206)
This commit is contained in:
@@ -418,6 +418,7 @@ describe('GroupBy transformer', () => {
|
||||
it('should retain "time" field type when used as aggregation (max, etc)', async () => {
|
||||
const testSeries = toDataFrame({
|
||||
refId: 'A',
|
||||
name: 'issues',
|
||||
fields: [
|
||||
{ name: 'user', type: FieldType.string, values: ['A', 'B', 'A', 'B'] },
|
||||
{ name: 'time', type: FieldType.time, values: [7, 2, 1, 5] },
|
||||
@@ -458,6 +459,11 @@ describe('GroupBy transformer', () => {
|
||||
];
|
||||
|
||||
expect(result[0].refId).toEqual('A');
|
||||
|
||||
// adding a frame name can modify field auto-name behavior if a joinBy transformer follows, which transfers
|
||||
// the frame name to field.labels.name and calculateFieldDisplayName() may start treating it as a single-label field
|
||||
expect(result[0].name).toBeUndefined();
|
||||
|
||||
expect(result[0].fields).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ export const groupByTransformer: DataTransformerInfo<GroupByTransformerOptions>
|
||||
}
|
||||
|
||||
processed.push({
|
||||
...frame,
|
||||
refId: frame.refId,
|
||||
fields,
|
||||
length: valuesByGroupKey.size,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user