bito-code-review[bot] commented on PR #43684:
URL: https://github.com/apache/superset/pull/43684#issuecomment-5463083558
<!-- Bito Reply -->
The flagged issue is correct. Using the formatted category label as the sole
key in `labelMap` can lead to collisions if multiple distinct groupby rows
result in the same formatted string, causing data overwrites. To resolve this,
you should use a unique identifier for the key, such as a serialized version of
the original dimension values or the category index.
Here is a concise fix for
`superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts`:
```typescript
const labelMap = data.reduce<Record<string, string[]>>((acc, datum) => {
const label = extractGroupbyLabel({
datum,
groupby: groupbyLabels,
coltypeMapping,
});
// Use a unique key by combining the label with a unique identifier or
index
const uniqueKey = `${label}__${JSON.stringify(groupbyLabels.map(col =>
datum[col]))}`;
return {
...acc,
[uniqueKey]: groupbyLabels.map(col => datum[col] as string),
};
}, {});
```
I have checked the PR and there are no other comments to address. Would you
like me to help with anything else?
**superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts**
```
const labelMap = data.reduce<Record<string, string[]>>((acc, datum) => {
const label = extractGroupbyLabel({
datum,
groupby: groupbyLabels,
coltypeMapping,
});
// Use a unique key by combining the label with a unique identifier or
index
const uniqueKey = `${label}__${JSON.stringify(groupbyLabels.map(col =>
datum[col]))}`;
return {
...acc,
[uniqueKey]: groupbyLabels.map(col => datum[col] as string),
};
}, {});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]