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 2024/06/13 12:10:39 UTC

(superset) branch 4.0 updated (a60891702a -> ce6fa3b652)

This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a change to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git


    from a60891702a fix: Remove BASE_AXIS from pre-query (#29084)
     new 449be5d511 fix(embedded): add missing GUEST_TOKEN_HEADER_NAME to bootstrap data (#28932)
     new 60f28e11bc fix(mixed-timeseries-plugin): Second query stacks stacked on top of first query series (#29119)
     new ce6fa3b652 fix(sqllab): run previous state query (#29230)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/MixedTimeseries/transformProps.ts          |   2 +
 .../src/Timeseries/transformers.ts                 |   5 +
 .../test/MixedTimeseries/transformProps.test.ts    | 161 +++++++++++++++++++++
 superset-frontend/src/SqlLab/actions/sqlLab.js     |   5 +-
 .../src/SqlLab/actions/sqlLab.test.js              |  39 ++++-
 superset/embedded/view.py                          |   5 +-
 6 files changed, 212 insertions(+), 5 deletions(-)
 create mode 100644 superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts


(superset) 01/03: fix(embedded): add missing GUEST_TOKEN_HEADER_NAME to bootstrap data (#28932)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 449be5d511d49fb8ec1a9e6e616ccc6e6c4fe595
Author: Hex Café <15...@users.noreply.github.com>
AuthorDate: Thu Jun 6 09:58:38 2024 +0800

    fix(embedded): add missing GUEST_TOKEN_HEADER_NAME to bootstrap data (#28932)
    
    (cherry picked from commit 5c9a79442c035ee5d6907883e5d6a0865a0a540e)
---
 superset/embedded/view.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/superset/embedded/view.py b/superset/embedded/view.py
index 462c6046fa..349729e8c4 100644
--- a/superset/embedded/view.py
+++ b/superset/embedded/view.py
@@ -17,7 +17,7 @@
 import json
 from typing import Callable
 
-from flask import abort, request
+from flask import abort, current_app, request
 from flask_appbuilder import expose
 from flask_login import AnonymousUserMixin, login_user
 from flask_wtf.csrf import same_origin
@@ -78,6 +78,9 @@ class EmbeddedView(BaseSupersetView):
         )
 
         bootstrap_data = {
+            "config": {
+                "GUEST_TOKEN_HEADER_NAME": current_app.config["GUEST_TOKEN_HEADER_NAME"]
+            },
             "common": common_bootstrap_payload(),
             "embedded": {
                 "dashboard_id": embedded.dashboard_id,


(superset) 02/03: fix(mixed-timeseries-plugin): Second query stacks stacked on top of first query series (#29119)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 60f28e11bc69e0b39e05537eba3715207e005b1e
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Mon Jun 10 12:22:35 2024 +0200

    fix(mixed-timeseries-plugin): Second query stacks stacked on top of first query series (#29119)
    
    (cherry picked from commit 68fd1895865a7c7fefe368db05f6fb22c8f1c048)
---
 .../src/MixedTimeseries/transformProps.ts          |   2 +
 .../src/Timeseries/transformers.ts                 |   5 +
 .../test/MixedTimeseries/transformProps.test.ts    | 161 +++++++++++++++++++++
 3 files changed, 168 insertions(+)

diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
index 7488d49dba..a0aa94f361 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
@@ -388,6 +388,7 @@ export default function transformProps(
         seriesType,
         showValue,
         stack: Boolean(stack),
+        stackIdSuffix: '\na',
         yAxisIndex,
         filterState,
         seriesKey: entry.name,
@@ -434,6 +435,7 @@ export default function transformProps(
         seriesType: seriesTypeB,
         showValue: showValueB,
         stack: Boolean(stackB),
+        stackIdSuffix: '\nb',
         yAxisIndex: yAxisIndexB,
         filterState,
         seriesKey: primarySeries.has(entry.name as string)
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
index 8944dc66fa..b4aded89bf 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
@@ -151,6 +151,7 @@ export function transformSeries(
     areaOpacity?: number;
     seriesType?: EchartsTimeseriesSeriesType;
     stack?: StackType;
+    stackIdSuffix?: string;
     yAxisIndex?: number;
     showValue?: boolean;
     onlyTotal?: boolean;
@@ -178,6 +179,7 @@ export function transformSeries(
     areaOpacity = 1,
     seriesType,
     stack,
+    stackIdSuffix,
     yAxisIndex = 0,
     showValue,
     onlyTotal,
@@ -223,6 +225,9 @@ export function transformSeries(
   } else if (stack && isTrend) {
     stackId = forecastSeries.type;
   }
+  if (stackId && stackIdSuffix) {
+    stackId += stackIdSuffix;
+  }
   let plotType;
   if (
     !isConfidenceBand &&
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
new file mode 100644
index 0000000000..422eb6a480
--- /dev/null
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
@@ -0,0 +1,161 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { ChartProps, supersetTheme } from '@superset-ui/core';
+import {
+  LegendOrientation,
+  LegendType,
+  EchartsTimeseriesSeriesType,
+} from '@superset-ui/plugin-chart-echarts';
+import transformProps from '../../src/MixedTimeseries/transformProps';
+import {
+  EchartsMixedTimeseriesFormData,
+  EchartsMixedTimeseriesProps,
+} from '../../src/MixedTimeseries/types';
+
+const formData: EchartsMixedTimeseriesFormData = {
+  annotationLayers: [],
+  area: false,
+  areaB: false,
+  legendMargin: null,
+  logAxis: false,
+  logAxisSecondary: false,
+  markerEnabled: false,
+  markerEnabledB: false,
+  markerSize: 0,
+  markerSizeB: 0,
+  minorSplitLine: false,
+  minorTicks: false,
+  opacity: 0,
+  opacityB: 0,
+  orderDesc: false,
+  orderDescB: false,
+  richTooltip: false,
+  rowLimit: 0,
+  rowLimitB: 0,
+  legendOrientation: LegendOrientation.Top,
+  legendType: LegendType.Scroll,
+  showLegend: false,
+  showValue: false,
+  showValueB: false,
+  stack: true,
+  stackB: true,
+  truncateYAxis: false,
+  truncateYAxisSecondary: false,
+  xAxisLabelRotation: 0,
+  xAxisTitle: '',
+  xAxisTitleMargin: 0,
+  yAxisBounds: [undefined, undefined],
+  yAxisBoundsSecondary: [undefined, undefined],
+  yAxisTitle: '',
+  yAxisTitleMargin: 0,
+  yAxisTitlePosition: '',
+  yAxisTitleSecondary: '',
+  zoomable: false,
+  colorScheme: 'bnbColors',
+  datasource: '3__table',
+  x_axis: 'ds',
+  metrics: ['sum__num'],
+  metricsB: ['sum__num'],
+  groupby: ['gender'],
+  groupbyB: ['gender'],
+  seriesType: EchartsTimeseriesSeriesType.Line,
+  seriesTypeB: EchartsTimeseriesSeriesType.Bar,
+  viz_type: 'mixed_timeseries',
+  forecastEnabled: false,
+  forecastPeriods: [],
+  forecastInterval: 0,
+  forecastSeasonalityDaily: 0,
+};
+
+const queriesData = [
+  {
+    data: [
+      { boy: 1, girl: 2, ds: 599616000000 },
+      { boy: 3, girl: 4, ds: 599916000000 },
+    ],
+    label_map: {
+      ds: ['ds'],
+      boy: ['boy'],
+      girl: ['girl'],
+    },
+  },
+  {
+    data: [
+      { boy: 1, girl: 2, ds: 599616000000 },
+      { boy: 3, girl: 4, ds: 599916000000 },
+    ],
+    label_map: {
+      ds: ['ds'],
+      boy: ['boy'],
+      girl: ['girl'],
+    },
+  },
+];
+
+const chartPropsConfig = {
+  formData,
+  width: 800,
+  height: 600,
+  queriesData,
+  theme: supersetTheme,
+};
+
+it('should transform chart props for viz', () => {
+  const chartProps = new ChartProps(chartPropsConfig);
+  expect(transformProps(chartProps as EchartsMixedTimeseriesProps)).toEqual(
+    expect.objectContaining({
+      echartOptions: expect.objectContaining({
+        series: expect.arrayContaining([
+          expect.objectContaining({
+            data: [
+              [599616000000, 1],
+              [599916000000, 3],
+            ],
+            id: 'boy',
+            stack: 'obs\na',
+          }),
+          expect.objectContaining({
+            data: [
+              [599616000000, 2],
+              [599916000000, 4],
+            ],
+            id: 'girl',
+            stack: 'obs\na',
+          }),
+          expect.objectContaining({
+            data: [
+              [599616000000, 1],
+              [599916000000, 3],
+            ],
+            id: 'boy (1)',
+            stack: 'obs\nb',
+          }),
+          expect.objectContaining({
+            data: [
+              [599616000000, 2],
+              [599916000000, 4],
+            ],
+            id: 'girl (1)',
+            stack: 'obs\nb',
+          }),
+        ]),
+      }),
+    }),
+  );
+});


(superset) 03/03: fix(sqllab): run previous state query (#29230)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit ce6fa3b65223de6514227749771417e32e90b00a
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Wed Jun 12 15:04:19 2024 -0700

    fix(sqllab): run previous state query (#29230)
    
    (cherry picked from commit a88979631e6abe4de1b00e9c05ad1e411db1c2a7)
---
 superset-frontend/src/SqlLab/actions/sqlLab.js     |  5 +--
 .../src/SqlLab/actions/sqlLab.test.js              | 39 ++++++++++++++++++++--
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js
index 540a0e8536..edc3098884 100644
--- a/superset-frontend/src/SqlLab/actions/sqlLab.js
+++ b/superset-frontend/src/SqlLab/actions/sqlLab.js
@@ -133,11 +133,12 @@ export const convertQueryToClient = fieldConverter(queryClientMapping);
 
 export function getUpToDateQuery(rootState, queryEditor, key) {
   const {
-    sqlLab: { unsavedQueryEditor },
+    sqlLab: { unsavedQueryEditor, queryEditors },
   } = rootState;
   const id = key ?? queryEditor.id;
   return {
-    ...queryEditor,
+    id,
+    ...queryEditors.find(qe => qe.id === id),
     ...(id === unsavedQueryEditor.id && unsavedQueryEditor),
   };
 }
diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.test.js b/superset-frontend/src/SqlLab/actions/sqlLab.test.js
index 20fd53ad38..5bb42f7580 100644
--- a/superset-frontend/src/SqlLab/actions/sqlLab.test.js
+++ b/superset-frontend/src/SqlLab/actions/sqlLab.test.js
@@ -36,6 +36,29 @@ import {
 const middlewares = [thunk];
 const mockStore = configureMockStore(middlewares);
 
+describe('getUpToDateQuery', () => {
+  test('should return the up to date query editor state', () => {
+    const outOfUpdatedQueryEditor = {
+      ...defaultQueryEditor,
+      schema: null,
+      sql: 'SELECT ...',
+    };
+    const queryEditor = {
+      ...defaultQueryEditor,
+      sql: 'SELECT * FROM table',
+    };
+    const state = {
+      sqlLab: {
+        queryEditors: [queryEditor],
+        unsavedQueryEditor: {},
+      },
+    };
+    expect(actions.getUpToDateQuery(state, outOfUpdatedQueryEditor)).toEqual(
+      queryEditor,
+    );
+  });
+});
+
 describe('async actions', () => {
   const mockBigNumber = '9223372036854775807';
   const queryEditor = {
@@ -675,7 +698,13 @@ describe('async actions', () => {
         it('updates the tab state in the backend', () => {
           expect.assertions(2);
 
-          const store = mockStore(initialState);
+          const store = mockStore({
+            ...initialState,
+            sqlLab: {
+              ...initialState.sqlLab,
+              queryEditors: [queryEditor],
+            },
+          });
           const request = actions.queryEditorSetAndSaveSql(queryEditor, sql);
           return request(store.dispatch, store.getState).then(() => {
             expect(store.getActions()).toEqual(expectedActions);
@@ -691,7 +720,13 @@ describe('async actions', () => {
               feature => !(feature === 'SQLLAB_BACKEND_PERSISTENCE'),
             );
 
-          const store = mockStore(initialState);
+          const store = mockStore({
+            ...initialState,
+            sqlLab: {
+              ...initialState.sqlLab,
+              queryEditors: [queryEditor],
+            },
+          });
           const request = actions.queryEditorSetAndSaveSql(queryEditor, sql);
           request(store.dispatch, store.getState);