Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-chart-echarts): support adhoc x-axis #20055

Merged
merged 2 commits into from
May 13, 2022

Conversation

villebro
Copy link
Member

@villebro villebro commented May 13, 2022

SUMMARY

Currently using a Custom SQL expression with the GENERIC_CHART_AXES produces unexpected results. Here we ensure all post processing operations that support generic x-axes also support custom SQL adhoc columns. In addition, the transformProps of the ECharts Timeseries chart is update to properly handle custom SQL adhoc columns.

AFTER

Now the chart renders as expected:
image

BEFORE

Previously the chart data request returned zero rows:
image

TESTING INSTRUCTIONS

  1. Enable GENERIC_CHART_AXES feature flag
  2. create a new chart using one of the ECharts plugin charts, e.g. the scatter plot
  3. add a Custom SQL x-axis expression and any metric
  4. Create chart and see that no rows are returned

ADDITIONAL INFORMATION

  • Has associated issue: closes [GENERIC_CHART_AXES] Custom SQL for x-axis is broken #19974
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #20055 (c7ef015) into master (89a844a) will not change coverage.
The diff coverage is 100.00%.

❗ Current head c7ef015 differs from pull request most recent head 1da6428. Consider uploading reports for the commit 1da6428 to get more accurate results

@@           Coverage Diff           @@
##           master   #20055   +/-   ##
=======================================
  Coverage   66.35%   66.35%           
=======================================
  Files        1712     1712           
  Lines       64097    64097           
  Branches     6744     6744           
=======================================
  Hits        42534    42534           
  Misses      19850    19850           
  Partials     1713     1713           
Flag Coverage Δ
javascript 51.31% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...t-ui-chart-controls/src/operators/pivotOperator.ts 100.00% <100.00%> (ø)
...ui-chart-controls/src/operators/prophetOperator.ts 100.00% <100.00%> (ø)
...controls/src/operators/timeComparePivotOperator.ts 100.00% <100.00%> (ø)
...gin-chart-echarts/src/Timeseries/transformProps.ts 57.89% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89a844a...1da6428. Read the comment docs.

@villebro villebro requested a review from zhaoyongjie May 13, 2022 11:47
Comment on lines 36 to 40
const index = [getColumnLabel(formData.x_axis || DTTM_ALIAS)];
return {
operation: 'pivot',
options: {
index: [xAxis || DTTM_ALIAS],
index,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure which is better/more readable, inlining it or declaring it as a variable first. I went with declaring a const first, but looking at it now I should maybe have inlined it..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good 👍

@villebro villebro requested a review from kgabryje May 13, 2022 11:49
Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 nit, otherwise LGTM!

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@stephenLYZ stephenLYZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@villebro villebro merged commit b53daa9 into apache:master May 13, 2022
@villebro villebro deleted the villebro/adhoc-generic-x branch May 13, 2022 13:29
@rumbin
Copy link
Contributor

rumbin commented May 13, 2022

@villebro great, thanks a lot for fixing!
Will this PR be included in the 1.5 LTS branch?

@villebro
Copy link
Member Author

@villebro great, thanks a lot for fixing!

Will this PR be included in the 1.5 LTS branch?

@rumbin you bet! 🙂👍

villebro added a commit that referenced this pull request May 26, 2022
* fix(plugin-chart-echarts): support adhoc x-axis

* simplify code

(cherry picked from commit b53daa9)
michael-s-molina pushed a commit that referenced this pull request May 26, 2022
* fix(plugin-chart-echarts): support adhoc x-axis

* simplify code

(cherry picked from commit b53daa9)
philipher29 pushed a commit to ValtechMobility/superset that referenced this pull request Jun 9, 2022
* fix(plugin-chart-echarts): support adhoc x-axis

* simplify code
@mistercrunch mistercrunch added 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GENERIC_CHART_AXES] Custom SQL for x-axis is broken
7 participants