hit-lacus commented on a change in pull request #1606:
URL: https://github.com/apache/kylin/pull/1606#discussion_r592041040
##########
File path: query/src/main/java/org/apache/kylin/query/util/QueryUtil.java
##########
@@ -219,17 +218,16 @@ public static boolean isSelectStatement(String sql) {
|| (sql1.startsWith(KEYWORD_EXPLAIN) &&
sql1.contains(KEYWORD_SELECT));
}
- public static String removeCommentInSql(String sql1) {
- // match two patterns, one is "-- comment", the other is "/* comment
*/"
- final String[] commentPatterns = new String[] {
"--(?!.*\\*/).*?[\r\n]", "/\\*(.|\r|\n)*?\\*/" };
- for (int i = 0; i < commentPatterns.length; i++) {
- sql1 = sql1.replaceAll(commentPatterns[i], "");
+ public static String removeCommentInSql(String sql) {
+ // match two patterns, one is "-- comment", the other is "/* comment
*/"
+ try {
+ return new CommentParser(sql).Input().trim();
+ } catch (ParseException e) {
+ e.printStackTrace();
Review comment:
Use log4j to print error stack trace.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]