codeant-ai-for-open-source[bot] commented on code in PR #42483:
URL: https://github.com/apache/superset/pull/42483#discussion_r3688998626
##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.tsx:
##########
@@ -385,6 +413,26 @@ const DndMetricSelect = (props: any) => {
[onNewMetric, togglePopover],
);
+ const onDropFolder = useCallback(
+ (items: DatasourcePanelDndItem[]) => {
+ // Items already passed `canDrop`. Saved metrics are added as-is; columns
+ // become adhoc metrics with a default aggregation (no popover, since a
+ // folder can drop many at once).
+ const additions = items.map(item =>
+ item.type === DndItemType.Metric
+ ? (item.value as Metric)
+ : createAdhocMetricFromColumn(item.value as ColumnMeta),
+ );
Review Comment:
**Suggestion:** The bulk path appends every item passed by the folder
dispatcher, but `canDrop` only checks duplicate saved metric names and does not
reject a column that is already represented by an existing adhoc metric.
Consequently, dragging a folder containing a previously added column adds a
second metric for that same column, contrary to the feature's requirement that
already added columns not be added. Filter column additions against the current
adhoc metric values before committing them. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Metrics controls accumulate duplicate adhoc column metrics.
- ⚠️ Folder drops violate the stated duplicate-prevention behavior.
- ⚠️ Duplicate aggregations can alter generated chart queries.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=d2511e87cfca4f29981c5fd0579f447b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=d2511e87cfca4f29981c5fd0579f447b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndMetricSelect.tsx
**Line:** 421:425
**Comment:**
*Logic Error: The bulk path appends every item passed by the folder
dispatcher, but `canDrop` only checks duplicate saved metric names and does not
reject a column that is already represented by an existing adhoc metric.
Consequently, dragging a folder containing a previously added column adds a
second metric for that same column, contrary to the feature's requirement that
already added columns not be added. Filter column additions against the current
adhoc metric values before committing them.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42483&comment_hash=0de7728af53518c350254da517a2879351eb3ce2c18ff73dda5163b6e2f19a84&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42483&comment_hash=0de7728af53518c350254da517a2879351eb3ce2c18ff73dda5163b6e2f19a84&reaction=dislike'>👎</a>
--
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]