villebro commented on PR #22945:
URL: https://github.com/apache/superset/pull/22945#issuecomment-1413666968
@kgabryje come to think of it, _this_ is the correct solution to this
problem:
```patch
diff --git
a/superset-frontend/packages/superset-ui-chart-controls/src/operators/pivotOperator.ts
b/superset-frontend/packages/superset-ui-chart-controls/src/operators/pivotOperator.ts
index 8190c951d..60b8bb43f 100644
---
a/superset-frontend/packages/superset-ui-chart-controls/src/operators/pivotOperator.ts
+++
b/superset-frontend/packages/superset-ui-chart-controls/src/operators/pivotOperator.ts
@@ -31,13 +31,14 @@ export const pivotOperator:
PostProcessingFactory<PostProcessingPivot> = (
) => {
const metricLabels =
ensureIsArray(queryObject.metrics).map(getMetricLabel);
const xAxisLabel = getXAxisLabel(formData);
+ const seriesColumns = queryObject.series_columns || queryObject.columns;
if (xAxisLabel && metricLabels.length) {
return {
operation: 'pivot',
options: {
index: [xAxisLabel],
- columns: ensureIsArray(queryObject.columns).map(getColumnLabel),
+ columns: ensureIsArray(seriesColumns).map(getColumnLabel),
// Create 'dummy' mean aggregates to assign cell values in pivot
table
// use the 'mean' aggregates to avoid drop NaN. PR:
https://github.com/apache-superset/superset-ui/pull/1231
aggregates: Object.fromEntries(
diff --git
a/superset-frontend/packages/superset-ui-chart-controls/src/operators/timeComparePivotOperator.ts
b/superset-frontend/packages/superset-ui-chart-controls/src/operators/timeComparePivotOperator.ts
index c3a2ef074..075379744 100644
---
a/superset-frontend/packages/superset-ui-chart-controls/src/operators/timeComparePivotOperator.ts
+++
b/superset-frontend/packages/superset-ui-chart-controls/src/operators/timeComparePivotOperator.ts
@@ -31,6 +31,7 @@ export const timeComparePivotOperator:
PostProcessingFactory<PostProcessingPivot
(formData, queryObject) => {
const metricOffsetMap = getMetricOffsetsMap(formData, queryObject);
const xAxisLabel = getXAxisLabel(formData);
+ const seriesColumns = queryObject.series_columns || queryObject.columns;
if (isTimeComparison(formData, queryObject) && xAxisLabel) {
const aggregates = Object.fromEntries(
@@ -45,7 +46,7 @@ export const timeComparePivotOperator:
PostProcessingFactory<PostProcessingPivot
operation: 'pivot',
options: {
index: [xAxisLabel],
- columns: ensureIsArray(queryObject.columns).map(getColumnLabel),
+ columns: ensureIsArray(seriesColumns).map(getColumnLabel),
drop_missing_columns: !formData?.show_empty_columns,
aggregates,
},
diff --git
a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/buildQuery.ts
b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/buildQuery.ts
index 5b74e0aeb..05c7049a1 100644
---
a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/buildQuery.ts
+++
b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/buildQuery.ts
@@ -68,10 +68,7 @@ export default function buildQuery(formData:
QueryFormData) {
queryObject,
)
? timeComparePivotOperator(fd, queryObject)
- : pivotOperator(fd, {
- ...queryObject,
- columns: fd.groupby,
- });
+ : pivotOperator(fd, queryObject);
const tmpQueryObject = {
...queryObject,
```
If you have time to make this update and add a unit test for it it will
future proof both pivot operators.
--
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]