fix(table): cross-filtering breaks after renaming column labels via Custom SQL (#38858)

This commit is contained in:
Enzo Martellucci
2026-04-10 06:02:18 +02:00
committed by GitHub
parent 8bcc90c766
commit aba7e6dae4
4 changed files with 174 additions and 4 deletions

View File

@@ -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,
};
};