[ZEPPELIN-4877]. text between 2 sql comment is mistaken as comment#3796
Closed
zjffdu wants to merge 3 commits intoapache:masterfrom
Closed
[ZEPPELIN-4877]. text between 2 sql comment is mistaken as comment#3796zjffdu wants to merge 3 commits intoapache:masterfrom
zjffdu wants to merge 3 commits intoapache:masterfrom
Conversation
alexott
reviewed
Jun 14, 2020
|
|
||
| // end of multiple line comment | ||
| if (multiLineComment && character == '/' && text.charAt(index - 1) == '*') { | ||
| if (multiLineComment && (index - 1) >= 0 && text.charAt(index - 1) == '/' |
Contributor
There was a problem hiding this comment.
Can we replace (index - 1) >= 0 with (index - 2) >= 0 and just skip it later?
Contributor
Author
There was a problem hiding this comment.
Sorry, I don't get it. Here I just check whether it is the end of multiple comment via checking whether (index-1) is / and (index-2) is *
| singleLineComment = true; | ||
| } else if (text.charAt(index) == '/' && text.charAt(index + 1) == '*') { | ||
| } else if (text.charAt(index) == '/' && text.charAt(index + 1) == '*' | ||
| && text.length() > (index + 2) && text.charAt(index + 2) != '+') { |
Contributor
There was a problem hiding this comment.
I would move text.length() > (index + 2) before text.charAt(index + 1) == '*'
Contributor
There was a problem hiding this comment.
sorry, I meant that we can write it as:
text.charAt(index) == '/' && text.length() > (index + 2)
&& text.charAt(index + 1) == '*' && text.charAt(index + 2) != '+'
so we have range check for index+1 covered, just in case if index == lenght-1...
Contributor
Author
There was a problem hiding this comment.
I see, now it is fixed
asfgit
pushed a commit
that referenced
this pull request
Jun 17, 2020
### What is this PR for? This PR fix the bug in Splitter that text between 2 sql comment is mistaken as comment. Unit test is added in this PR as well. Besides that, this PR also remove the comment in the middle of sql. e.g. ``` select a -- comment 1 from table_1 ``` will be converted to ``` select a from table_1 ``` ### What type of PR is it? [Bug Fix] ### Todos * [ ] - Task ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-4877 ### How should this be tested? * CI pass ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jeff Zhang <zjffdu@apache.org> Closes #3796 from zjffdu/ZEPPELIN-4877 and squashes the following commits: 0b0b728 [Jeff Zhang] address comment 6e9287e [Jeff Zhang] address comment 63afd6a [Jeff Zhang] [ZEPPELIN-4877]. text between 2 sql comment is mistaken as comment (cherry picked from commit badcaa0) Signed-off-by: Jeff Zhang <zjffdu@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
This PR fix the bug in Splitter that text between 2 sql comment is mistaken as comment. Unit test is added in this PR as well. Besides that, this PR also remove the comment in the middle of sql. e.g.
will be converted to
What type of PR is it?
[Bug Fix]
Todos
What is the Jira issue?
How should this be tested?
Screenshots (if appropriate)
Questions: