[jira] [Comment Edited] (KYLIN-3135) Fix regular expression bug in SQL comments

2018-02-10 Thread peng.jianhua (JIRA)

[ 
https://issues.apache.org/jira/browse/KYLIN-3135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16359776#comment-16359776
 ] 

peng.jianhua edited comment on KYLIN-3135 at 2/11/18 4:43 AM:
--

Please revert the first 
{code:java}
--.*?[\r\n]
{code}
too.
if the comments like '--comments' at the end of sql,and don't have '\n',
the 
{code:java}
--.*?[\r\n]
{code}
will be wrong.
please refer to the last test case in 
0001-kylin-3135-revert-first-regex-too.patch


was (Author: peng.jianhua):
Please revert the first 
{code:java}
--.*?[\r\n]
{code}
too.
if the comments like '--comments' at the end of sql,and don't have '\n',
the 
{code:java}
--.*?[\r\n]
{code}
will be wrong.

> Fix regular expression bug in SQL comments
> --
>
> Key: KYLIN-3135
> URL: https://issues.apache.org/jira/browse/KYLIN-3135
> Project: Kylin
>  Issue Type: Bug
>Reporter: hahayuan
>Assignee: hahayuan
>Priority: Major
> Fix For: v2.3.0
>
> Attachments: 0001-KYLIN-3135.patch, 
> 0001-kylin-3135-revert-first-regex-too.patch, 
> 0002-KYLIN-3135-fix-regEx.patch, multi_line_comments.PNG, 
> one_line_comments.PNG
>
>
> Hi,all.
> Recently,I was testing query function of kylin,
> sometimes I just comment with /**/ instead of delete the sql,cause I need to 
> query and compare again.
> And I was confused that the results says it was "No Support Sql",but it can 
> query success without comments.
> For example,
> {code:java}
> /*
> select count(*) from kylin_sales;
> */
> select * from kylin_sales;
> {code}
> So I view the code and find the commentPatterns of  /\**/  was 
> {code:java}
> /\\*[^\\*/]*
> {code}
> ,clearly it was wrong.
> The regular expression of [abc] means any character in abc,such as a or b.
> So the [^\\*/] means that * or / can't appear,
> But under this circumstances the */ need to be as a string not separated 
> character.
> the */ can't appear not * or / can't appear.
> I rewrite the regular expression,
> {code:java}
> /\\*[\\s\\S]*?\\*/
> {code}
> if you think it's necessary to change the old code,please review and replace 
> it.
> Thank for you time.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Comment Edited] (KYLIN-3135) Fix regular expression bug in SQL comments

2018-01-30 Thread Kaige Liu (JIRA)

[ 
https://issues.apache.org/jira/browse/KYLIN-3135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16346156#comment-16346156
 ] 

 Kaige Liu edited comment on KYLIN-3135 at 1/31/18 2:34 AM:


Hi [~hahayuan], you are right. The commit is not correct according to 
[https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#predef]
||Predefined character classes||
|{{.}}|Any character (may or may not match [line 
terminators|https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#lt])|
|{{\s}}|A whitespace character: {{[ \t\n\x0B\f\r]}}|
|{{\S}}|A non-whitespace character: {{[^\s]}}|

 

So *"/\\*.*?*/"* won't match multiple lines comment.


was (Author: liukaige):
Hi [~hahayuan], you are right. The commit is not correct according to 
[https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#predef]
||Predefined character classes||
|{{.}}|Any character (may or may not match [line 
terminators|https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#lt])|
|{{\s}}|A whitespace character: {{[ \t\n\x0B\f\r]}}|
|{{\S}}|A non-whitespace character: {{[^\s]}}|

 

So "/\\*.*?\\*/" won't match multiple lines comment.

> Fix regular expression bug in SQL comments
> --
>
> Key: KYLIN-3135
> URL: https://issues.apache.org/jira/browse/KYLIN-3135
> Project: Kylin
>  Issue Type: Bug
>Reporter: hahayuan
>Assignee: hahayuan
>Priority: Major
> Fix For: v2.3.0
>
> Attachments: 0001-KYLIN-3135.patch, multi_line_comments.PNG, 
> one_line_comments.PNG
>
>
> Hi,all.
> Recently,I was testing query function of kylin,
> sometimes I just comment with /**/ instead of delete the sql,cause I need to 
> query and compare again.
> And I was confused that the results says it was "No Support Sql",but it can 
> query success without comments.
> For example,
> {code:java}
> /*
> select count(*) from kylin_sales;
> */
> select * from kylin_sales;
> {code}
> So I view the code and find the commentPatterns of  /\**/  was 
> {code:java}
> /\\*[^\\*/]*
> {code}
> ,clearly it was wrong.
> The regular expression of [abc] means any character in abc,such as a or b.
> So the [^\\*/] means that * or / can't appear,
> But under this circumstances the */ need to be as a string not separated 
> character.
> the */ can't appear not * or / can't appear.
> I rewrite the regular expression,
> {code:java}
> /\\*[\\s\\S]*?\\*/
> {code}
> if you think it's necessary to change the old code,please review and replace 
> it.
> Thank for you time.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Comment Edited] (KYLIN-3135) Fix regular expression bug in SQL comments

2018-01-30 Thread hahayuan (JIRA)

[ 
https://issues.apache.org/jira/browse/KYLIN-3135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16346092#comment-16346092
 ] 

hahayuan edited comment on KYLIN-3135 at 1/31/18 1:30 AM:
--

[~yimingliu],this commit : 
[https://github.com/apache/kylin/commit/7d5fb855064e2b81cd3b154cdeeafec4e64f63c9]

was wrong.

please refer the picture above.

And one more 
{code:java}
sql1 = sql1.replaceAll(commentPatterns[i], "");{code}
 

is improper.

I'll add the test case later.


was (Author: hahayuan):
[~yimingliu],this commit : 
[https://github.com/apache/kylin/commit/7d5fb855064e2b81cd3b154cdeeafec4e64f63c9]

was wrong.

please refer the picture above.

> Fix regular expression bug in SQL comments
> --
>
> Key: KYLIN-3135
> URL: https://issues.apache.org/jira/browse/KYLIN-3135
> Project: Kylin
>  Issue Type: Bug
>Reporter: hahayuan
>Assignee: hahayuan
>Priority: Major
> Fix For: v2.3.0
>
> Attachments: 0001-KYLIN-3135.patch, multi_line_comments.PNG
>
>
> Hi,all.
> Recently,I was testing query function of kylin,
> sometimes I just comment with /**/ instead of delete the sql,cause I need to 
> query and compare again.
> And I was confused that the results says it was "No Support Sql",but it can 
> query success without comments.
> For example,
> {code:java}
> /*
> select count(*) from kylin_sales;
> */
> select * from kylin_sales;
> {code}
> So I view the code and find the commentPatterns of  /\**/  was 
> {code:java}
> /\\*[^\\*/]*
> {code}
> ,clearly it was wrong.
> The regular expression of [abc] means any character in abc,such as a or b.
> So the [^\\*/] means that * or / can't appear,
> But under this circumstances the */ need to be as a string not separated 
> character.
> the */ can't appear not * or / can't appear.
> I rewrite the regular expression,
> {code:java}
> /\\*[\\s\\S]*?\\*/
> {code}
> if you think it's necessary to change the old code,please review and replace 
> it.
> Thank for you time.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)