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(presto): default unknown types to string type #10753

Merged
merged 2 commits into from
Sep 22, 2020

Conversation

villebro
Copy link
Member

@villebro villebro commented Sep 1, 2020

SUMMARY

A recent PR #10658 introduced a regression on Presto for undefined column types. The regression was caused due to one of the methods calling the get_sqla_column_type method with None which is contradictory with the method signature. This reverts exception raising for unknown types and defaults those to sqlalchemy.types.String(), while at the same time logging the discrepancy.

Going forward the associated methods need to be broken up and properly unit tested, as they are currently very difficult to follow.

TEST PLAN

CI + added test

ADDITIONAL INFORMATION

Comment on lines +177 to +179
def _create_column_info(
cls, name: str, data_type: types.TypeEngine
) -> Dict[str, Any]:
Copy link
Member Author

@villebro villebro Sep 1, 2020

Choose a reason for hiding this comment

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

Not sure why MyPy hadn't picked up on the calls sending TypeEngine to data_type, not str.

@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2020

Codecov Report

Merging #10753 into master will decrease coverage by 4.66%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10753      +/-   ##
==========================================
- Coverage   64.98%   60.31%   -4.67%     
==========================================
  Files         789      789              
  Lines       37179    37181       +2     
  Branches     3555     3555              
==========================================
- Hits        24161    22426    -1735     
- Misses      12911    14568    +1657     
- Partials      107      187      +80     
Flag Coverage Δ
#cypress ?
#javascript 61.49% <ø> (ø)
#python 59.60% <50.00%> (-0.69%) ⬇️

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

Impacted Files Coverage Δ
superset/db_engine_specs/presto.py 70.53% <20.00%> (-11.08%) ⬇️
superset/db_engine_specs/base.py 87.74% <100.00%> (+0.06%) ⬆️
superset-frontend/src/SqlLab/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupColors.js 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/chart/ChartContainer.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupFormatters.js 0.00% <0.00%> (-100.00%) ⬇️
... and 167 more

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 807bd65...803337d. Read the comment docs.

(see MSSQL for example of NCHAR/NVARCHAR handling).

:param type_: Column type returned by inspector
:return: SqlAlchemy column type
"""
if not type_:
Copy link
Member

Choose a reason for hiding this comment

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

Is this somewhat of an anti-pattern, i.e., passing type_ as None results in the short-circuit and returning None . Can we not call get_sqla_column_type if the type is None?

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 what calling this with None should return. As far as I'm aware, only the Presto db engine spec currently does this, so it would be nice to get more context and tests (see #10743 (comment)) to make sure this is working as intended.

@pull-request-size pull-request-size bot added size/S and removed size/M labels Sep 22, 2020
@villebro villebro merged commit bd140e0 into apache:master Sep 22, 2020
@villebro villebro added the v0.38 label Sep 22, 2020
dpgaspar pushed a commit that referenced this pull request Sep 22, 2020
* fix(presto): default unknown types to string type

* lint
amitmiran137 pushed a commit to ofekisr/incubator-superset that referenced this pull request Sep 22, 2020
…l_access/dashboard_by_id_endpoints

* upstream/master: (29 commits)
  fix(presto): default unknown types to string type (apache#10753)
  feat(row-level-security): add base filter type and filter grouping (apache#10946)
  docs: add gallery screenshot & link in README (apache#10988)
  docs: add a "Gallery" page (apache#10968)
  build: add PR lint action (apache#10990)
  adding filters back that caused issues (apache#10989)
  chore: selectors refactor in SQLLab test suite (Cypress) (apache#10944)
  ESLint: Remove ts-ignore comments (apache#10933)
  style: fix checkbox color (apache#10970)
  fix: changed disabled rules in datasets module (apache#10979)
  fix: update the time filter for 'Last Year' option in explore (apache#10829)
  fix: use nullpool even for user lookup in the celery (apache#10938)
  Allow empty observations in alerting (apache#10939)
  fix: re-enabling several globally disabled lint rules (apache#10957)
  fix: setting specific exceptions common/query_context.py (apache#10942)
  Pylint disabled rule `pointless-string-statement` is not raising warining anymore - removing (apache#10975)
  fix: pylint disabled rules in dashboard/api.py (apache#10976)
  fix: removed disabled lint rule `too-many-locals` in connectors/base/models.py (apache#10958)
  ESLint: Re-enable rule no-access-state-in-setstate (apache#10870)
  fix: simply is_adhoc_metric (apache#10964)
  ...
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* fix(presto): default unknown types to string type

* lint
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.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 size/S v0.38 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error loading charts for presto table with null column types
4 participants