You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "betodealmeida (via GitHub)" <gi...@apache.org> on 2023/04/19 00:31:31 UTC
[GitHub] [superset] betodealmeida opened a new pull request, #23731: fix: pivot v2 charts created before `GENERIC_CHART_AXES` is enabled
betodealmeida opened a new pull request, #23731:
URL: https://github.com/apache/superset/pull/23731
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
Pivot v2 charts lose their time granularity when `GENERIC_CHART_AXES` is enabled, see screenshots.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
Before, a dashboard showing two pivot charts with monthly time grain, with `GENERIC_CHART_AXES` enabled. The one on the left was created before `GENERIC_CHART_AXES` was enabled, and the one on the right was created after. Note that the left chart has multiple values for January, which shouldn't happen:
![Screenshot 2023-04-18 at 16-41-16 pivot test](https://user-images.githubusercontent.com/1534870/232935626-d52a8b21-ea73-472d-aa31-8e75c22be4ab.png)
After:
![Screenshot 2023-04-18 at 16-41-42 pivot test](https://user-images.githubusercontent.com/1534870/232935642-9276760e-cb0f-44fa-9d40-6773de950b01.png)
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
### 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:
- [ ] 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] hughhhh commented on a diff in pull request #23731: fix: pivot v2 charts created before `GENERIC_CHART_AXES` is enabled
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #23731:
URL: https://github.com/apache/superset/pull/23731#discussion_r1171575453
##########
superset-frontend/packages/superset-ui-core/src/query/buildQueryContext.ts:
##########
@@ -59,6 +60,38 @@ export default function buildQueryContext(
if (isXAxisSet(formData)) {
queries = queries.map(query => normalizeTimeColumn(formData, query));
}
+
+ /* Some charts saved before GENERIC_CHART_AXES is enabled will have the wrong
+ * time granularity set. This fixes the generated payload to conform with the new
+ * schema used when GENERIC_CHART_AXES is enabled.
+ */
+ if (hasGenericChartAxes && formData.granularity_sqla) {
+ const filterSubject = formData.granularity_sqla;
Review Comment:
```suggestion
const { granularity_sqla: filterSubject, time_range: timeRange } = formData;
const filterComparator = timeRange || 'No Filter';
```
--
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] hughhhh commented on a diff in pull request #23731: fix: pivot v2 charts created before `GENERIC_CHART_AXES` is enabled
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #23731:
URL: https://github.com/apache/superset/pull/23731#discussion_r1171575453
##########
superset-frontend/packages/superset-ui-core/src/query/buildQueryContext.ts:
##########
@@ -59,6 +60,38 @@ export default function buildQueryContext(
if (isXAxisSet(formData)) {
queries = queries.map(query => normalizeTimeColumn(formData, query));
}
+
+ /* Some charts saved before GENERIC_CHART_AXES is enabled will have the wrong
+ * time granularity set. This fixes the generated payload to conform with the new
+ * schema used when GENERIC_CHART_AXES is enabled.
+ */
+ if (hasGenericChartAxes && formData.granularity_sqla) {
+ const filterSubject = formData.granularity_sqla;
Review Comment:
```suggestion
const { granularity_sqla: filterSubject, time_range: timeRange } = formData;
const filterComparator = timeRange || 'No Filter';
```
--
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 #23731: fix: pivot v2 charts created before `GENERIC_CHART_AXES` is enabled
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #23731:
URL: https://github.com/apache/superset/pull/23731#issuecomment-1513958923
## [Codecov](https://codecov.io/gh/apache/superset/pull/23731?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 [#23731](https://codecov.io/gh/apache/superset/pull/23731?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (06b066f) into [master](https://codecov.io/gh/apache/superset/commit/b39edc1002f6620b0ae71f96be3df8f9f27070bb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b39edc1) will **decrease** coverage by `9.59%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## master #23731 +/- ##
==========================================
- Coverage 66.30% 56.71% -9.59%
==========================================
Files 1922 1922
Lines 74048 74048
Branches 8104 8104
==========================================
- Hits 49094 41996 -7098
- Misses 22882 29980 +7098
Partials 2072 2072
```
| Flag | Coverage Δ | |
|---|---|---|
| hive | `53.18% <ø> (?)` | |
| mysql | `?` | |
| postgres | `?` | |
| python | `59.50% <ø> (-19.93%)` | :arrow_down: |
| sqlite | `?` | |
| unit | `53.02% <ø> (?)` | |
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/23731?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...es/superset-ui-core/src/query/buildQueryContext.ts](https://codecov.io/gh/apache/superset/pull/23731?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGFja2FnZXMvc3VwZXJzZXQtdWktY29yZS9zcmMvcXVlcnkvYnVpbGRRdWVyeUNvbnRleHQudHM=) | `100.00% <ø> (ø)` | |
... and [352 files with indirect coverage changes](https://codecov.io/gh/apache/superset/pull/23731/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?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] hughhhh commented on a diff in pull request #23731: fix: pivot v2 charts created before `GENERIC_CHART_AXES` is enabled
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #23731:
URL: https://github.com/apache/superset/pull/23731#discussion_r1171580244
##########
superset-frontend/packages/superset-ui-core/test/query/buildQueryContext.test.ts:
##########
@@ -164,4 +165,152 @@ describe('buildQueryContext', () => {
expect(spyNormalizeTimeColumn).not.toBeCalled();
spyNormalizeTimeColumn.mockRestore();
});
+ it('should fix pivot v2 charts saved before GENERIC_CHART_AXES was enabled', () => {
+ Object.defineProperty(buildQueryContextModule, 'hasGenericChartAxes', {
+ value: true,
+ });
+ const queryContext = buildQueryContext(
+ {
+ datasource: '22__table',
+ viz_type: 'pivot_table_v2',
+ slice_id: 138,
+ url_params: {
+ native_filters_key:
+ 'oGUUQKLlluSODgWflOlhSKi2dMljuOTbyGVxVlZ8s5xp_nTJpd3rdWram_xNDotb',
+ },
+ groupbyColumns: ['order_date'],
+ groupbyRows: [],
+ time_grain_sqla: 'P1M',
+ temporal_columns_lookup: {},
+ metrics: ['count'],
+ metricsLayout: 'COLUMNS',
+ adhoc_filters: [],
+ row_limit: 10000,
+ order_desc: true,
+ aggregateFunction: 'Sum',
+ valueFormat: 'SMART_NUMBER',
+ date_format: 'smart_date',
+ rowOrder: 'key_a_to_z',
+ colOrder: 'key_a_to_z',
+ dashboards: [13],
+ extra_form_data: {},
+ granularity_sqla: 'order_date',
+ time_range: 'No filter',
+ label_colors: {},
+ shared_label_colors: {},
+ extra_filters: [],
+ dashboardId: 13,
+ force: undefined,
+ result_format: 'json',
+ result_type: 'full',
+ },
+ () => [
+ {
+ annotation_layers: [],
+ applied_time_extras: {},
+ columns: ['order_date'],
+ custom_form_data: {},
+ custom_params: {},
+ extras: {
+ having: '',
+ where: '',
+ },
+ filters: [],
+ granularity: 'order_date',
+ metrics: ['count'],
+ order_desc: true,
+ orderby: [['count', false]],
+ row_limit: 10000,
+ series_limit: 0,
+ time_range: 'No filter',
+ url_params: {
+ native_filters_key:
+ 'oGUUQKLlluSODgWflOlhSKi2dMljuOTbyGVxVlZ8s5xp_nTJpd3rdWram_xNDotb',
+ },
+ },
+ ],
+ );
+ expect(queryContext).toEqual({
+ datasource: {
Review Comment:
nit: rather put this into `expectedResult` const then at the bottom have this:
```
expect(queryContext).toEqual(expectedResult)
```
--
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] betodealmeida merged pull request #23731: fix: pivot v2 charts created before `GENERIC_CHART_AXES` is enabled
Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida merged PR #23731:
URL: https://github.com/apache/superset/pull/23731
--
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