You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2025/09/08 19:32:58 UTC
(superset) 01/02: fix(echarts): rename time series shifted for isTimeComparisonValue (#35022)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 5.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit d825b32e986477743fa8fc8d0691f9ea1b330cb2
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Fri Sep 5 08:39:46 2025 -0700
fix(echarts): rename time series shifted for isTimeComparisonValue (#35022)
(cherry picked from commit bc54b7970a5e84b84d7e318c23d0f97a8a8a87d0)
---
.../src/operators/renameOperator.ts | 14 ++++----
.../test/operators/renameOperator.test.ts | 38 ++++++++++++++++++++++
2 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/operators/renameOperator.ts b/superset-frontend/packages/superset-ui-chart-controls/src/operators/renameOperator.ts
index 9e1076900f..86643e2682 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/operators/renameOperator.ts
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/operators/renameOperator.ts
@@ -43,15 +43,17 @@ export const renameOperator: PostProcessingFactory<PostProcessingRename> = (
// remove or rename top level of column name(metric name) in the MultiIndex when
// 1) at least 1 metric
- // 2) dimension exist or multiple time shift metrics exist
- // 3) xAxis exist
- // 4) truncate_metric in form_data and truncate_metric is true
+ // 2) xAxis exist
+ // 3a) isTimeComparisonValue
+ // 3b-1) dimension exist or multiple time shift metrics exist
+ // 3b-2) truncate_metric in form_data and truncate_metric is true
if (
metrics.length > 0 &&
- (columns.length > 0 || timeOffsets.length > 1) &&
xAxisLabel &&
- truncate_metric !== undefined &&
- !!truncate_metric
+ (isTimeComparisonValue ||
+ ((columns.length > 0 || timeOffsets.length > 1) &&
+ truncate_metric !== undefined &&
+ !!truncate_metric))
) {
const renamePairs: [string, string | null][] = [];
if (
diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/operators/renameOperator.test.ts b/superset-frontend/packages/superset-ui-chart-controls/test/operators/renameOperator.test.ts
index 19d594a7f6..26669a7510 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/test/operators/renameOperator.test.ts
+++ b/superset-frontend/packages/superset-ui-chart-controls/test/operators/renameOperator.test.ts
@@ -160,6 +160,44 @@ test('should add renameOperator if exists derived metrics', () => {
});
});
+test('should add renameOperator if isTimeComparisonValue without columns', () => {
+ [
+ ComparisonType.Difference,
+ ComparisonType.Ratio,
+ ComparisonType.Percentage,
+ ].forEach(type => {
+ expect(
+ renameOperator(
+ {
+ ...formData,
+ ...{
+ comparison_type: type,
+ time_compare: ['1 year ago'],
+ },
+ },
+ {
+ ...queryObject,
+ ...{
+ columns: [],
+ metrics: ['sum(val)', 'avg(val2)'],
+ },
+ },
+ ),
+ ).toEqual({
+ operation: 'rename',
+ options: {
+ columns: {
+ [`${type}__avg(val2)__avg(val2)__1 year ago`]:
+ 'avg(val2), 1 year ago',
+ [`${type}__sum(val)__sum(val)__1 year ago`]: 'sum(val), 1 year ago',
+ },
+ inplace: true,
+ level: 0,
+ },
+ });
+ });
+});
+
test('should add renameOperator if x_axis does not exist', () => {
expect(
renameOperator(