-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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(sqllab): throw errors of commented out query #23378
fix(sqllab): throw errors of commented out query #23378
Conversation
Codecov Report
@@ Coverage Diff @@
## master #23378 +/- ##
==========================================
+ Coverage 65.91% 67.64% +1.72%
==========================================
Files 1907 1908 +1
Lines 73453 73741 +288
Branches 7976 7987 +11
==========================================
+ Hits 48420 49881 +1461
+ Misses 22983 21814 -1169
+ Partials 2050 2046 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 74 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@michael-s-molina could you help this code review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @justinpark. I left a couple of comments.
export function cleanSqlComments(sql) { | ||
if (!sql) return ''; | ||
|
||
return sql.replace(/(\/\*[^*]*\*\/)|(\/\/[^*]*)|(--[^.].*)/gm, '').trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return sql.replace(/(\/\*[^*]*\*\/)|(\/\/[^*]*)|(--[^.].*)/gm, '').trim(); | |
// group 1 -> /* */ | |
// group 2 -> // | |
// group 3 -> -- | |
return sql.replace(/(\/\*[^*]*\*\/)|(\/\/[^*]*)|(--[^.].*)/gm, '').trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. I'll update the pr to support other styles too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there's a case with empty spaces where it's matching but it shouldn’t.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-s-molina just update to preserve the newlines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinpark The latest update broke //
comments. You can test the regex here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-s-molina that's intended.
As I mentioned above, //
comment visually not recognized as comment-out block so it doesn't sanitize the //
comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Thank you for the clarification.
@michael-s-molina could you help the review for updates? |
@justinpark I reviewed and left this comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This reverts commit a0bab8d.
…che#23378)"" This reverts commit 0ee676e.
This reverts commit d1947f7.
This reverts commit d1947f7.
This reverts commit d1947f7.
SUMMARY
sqllab threw an error for undefined parameters even when those parameters are commented out of/not used by the query.
This commit cleans out the commented out part from the requested query to fix the issue (and also reduce the payload size since commented-out parts are unnecessary)
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
After:
Before:
TESTING INSTRUCTIONS
Go to sqllab and then run a query including a template string within comment-out block like
select 123 --,{{ds}}
ADDITIONAL INFORMATION