mirror of
https://github.com/apache/superset.git
synced 2026-04-22 09:35:23 +00:00
fix(table): cross-filtering breaks after renaming column labels via Custom SQL (#38858)
This commit is contained in:
@@ -29,6 +29,7 @@ import {
|
||||
getNumberFormatter,
|
||||
getTimeFormatter,
|
||||
getTimeFormatterForGranularity,
|
||||
isAdhocColumn,
|
||||
normalizeCurrency,
|
||||
NumberFormats,
|
||||
QueryMode,
|
||||
@@ -532,6 +533,20 @@ const transformProps = (
|
||||
comparison_type,
|
||||
slice_id,
|
||||
} = formData;
|
||||
// Build a mapping from column labels to original column names.
|
||||
// When a user creates an adhoc column with a custom label (e.g. sqlExpression: "state",
|
||||
// label: "State_Renamed"), the query result uses the label as the column name.
|
||||
// Cross-filtering needs the original column name to work on the receiving chart.
|
||||
const columnLabelToNameMap: Record<string, string> = {};
|
||||
const formColumns = ensureIsArray(
|
||||
queryMode === QueryMode.Raw ? formData.all_columns : formData.groupby,
|
||||
);
|
||||
formColumns.forEach(col => {
|
||||
if (isAdhocColumn(col) && col.label && col.label !== col.sqlExpression) {
|
||||
columnLabelToNameMap[col.label] = col.sqlExpression;
|
||||
}
|
||||
});
|
||||
|
||||
const isUsingTimeComparison =
|
||||
!isEmpty(time_compare) &&
|
||||
queryMode === QueryMode.Aggregate &&
|
||||
@@ -791,6 +806,7 @@ const transformProps = (
|
||||
hasServerPageLengthChanged,
|
||||
serverPageLength,
|
||||
slice_id,
|
||||
columnLabelToNameMap,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user