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

refactor: external metadata fetch API #16193

Merged
merged 6 commits into from
Aug 13, 2021

Conversation

zhaoyongjie
Copy link
Member

@zhaoyongjie zhaoyongjie commented Aug 11, 2021

SUMMARY

closes: #16172
When special characters("/") are encountered, the API /datasource/external_metadata_by_name/<datasouce_type>/<database_name>/<schema_name>/<table_name> cannot be called.

This PR refactor this API to /datasource/external_metadata_by_name/?q=<rison string>

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

After

virtual_dataset_sync.mov

TESTING INSTRUCTIONS

  1. Create a virtual dataset from SQLLab, ensure that dataset's name contains "/" and "space"
  2. Goto dataset List
  3. Sync columns from source

ADDITIONAL INFORMATION

  • Has associated issue: "Sync columns from source" broken for complex datasource names #16172
  • 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

@junlincc junlincc added the risk:refactor High risk as it involves large refactoring work label Aug 11, 2021
@codecov
Copy link

codecov bot commented Aug 12, 2021

Codecov Report

Merging #16193 (5df173e) into master (6df16c4) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16193      +/-   ##
==========================================
- Coverage   76.75%   76.71%   -0.05%     
==========================================
  Files         996      997       +1     
  Lines       53054    53073      +19     
  Branches     6760     6740      -20     
==========================================
- Hits        40721    40714       -7     
- Misses      12107    12130      +23     
- Partials      226      229       +3     
Flag Coverage Δ
hive 81.26% <100.00%> (-0.10%) ⬇️
javascript 70.96% <100.00%> (-0.21%) ⬇️
mysql 81.51% <100.00%> (-0.06%) ⬇️
postgres 81.54% <100.00%> (-0.10%) ⬇️
presto 81.41% <100.00%> (?)
python 82.09% <100.00%> (+0.09%) ⬆️
sqlite 81.22% <100.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
...erset-frontend/src/datasource/DatasourceEditor.jsx 74.44% <100.00%> (+0.19%) ⬆️
superset/connectors/sqla/utils.py 92.15% <100.00%> (+0.49%) ⬆️
superset/initialization/__init__.py 87.72% <100.00%> (ø)
superset/views/datasource/schemas.py 100.00% <100.00%> (ø)
superset/views/datasource/views.py 91.95% <100.00%> (ø)
...mponents/controls/MetricControl/MetricsControl.jsx 42.05% <0.00%> (-40.89%) ⬇️
superset/utils/profiler.py 40.90% <0.00%> (-6.15%) ⬇️
superset/examples/utils.py 28.57% <0.00%> (-3.43%) ⬇️
...set-frontend/src/views/CRUD/welcome/ChartTable.tsx 73.17% <0.00%> (-1.83%) ⬇️
superset/views/base.py 75.86% <0.00%> (-1.38%) ⬇️
... and 15 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 6df16c4...5df173e. Read the comment docs.

Copy link
Member

@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.

Looks great - one minor question before pressing approve

Comment on lines +498 to +500
Object.keys(params).map(key =>
params[key] === undefined ? null : params[key],
),
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to encode the key/value pairs (Object.entries), not just the values (Object.keys)? (honest question, I haven't done a lot of this rison API stuff)

Copy link
Member Author

Choose a reason for hiding this comment

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

this is to code entire params field, just change undefined to null, because prison can't encode undefined value

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes now I see! 🤦

Copy link
Member

@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.

LGTM, and special thanks for the comprehensive tests!

@zhaoyongjie zhaoyongjie merged commit 6cd15d5 into apache:master Aug 13, 2021
amitmiran137 pushed a commit that referenced this pull request Aug 16, 2021
…gies

* upstream/master: (64 commits)
  check roles before fetching reports (#16260)
  chore: upgrade mypy and add type guards (#16227)
  fix: pivot columns with ints for name (#16259)
  chore(pylint): Bump Pylint to 2.9.6 (#16146)
  fix examples tab for dashboard (#16253)
  chore: bump superset-ui packages to 0.17.84 (#16251)
  chore: Shows the dataset description in the gallery dropdown (#16200)
  fix(Dashboard): Omnibar dropdown visibility and keyboard commands (#16168)
  chore: bump py version for integration test (#16213)
  fix: skip perms on query context update (#16250)
  refactor: external metadata fetch API (#16193)
  feat(dao): admin can remove self from object owners (#15149)
  fix(dashboard): cross filter chart highlight when filters badge icon clicked (#16233)
  fix: validate_parameters and query (#16241)
  fix: Remove Advanced Analytics tag for 2 charts (#16240)
  Revert "feat: Changing Dataset names (#16199)" (#16235)
  feat: Allow users to connect via legacy SQLA form (#16201)
  fix: remove encryption from db params (#16214)
  fix(Explore): Show the tooltip only when label does not fit the container in METRICS/FILTERS/GROUP BY/SORT BY of the DATA panel (#16060)
  Show/hide tooltips (#16192)
  ...

# Conflicts:
#	superset/tasks/caching/cache_strategy.py
from typing_extensions import TypedDict


class ExternalMetadataParams(TypedDict):
Copy link
Member

Choose a reason for hiding this comment

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

@villebro @zhaoyongjie I wonder if we should be using marshmallow_dataclass instead as it adhere's to the DRY principle and simplifies the code. I've used it for an internal project and I'm definitely a fan.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the mention. It's a more elegant way, let me try to use marshmallow_dataclass to refactor this class.

@villebro villebro added the v1.3 label Aug 27, 2021
villebro pushed a commit that referenced this pull request Sep 6, 2021
* refactor: external metadata api

* fix comments

* fix ut

* fix fe lint

* fix UT

* fix UT

(cherry picked from commit 6cd15d5)
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
* refactor: external metadata api

* fix comments

* fix ut

* fix fe lint

* fix UT

* fix UT
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
* refactor: external metadata api

* fix comments

* fix ut

* fix fe lint

* fix UT

* fix UT
@mistercrunch mistercrunch added 🍒 1.3.1 🍒 1.3.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.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 risk:refactor High risk as it involves large refactoring work size/L v1.3 🍒 1.3.1 🍒 1.3.2 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Sync columns from source" broken for complex datasource names
5 participants