ariel-sofi commented on code in PR #42477:
URL: https://github.com/apache/superset/pull/42477#discussion_r3657752639


##########
superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts:
##########
@@ -246,13 +246,10 @@ function applyChartSpecificGroupBy(
       groupByFormData.target = limitedColumns[1];
     }
   } else if (chartType === 'sankey_v2') {
-    const { limitedColumns } = limitColumnsForChartType(
-      chartType,
-      groupByColumns,
-    );
-    groupByFormData.source = limitedColumns[0];
-    if (limitedColumns.length > 1) {
-      groupByFormData.target = limitedColumns[1];
+    groupByFormData.source = groupByColumns[0];
+    if (groupByColumns.length > 1) {
+      groupByFormData.target = groupByColumns[groupByColumns.length - 1];
+      groupByFormData.intermediate_levels = groupByColumns.slice(1, -1);
     }

Review Comment:
   Good catch — fixed in 2e14fbb.
   
   A single override column can't describe a flow at all, so rather than 
clearing `target` to `undefined` (which would send `groupby: [source, 
undefined]` to the backend — a half-applied override), the branch now leaves 
the chart's configured columns alone unless the override has at least two 
columns:
   
   ```ts
   } else if (chartType === 'sankey_v2') {
     if (groupByColumns.length > 1) {
       groupByFormData.source = groupByColumns[0];
       groupByFormData.target = groupByColumns[groupByColumns.length - 1];
       groupByFormData.intermediate_levels = groupByColumns.slice(1, -1);
     }
   }
   ```
   
   Also added `intermediate_levels` to the declared return type of 
`processGroupByCustomizations`, which was missing it, plus a regression test 
asserting all three fields survive a one-column override.



-- 
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]

Reply via email to