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

chore(sqllab): Do not strip comments when executing SQL statements #27725

Merged

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Mar 27, 2024

SUMMARY

I realize there is merit for stripping SQL comments when parsing SQL to extract tables etc., i.e., to aid with simplification, however I'm not entirely sure why we do this when executing SQL especially given that numerous SQL dialects supports optimizer hints in the form of comments:

This PR ensures when running SQL statements in SQL Lab we don't strip away the comments.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

CI.

ADDITIONAL INFORMATION

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

@john-bodley john-bodley force-pushed the john-bodley--do-not-strip-comments branch from a05d7b9 to 0b35815 Compare March 28, 2024 01:37
@john-bodley john-bodley force-pushed the john-bodley--do-not-strip-comments branch from 0b35815 to 7b317d6 Compare March 28, 2024 01:46
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.85%. Comparing base (5e8459b) to head (7b317d6).
Report is 90 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #27725      +/-   ##
==========================================
+ Coverage   67.46%   69.85%   +2.38%     
==========================================
  Files        1910     1911       +1     
  Lines       74802    74988     +186     
  Branches     8345     8345              
==========================================
+ Hits        50467    52381    +1914     
+ Misses      22284    20556    -1728     
  Partials     2051     2051              
Flag Coverage Δ
hive 48.93% <ø> (?)
mysql 77.91% <ø> (-0.12%) ⬇️
postgres 78.02% <ø> (-0.12%) ⬇️
presto 53.64% <ø> (?)
python 83.15% <ø> (+4.87%) ⬆️
sqlite 77.46% <ø> (-0.12%) ⬇️
unit 56.76% <ø> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

Oh yeah, we should definitely not be stripping comments. There are multiple reasons to leave them — in addition to optimization like you mentioned I've also seen them used for auditing. Thanks for fixing this!

@betodealmeida
Copy link
Member

(I restarted the flaky MySQL test for you.)

@john-bodley john-bodley marked this pull request as ready for review March 28, 2024 17:30
@john-bodley john-bodley force-pushed the john-bodley--do-not-strip-comments branch from 7b317d6 to 225a04d Compare April 3, 2024 16:11
@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 3, 2024
@john-bodley john-bodley force-pushed the john-bodley--do-not-strip-comments branch from 225a04d to cdfa700 Compare April 3, 2024 23:28
@john-bodley john-bodley force-pushed the john-bodley--do-not-strip-comments branch from cdfa700 to a04a63b Compare April 4, 2024 02:06
@john-bodley john-bodley merged commit 5ed4876 into apache:master Apr 4, 2024
40 checks passed
@john-bodley john-bodley deleted the john-bodley--do-not-strip-comments branch April 4, 2024 02:49
jzhao62 pushed a commit to jzhao62/superset that referenced this pull request Apr 4, 2024
@michael-s-molina michael-s-molina added v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch labels Apr 4, 2024
michael-s-molina pushed a commit that referenced this pull request Apr 8, 2024
mistercrunch added a commit that referenced this pull request May 7, 2024
Following up in the footsteps of #27725 as comments can be used as a way to pass the database engine hints, or for logging purposes.
@mistercrunch mistercrunch added 🍒 3.1.3 🍒 4.0.1 🍒 4.0.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Jul 2, 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/M v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch 🍒 3.1.3 🍒 4.0.1 🍒 4.0.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants