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

feat(explore): adhoc column expressions [ID-3] #17379

Merged
merged 48 commits into from
Nov 15, 2021

Conversation

villebro
Copy link
Member

@villebro villebro commented Nov 9, 2021

SUMMARY

Adds support for adhoc column expressions, similar to how adhoc metrics work. See video for example where gender that features values "boy" and "girl" is replaced with a case-statement that maps these values to "male" and "female":

adhoc_column.mp4

The resulting query:
image

Part of the work is done in apache-superset/superset-ui#1342 (featured in the included bump of superset-ui).

TESTING INSTRUCTIONS

  1. Enable ENABLE_EXPLORE_DRAG_AND_DROP, UX_BETA, ENABLE_DND_WITH_CLICK_UX feature flags
  2. Create a new chart
  3. click on a column select component
  4. Go to "Custom SQL" and create an expression

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

villebro and others added 28 commits September 1, 2021 12:02
…#16412)

* Support Jinja template functions in async queries

* Pylint

* Add tests for async tasks

* Remove redundant has_request_context check
* feat: Add Aurora Data API engine spec

* Fix lint
…#16548)

* refactor sql_json view endpoint: encapsulate ctas parameters

* fix failed tests

* fix failed tests and ci issues
* fix:fix get permission function

* feat: add cross filter chart in charts gallery under FF
Copy link
Member Author

@villebro villebro left a comment

Choose a reason for hiding this comment

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

First pass, just one minor nit

@kgabryje
Copy link
Member

/testenv up FEATURE_UX_BETA=true FEATURE_ENABLE_EXPLORE_DRAG_AND_DROP=true FEATURE_ENABLE_DND_WITH_CLICK_UX=true

@github-actions
Copy link
Contributor

@kgabryje Ephemeral environment spinning up at http://35.86.253.253:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@geido geido self-requested a review November 12, 2021 14:57
Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

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

Code LGTM! Going to do manual testing

@jinghua-qa
Copy link
Member

Do we need to re-spin up the test env? Saw the test env is not spin up at the latest commit

@kgabryje
Copy link
Member

/testenv up FEATURE_UX_BETA=true FEATURE_ENABLE_EXPLORE_DRAG_AND_DROP=true FEATURE_ENABLE_DND_WITH_CLICK_UX=true

@kgabryje
Copy link
Member

Do we need to re-spin up the test env? Saw the test env is not spin up at the latest commit

Good point! The latest changes shouldn't affect the functionality in any way, but better to be safe than sorry

@github-actions
Copy link
Contributor

@kgabryje Ephemeral environment spinning up at http://52.26.96.154:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@rumbin
Copy link
Contributor

rumbin commented Nov 14, 2021

Had a quick look at the ephemeral env.
The ad-hoc column expressions are such a beauty!

Thanks a lot for implementing it. I am eagerly awaiting it to be merged and released :-)

Copy link
Member

@jinghua-qa jinghua-qa 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

@geido geido left a comment

Choose a reason for hiding this comment

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

LGTM! Awesome work

@villebro villebro merged commit e2a429b into apache:master Nov 15, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@villebro villebro deleted the hack2021/adhoc-columns branch November 15, 2021 10:50
@sadpandajoe
Copy link
Contributor

🏷️ 2021.46

AAfghahi pushed a commit that referenced this pull request Jan 10, 2022
* add support for adhoc columns to api and sqla model

* fix some types

* fix duplicates in column names

* fix more lint

* fix schema and dedup

* clean up some logic

* first pass at fixing viz.py

* Add frontend support for adhoc columns

* Add title edit

* Fix showing custom title

* Use column name as default value in sql editor

* fix: Adds a loading message when needed in the Select component (#16531)

* fix(tests): make parquet select deterministic with order by (#16570)

* bump emotion to help with cache clobbering (#16559)

* fix: Support Jinja template functions in global async queries (#16412)

* Support Jinja template functions in async queries

* Pylint

* Add tests for async tasks

* Remove redundant has_request_context check

* fix: impersonate user label/tooltip (#16573)

* docs: update for small typos (#16568)

* feat: Add Aurora Data API engine spec (#16535)

* feat: Add Aurora Data API engine spec

* Fix lint

* refactor: sql_json view endpoint: encapsulate ctas parameters (#16548)

* refactor sql_json view endpoint: encapsulate ctas parameters

* fix failed tests

* fix failed tests and ci issues

* refactor sql_json view endpoint: separate concern into ad hod method (#16595)

* feat: Experimental cross-filter plugins (#16594)

* fix:fix get permission function

* feat: add cross filter chart in charts gallery under FF

* chore(deps): bump superset-ui to 0.18.2 (#16601)

* update type guard references

* fix imports

* update series_columns schema

* Add changes that got lost in rebase

* Use current columns name or expression as sql editor init value

* add integration test and do minor fixes

* Bump superset-ui

* fix linting issue

* bump superset-ui to 0.18.22

* resolve merge conflict

* lint

* fix select filter infinite loop

* bump superset-ui to 0.18.23

* Fix auto setting column popover title

* Enable adhoc columns only if UX_BETA enabled

* put back removed test

* Move popover height and width to constants

* Refactor big ternary expression

Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
Co-authored-by: Rob DiCiuccio <rob.diciuccio@gmail.com>
Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
Co-authored-by: joeADSP <75027008+joeADSP@users.noreply.github.com>
Co-authored-by: ofekisr <35701650+ofekisr@users.noreply.github.com>
Co-authored-by: simcha90 <56388545+simcha90@users.noreply.github.com>
for column in columns or []:
label = get_column_name(column)
if label not in labels:
deduped_columns.append(column)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we also need to append label in labels ?
but this didn't cause any issue, because there are checks in /explore_json api somewhere which throws { "error": "Group By' and 'Columns' can't overlap" }

Copy link
Member Author

Choose a reason for hiding this comment

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

@mayurnewase do you have repro steps for this error?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just going through this feature and found pivot table allows same group by and column name, but looking at this function it's not expected.
So I thought this might be incorrect as its not really putting anything in labels list.
So may need to add labels.append(label) here?

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 did a quick test, and it seems the legacy pivot table does work with overlapping groupby and column names:
image

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.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 preset:2021.46 preset-io size/XL 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet