You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/04/26 13:59:49 UTC

[GitHub] [superset] zhaoyongjie opened a new pull request, #19851: feat: add AA into mixed time series chart

zhaoyongjie opened a new pull request, #19851:
URL: https://github.com/apache/superset/pull/19851

   ### SUMMARY
   Added Advanced Analytics into Mixed Timeseries chart
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   ![image](https://user-images.githubusercontent.com/2016594/165316903-cc6c67a1-6705-4c16-9089-2603fd670aa4.png)
   
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   TBD
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie merged pull request #19851: feat: add Advanced Analytics into mixed time series chart

Posted by GitBox <gi...@apache.org>.
zhaoyongjie merged PR #19851:
URL: https://github.com/apache/superset/pull/19851


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #19851: feat: add Advanced Analytics into mixed time series chart

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #19851:
URL: https://github.com/apache/superset/pull/19851#issuecomment-1110584593

   # [Codecov](https://codecov.io/gh/apache/superset/pull/19851?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#19851](https://codecov.io/gh/apache/superset/pull/19851?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (dc415af) into [master](https://codecov.io/gh/apache/superset/commit/523bd8b79cfd48d1cb3a94f89c8095976844ce59?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (523bd8b) will **decrease** coverage by `0.05%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #19851      +/-   ##
   ==========================================
   - Coverage   66.55%   66.49%   -0.06%     
   ==========================================
     Files        1692     1714      +22     
     Lines       64802    64991     +189     
     Branches     6657     6707      +50     
   ==========================================
   + Hits        43129    43216      +87     
   - Misses      19973    20068      +95     
   - Partials     1700     1707       +7     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `51.22% <100.00%> (-0.03%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/19851?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...in-chart-echarts/src/MixedTimeseries/buildQuery.ts](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGx1Z2lucy9wbHVnaW4tY2hhcnQtZWNoYXJ0cy9zcmMvTWl4ZWRUaW1lc2VyaWVzL2J1aWxkUXVlcnkudHM=) | `100.00% <100.00%> (+100.00%)` | :arrow_up: |
   | [...chart-echarts/src/MixedTimeseries/controlPanel.tsx](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGx1Z2lucy9wbHVnaW4tY2hhcnQtZWNoYXJ0cy9zcmMvTWl4ZWRUaW1lc2VyaWVzL2NvbnRyb2xQYW5lbC50c3g=) | `92.85% <100.00%> (+12.85%)` | :arrow_up: |
   | [...s/plugin-chart-echarts/src/utils/formDataSuffix.ts](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGx1Z2lucy9wbHVnaW4tY2hhcnQtZWNoYXJ0cy9zcmMvdXRpbHMvZm9ybURhdGFTdWZmaXgudHM=) | `100.00% <100.00%> (ø)` | |
   | [...end/src/components/Form/LabeledErrorBoundInput.tsx](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvRm9ybS9MYWJlbGVkRXJyb3JCb3VuZElucHV0LnRzeA==) | `95.00% <0.00%> (-5.00%)` | :arrow_down: |
   | [...frontend/src/SqlLab/components/SqlEditor/index.jsx](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL1NxbExhYi9jb21wb25lbnRzL1NxbEVkaXRvci9pbmRleC5qc3g=) | `51.07% <0.00%> (-0.28%)` | :arrow_down: |
   | [...-frontend/src/components/AlteredSliceTag/index.jsx](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvQWx0ZXJlZFNsaWNlVGFnL2luZGV4LmpzeA==) | `87.87% <0.00%> (ø)` | |
   | [...-frontend/src/visualizations/presets/MainPreset.js](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3Zpc3VhbGl6YXRpb25zL3ByZXNldHMvTWFpblByZXNldC5qcw==) | `100.00% <0.00%> (ø)` | |
   | [...preset-chart-deckgl/src/layers/Geojson/Geojson.jsx](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGx1Z2lucy9sZWdhY3ktcHJlc2V0LWNoYXJ0LWRlY2tnbC9zcmMvbGF5ZXJzL0dlb2pzb24vR2VvanNvbi5qc3g=) | `0.00% <0.00%> (ø)` | |
   | [...et-chart-deckgl/src/layers/Geojson/controlPanel.ts](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGx1Z2lucy9sZWdhY3ktcHJlc2V0LWNoYXJ0LWRlY2tnbC9zcmMvbGF5ZXJzL0dlb2pzb24vY29udHJvbFBhbmVsLnRz) | `50.00% <0.00%> (ø)` | |
   | [...ols/MetricControl/AdhocMetricEditPopover/index.jsx](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9NZXRyaWNDb250cm9sL0FkaG9jTWV0cmljRWRpdFBvcG92ZXIvaW5kZXguanN4) | `76.28% <0.00%> (ø)` | |
   | ... and [25 more](https://codecov.io/gh/apache/superset/pull/19851/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/19851?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/19851?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [523bd8b...dc415af](https://codecov.io/gh/apache/superset/pull/19851?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #19851: feat: add Advanced Analytics into mixed time series chart

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #19851:
URL: https://github.com/apache/superset/pull/19851#discussion_r859396240


##########
superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/buildQuery.test.ts:
##########
@@ -0,0 +1,277 @@
+/**
+ * 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 {
+  ComparisionType,
+  FreeFormAdhocFilter,
+  RollingType,
+  TimeGranularity,
+} from '@superset-ui/core';
+import buildQuery from '../../src/MixedTimeseries/buildQuery';
+
+const formDataMixedChart = {
+  datasource: 'dummy',
+  viz_type: 'my_chart',
+  // query
+  //   -- common
+  time_range: '1980 : 2000',
+  time_grain_sqla: TimeGranularity.WEEK,
+  granularity_sqla: 'ds',
+  //   -- query a
+  groupby: ['foo'],
+  metrics: ['sum(sales)'],
+  adhoc_filters: [
+    {
+      clause: 'WHERE',
+      expressionType: 'SQL',
+      sqlExpression: "foo in ('a', 'b')",
+    } as FreeFormAdhocFilter,
+  ],
+  limit: 5,
+  row_limit: 10,
+  timeseries_limit_metric: 'count',
+  order_desc: true,
+  emit_filter: true,
+  //   -- query b
+  groupby_b: [],
+  metrics_b: ['count'],
+  adhoc_filters_b: [
+    {
+      clause: 'WHERE',
+      expressionType: 'SQL',
+      sqlExpression: "name in ('c', 'd')",
+    } as FreeFormAdhocFilter,
+  ],
+  limit_b: undefined,
+  row_limit_b: 100,
+  timeseries_limit_metric_b: undefined,
+  order_desc_b: false,
+  emit_filter_b: undefined,
+  // chart configs
+  show_value: false,
+  show_valueB: undefined,
+};
+const formDataMixedChartWithAA = {
+  ...formDataMixedChart,
+  rolling_type: RollingType.Cumsum,
+  time_compare: ['1 years ago'],
+  comparison_type: ComparisionType.Values,
+  resample_rule: '1AS',
+  resample_method: 'zerofill',
+
+  rolling_type_b: RollingType.Sum,
+  rolling_periods_b: 1,
+  min_periods_b: 1,
+  comparison_type_b: ComparisionType.Difference,
+  time_compare_b: ['3 years ago'],
+  resample_rule_b: '1A',
+  resample_method_b: 'asfreq',
+};
+
+test('should compile query object A', () => {
+  const query_a = buildQuery(formDataMixedChart).queries[0];
+  expect(query_a).toEqual({
+    time_range: '1980 : 2000',
+    since: undefined,
+    until: undefined,
+    granularity: 'ds',
+    filters: [],
+    extras: {
+      having: '',
+      having_druid: [],
+      time_grain_sqla: 'P1W',
+      where: "(foo in ('a', 'b'))",
+    },
+    applied_time_extras: {},
+    columns: ['foo'],
+    metrics: ['sum(sales)'],
+    annotation_layers: [],
+    row_limit: 10,
+    row_offset: undefined,
+    series_columns: undefined,
+    series_limit: undefined,
+    series_limit_metric: undefined,
+    timeseries_limit: 5,
+    url_params: {},
+    custom_params: {},
+    custom_form_data: {},
+    is_timeseries: true,
+    time_offsets: [],
+    post_processing: [
+      {
+        operation: 'pivot',
+        options: {
+          aggregates: {
+            'sum(sales)': {
+              operator: 'mean',
+            },
+          },
+          columns: ['foo'],
+          drop_missing_columns: false,
+          flatten_columns: false,
+          index: ['__timestamp'],
+          reset_index: false,
+        },
+      },
+      undefined,
+      undefined,
+      undefined,
+      {
+        operation: 'rename',
+        options: {
+          columns: {
+            'sum(sales)': null,
+          },
+          inplace: true,
+          level: 0,
+        },
+      },
+      {
+        operation: 'flatten',
+      },
+    ],
+    orderby: [['count', false]],
+  });
+});
+
+test('should compile query object B', () => {
+  const query_a = buildQuery(formDataMixedChart).queries[1];
+  expect(query_a).toEqual({
+    time_range: '1980 : 2000',
+    since: undefined,
+    until: undefined,
+    granularity: 'ds',
+    filters: [],
+    extras: {
+      having: '',
+      having_druid: [],
+      time_grain_sqla: 'P1W',
+      where: "(name in ('c', 'd'))",
+    },
+    applied_time_extras: {},
+    columns: [],
+    metrics: ['count'],
+    annotation_layers: [],
+    row_limit: 100,
+    row_offset: undefined,
+    series_columns: undefined,
+    series_limit: undefined,
+    series_limit_metric: undefined,
+    timeseries_limit: 0,
+    url_params: {},
+    custom_params: {},
+    custom_form_data: {},
+    is_timeseries: true,
+    time_offsets: [],
+    post_processing: [
+      {
+        operation: 'pivot',
+        options: {
+          aggregates: {
+            count: {
+              operator: 'mean',
+            },
+          },
+          columns: [],
+          drop_missing_columns: false,
+          flatten_columns: false,
+          index: ['__timestamp'],
+          reset_index: false,
+        },
+      },
+      undefined,
+      undefined,
+      undefined,
+      undefined,

Review Comment:
   I will open separated PR to remove undefined in QueryObject.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a diff in pull request #19851: feat: add Advanced Analytics into mixed time series chart

Posted by GitBox <gi...@apache.org>.
villebro commented on code in PR #19851:
URL: https://github.com/apache/superset/pull/19851#discussion_r859599972


##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx:
##########
@@ -253,11 +255,33 @@ function createCustomizeSection(
   ];
 }
 
+function createAdvancedAnalyticsSection(
+  label: string,
+  controlSuffix: string,
+): ControlPanelSectionConfig {
+  const aaWithSuffix = cloneDeep(sections.advancedAnalyticsControls);
+  aaWithSuffix.label = label;
+  if (!controlSuffix) {
+    return aaWithSuffix;
+  }
+  aaWithSuffix.controlSetRows.forEach(row =>
+    row.forEach((control: CustomControlItem) => {
+      if (control?.name) {
+        // eslint-disable-next-line no-param-reassign
+        control.name = `${control.name}${controlSuffix}`;
+      }
+    }),
+  );
+  return aaWithSuffix;
+}
+

Review Comment:
   One minor observation: the "Periods" sets the visibility based on the state of the "Rolling Type" control:
   <img width="537" alt="image" src="https://user-images.githubusercontent.com/33317356/165491265-6b139d39-2e20-4e85-9472-daef5ec0bab3.png">
   This causes the "Periods" section in the B section to have an incorrect visibility (should be hidden for `cumsum`):
   <img width="316" alt="image" src="https://user-images.githubusercontent.com/33317356/165490846-4eb22cb0-11cf-449c-b00a-ab81fe2d4e38.png">
   



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #19851: feat: add Advanced Analytics into mixed time series chart

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #19851:
URL: https://github.com/apache/superset/pull/19851#discussion_r859740004


##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx:
##########
@@ -253,11 +255,33 @@ function createCustomizeSection(
   ];
 }
 
+function createAdvancedAnalyticsSection(
+  label: string,
+  controlSuffix: string,
+): ControlPanelSectionConfig {
+  const aaWithSuffix = cloneDeep(sections.advancedAnalyticsControls);
+  aaWithSuffix.label = label;
+  if (!controlSuffix) {
+    return aaWithSuffix;
+  }
+  aaWithSuffix.controlSetRows.forEach(row =>
+    row.forEach((control: CustomControlItem) => {
+      if (control?.name) {
+        // eslint-disable-next-line no-param-reassign
+        control.name = `${control.name}${controlSuffix}`;
+      }
+    }),
+  );
+  return aaWithSuffix;
+}
+

Review Comment:
   Thanks for the mention. I add a little trick to fix this.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org