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? |
michael-s-molina
left a comment
There was a problem hiding this comment.
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.
| return sql.replace(/(\/\*[^*]*\*\/)|(\/\/[^*]*)|(--[^.].*)/gm, '').trim(); | |
| // group 1 -> /* */ | |
| // group 2 -> // | |
| // group 3 -> -- | |
| return sql.replace(/(\/\*[^*]*\*\/)|(\/\/[^*]*)|(--[^.].*)/gm, '').trim(); |
There was a problem hiding this comment.
good catch. I'll update the pr to support other styles too.
There was a problem hiding this comment.
It seems there's a case with empty spaces where it's matching but it shouldn’t.
There was a problem hiding this comment.
@michael-s-molina just update to preserve the newlines.
There was a problem hiding this comment.
@justinpark The latest update broke // comments. You can test the regex here.
There was a problem hiding this comment.
@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.
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. |
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