Transformations: Fix duplicate field names when joinBy follows groupBy (#104206)

This commit is contained in:
Leon Sorokin
2025-05-02 17:08:07 -05:00
committed by GitHub
parent 4aba287bbe
commit c8384cf503
2 changed files with 7 additions and 1 deletions
@@ -418,6 +418,7 @@ describe('GroupBy transformer', () => {
it('should retain "time" field type when used as aggregation (max, etc)', async () => { it('should retain "time" field type when used as aggregation (max, etc)', async () => {
const testSeries = toDataFrame({ const testSeries = toDataFrame({
refId: 'A', refId: 'A',
name: 'issues',
fields: [ fields: [
{ name: 'user', type: FieldType.string, values: ['A', 'B', 'A', 'B'] }, { name: 'user', type: FieldType.string, values: ['A', 'B', 'A', 'B'] },
{ name: 'time', type: FieldType.time, values: [7, 2, 1, 5] }, { name: 'time', type: FieldType.time, values: [7, 2, 1, 5] },
@@ -458,6 +459,11 @@ describe('GroupBy transformer', () => {
]; ];
expect(result[0].refId).toEqual('A'); 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); expect(result[0].fields).toEqual(expected);
}); });
}); });
@@ -133,7 +133,7 @@ export const groupByTransformer: DataTransformerInfo<GroupByTransformerOptions>
} }
processed.push({ processed.push({
...frame, refId: frame.refId,
fields, fields,
length: valuesByGroupKey.size, length: valuesByGroupKey.size,
}); });