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(datasets): give possibility to add dataset with slashes in name #24796

Conversation

Always-prog
Copy link
Contributor

@Always-prog Always-prog commented Jul 25, 2023

SUMMARY

Give possibility to users to add datasets which contains slashes in a table name

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before

2023-07-25_15-24-31.mp4

After

2023-07-25_15-28-11.mp4

TESTING INSTRUCTIONS

  1. Go to "*/dataset/add/" URL, or push "+DATASET" button.
  2. Choose database and schema.
  3. Choose a table with "/" symbol in name
  4. See error

ADDITIONAL INFORMATION

  • Has associated issue: 23540
  • 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 Jul 25, 2023

Codecov Report

Merging #24796 (bb0263e) into master (5bb8e0d) will not change coverage.
The diff coverage is 100.00%.

❗ Current head bb0263e differs from pull request most recent head 4119ee6. Consider uploading reports for the commit 4119ee6 to get more accurate results

@@           Coverage Diff           @@
##           master   #24796   +/-   ##
=======================================
  Coverage   68.99%   68.99%           
=======================================
  Files        1903     1903           
  Lines       74072    74072           
  Branches     8193     8193           
=======================================
  Hits        51104    51104           
  Misses      20847    20847           
  Partials     2121     2121           
Flag Coverage Δ
hive 54.13% <100.00%> (ø)
mysql 79.21% <100.00%> (ø)
postgres 79.31% <100.00%> (ø)
presto 54.03% <100.00%> (ø)
python 83.36% <100.00%> (ø)
sqlite 77.88% <100.00%> (ø)
unit 54.99% <100.00%> (ø)

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

Files Changed Coverage Δ
superset/databases/api.py 89.90% <100.00%> (ø)
superset/views/core.py 69.46% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@michael-s-molina
Copy link
Member

Thank for the PR @Always-prog. Could you add a test?

@Always-prog
Copy link
Contributor Author

@michael-s-molina Yeah, I can. I'll add it.

@michael-s-molina
Copy link
Member

@Always-prog If you do a quick search for <table_name> you'll see that there are other endpoints that need to be modified.

@dpgaspar Is there any concern with this change?

@Always-prog
Copy link
Contributor Author

@michael-s-molina I added a test for the slash in the table name and updated the table_name parameter type to path in all endpoints.

@michael-s-molina
Copy link
Member

michael-s-molina commented Jul 26, 2023

Here's the list of places that have <table_name>:

superset/databases/api.py::table_metadata
superset/databases/api.py::table_extra_metadata
superset/databases/api.py::select_star
superset/views/core.py::fetch_datasource_metadata
superset/db_engine_specs/presto.py::TABLE_DOES_NOT_EXIST_REGEX

@pull-request-size pull-request-size bot added size/S and removed size/M labels Jul 26, 2023
@Always-prog
Copy link
Contributor Author

@michael-s-molina I added path type to the all endpoints in your list excluding presto.py file because it contains just regex functions with <table_name>, it isn't endpoint.

@Always-prog
Copy link
Contributor Author

@michael-s-molina Hello! Can I get code review?

def test_get_table_details_with_slash_in_name(self):
table_name = "table_with/slash"
database = get_example_database()
if database.backend in ("mysql", "sqlite"):
Copy link
Member

Choose a reason for hiding this comment

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

It seems MySQL and SQLite support table names with slashes but you need to escape them.

@Always-prog
Copy link
Contributor Author

@michael-s-molina I added MySQL and SQLite to the test case, but why is there an error while migrating? I haven't changed any migrations.

@michael-s-molina
Copy link
Member

@michael-s-molina I added MySQL and SQLite to the test case, but why is there an error while migrating? I haven't changed any migrations.

It seems the error was fixed by #24832. You need to rebase your PR.

@Always-prog
Copy link
Contributor Author

@michael-s-molina Rebased

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for the fix @Always-prog!

@michael-s-molina michael-s-molina merged commit 64ced60 into apache:master Jul 28, 2023
29 checks passed
@michael-s-molina michael-s-molina added the v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch label Jul 31, 2023
@mistercrunch mistercrunch added 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 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 v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants