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] SQL parsing of table names #7490

Conversation

john-bodley
Copy link
Member

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

Presto supports using the optional cluster when specifying the table name, i.e., [[cluster.]schema].table however the currently SQL parse logic only returns at most the first two components, i.e., cluster.schema if a cluster was defined.

This PR extends the logic to support the [[cluster.]schema].table construct as well as:

  • Ensures the table construct is valid in terms of length and structure.
  • Ensures that the quotes are removed from each token. Previously this was only the case when only the table was specified which were removed via get_real_name().
  • The get_real_name() logic wasn't overly apparent though it's used when a table alias is present. I felt this logic wasn't overly clear and in the case of a TokenList representing schema.table AS foo the get_real_name() only returns table (though this wasn't invoked because there was the . token). From a table construct validity perspective it seems more prudent to strip the alias and then extract the full table name if valid.

TEST PLAN

CI.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

to: @graceguo-supercat @michellethomas @mistercrunch

@john-bodley john-bodley force-pushed the john-bodley--fix-sql-parse-__get_full_name branch from 07054b2 to a938795 Compare May 11, 2019 15:49
@codecov-io
Copy link

codecov-io commented May 11, 2019

Codecov Report

Merging #7490 into master will increase coverage by 0.01%.
The diff coverage is 89.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7490      +/-   ##
==========================================
+ Coverage   65.42%   65.43%   +0.01%     
==========================================
  Files         435      435              
  Lines       21323    21330       +7     
  Branches     2347     2347              
==========================================
+ Hits        13950    13957       +7     
  Misses       7257     7257              
  Partials      116      116
Impacted Files Coverage Δ
superset/sql_parse.py 99.2% <100%> (+0.05%) ⬆️
superset/security.py 76.08% <60%> (-0.11%) ⬇️

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 4377328...d54978e. Read the comment docs.

@john-bodley john-bodley force-pushed the john-bodley--fix-sql-parse-__get_full_name branch from a938795 to d54978e Compare May 12, 2019 18:13
@john-bodley john-bodley force-pushed the john-bodley--fix-sql-parse-__get_full_name branch from d54978e to 1678471 Compare May 13, 2019 18:07
@john-bodley john-bodley added !deprecated-label:bug Deprecated label - Use #bug instead and removed bug:external labels May 22, 2019
@john-bodley john-bodley merged commit 45b41aa into apache:master Jun 3, 2019
@john-bodley john-bodley deleted the john-bodley--fix-sql-parse-__get_full_name branch June 3, 2019 18:08
john-bodley added a commit to john-bodley/superset that referenced this pull request Jul 12, 2019
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 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 !deprecated-label:bug Deprecated label - Use #bug instead size/M 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants