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: add generic type to column payload #14547

Merged
merged 3 commits into from
May 13, 2021

Conversation

villebro
Copy link
Member

@villebro villebro commented May 10, 2021

SUMMARY

Adds the generic datatype to the dataset column payload to avoid having to parse the raw datatypes in the frontend. Also bump superset-ui to bring in updates to superset-ui/core that are required to make this function properly: apache-superset/superset-ui#1102

BEFORE

Currently the numeric datatypes on the FCC 2018 example dataset show up as unidentified due to the frontend not being able to detect the generic datatype of the raw datatype from the database ("DOUBLE PRECISION"):
image

AFTER

Now numeric types are being picked up automatically. In the future only datatypes that the db engine spec doesn't identify are shown as question marks:
image

TEST PLAN

Added datatype tests for Postgres

ADDITIONAL INFORMATION

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

Codecov Report

Merging #14547 (eab110a) into master (31f406a) will not change coverage.
The diff coverage is 77.77%.

❗ Current head eab110a differs from pull request most recent head 8853b1a. Consider uploading reports for the commit 8853b1a to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master   #14547   +/-   ##
=======================================
  Coverage   77.46%   77.46%           
=======================================
  Files         959      959           
  Lines       48450    48450           
  Branches     5680     5680           
=======================================
  Hits        37532    37532           
  Misses      10718    10718           
  Partials      200      200           
Flag Coverage Δ
javascript 72.51% <0.00%> (ø)

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

Impacted Files Coverage Δ
...rontend/src/filters/components/Range/buildQuery.ts 40.00% <ø> (ø)
...ers/components/TimeGrain/TimeGrainFilterPlugin.tsx 0.00% <0.00%> (ø)
superset/db_engine_specs/base.py 88.42% <ø> (ø)
superset/connectors/base/models.py 90.90% <77.77%> (ø)
superset/connectors/sqla/models.py 90.07% <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 31f406a...8853b1a. Read the comment docs.

@villebro villebro force-pushed the villebro/type-generic branch 3 times, most recently from 1e44a08 to 181ab7d Compare May 10, 2021 14:33
@pull-request-size pull-request-size bot added size/L and removed size/M labels May 10, 2021
@villebro villebro changed the title [WIP] feat: add generic type to column payload feat: add generic type to column payload May 10, 2021
@junlincc
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

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

@junlincc
Copy link
Member

thank you Ville! for some reasons i am still seeing "?" as the icon locally

@junlincc junlincc added the hold:testing! On hold for testing label May 10, 2021
@villebro
Copy link
Member Author

thank you Ville! for some reasons i am still seeing "?" as the icon locally

The question mark won't go away until apache-superset/superset-ui#1102 is released and bumped on the main repo. But since this is not a breaking change I think it makes sense to merge this first to avoid having to make a superset-ui bump coincide with this PR.

@junlincc junlincc removed the hold:testing! On hold for testing label May 11, 2021
@junlincc junlincc requested a review from zhaoyongjie May 11, 2021 19:49
@junlincc
Copy link
Member

junlincc commented May 11, 2021

gotcha, @zhaoyongjie please help review, i wanna get this PR and apache-superset/superset-ui#1102 in soon. 🙏 @villebro can we get the test pass?

@junlincc
Copy link
Member

/testenv up

@junlincc
Copy link
Member

junlincc commented May 12, 2021

hmmm still seeing "?" this one seems low risk, i am comfortable of merging if code is good. will look at it right it's in master

@rusackas rusackas added the bash! label May 12, 2021
@github-actions
Copy link
Contributor

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

Comment on lines -48 to +50
.get(`[data-test="chart-grid-component"][data-test-chart-name="${name}"]`)
.get(`[data-test="chart-grid-component"][data-test-chart-name="${name}"]`, {
timeout: 30000,
})
Copy link
Member Author

@villebro villebro May 13, 2021

Choose a reason for hiding this comment

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

This was resolving very close to the default 5 secs, and apparently started causing widespread flakiness on cypress. I bumped this to the 30s seen a few lines below, now all tests pass.

@villebro villebro added the data:connect:postgres Related to Postgres label May 13, 2021
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! thanks for the improvment.
Tested in postgres

image

@villebro villebro merged commit 3f6bd1e into apache:master May 13, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@villebro villebro deleted the villebro/type-generic branch May 13, 2021 06:36
@@ -29,7 +29,8 @@ export const columns: ColumnMeta[] = [
id: 516,
is_dttm: false,
python_date_format: null,
type: ColumnType.DOUBLE,
type: 'DOUBLE',
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we use ColumnType here anymore? Comment applies to all other "ColumnType -> hardcoded string" changes

Copy link
Member Author

Choose a reason for hiding this comment

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

ColumnType has been removed from superset-ui/core and replaced with string, as it's the raw column type coming back from the database. ColumnType was really just a generalization that mostly complied with ANSI SQL types, but this was not a scalable solution, as the frontend mostly isn't aware of which database is being used. As an example, the datatype DOUBLE PRECISION wasn't being picked up on the frontend due to it being a datatype that's mostly only available on dialects of Postgres. In corner cases two datatypes with the same name can mean different things on different databases (the boolean type on MySQL comes to mind, which is actually an integer). As these are now handled in the backend and mapped to GenericDataType, that's what we're now going to be using for the most part.

@junlincc junlincc added rush! Requires immediate attention and removed rush! Requires immediate attention labels May 18, 2021
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
* feat: add generic type to column payload

* feat: add generic type to column payload

* xit flaky test
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* feat: add generic type to column payload

* feat: add generic type to column payload

* xit flaky test
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* feat: add generic type to column payload

* feat: add generic type to column payload

* xit flaky test
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 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 data:connect:postgres Related to Postgres preset-io release:note size/L 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants