kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lid...@apache.org
Subject [3/3] kylin git commit: KYLIN-3135 revert first regex too
Date Mon, 12 Feb 2018 02:14:21 GMT
KYLIN-3135 revert first regex too

Signed-off-by: lidongsjtu <lidong@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/f1e9f188
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/f1e9f188
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/f1e9f188

Branch: refs/heads/master
Commit: f1e9f1882113df6bc053905a5f31e0346384f0cd
Parents: 24c489a
Author: hahayuan <yhh1234@126.com>
Authored: Sun Feb 11 12:38:55 2018 +0800
Committer: lidongsjtu <lidong@apache.org>
Committed: Mon Feb 12 09:57:13 2018 +0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/kylin/query/util/QueryUtil.java  | 2 +-
 .../test/java/org/apache/kylin/query/util/QueryUtilTest.java  | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/f1e9f188/query/src/main/java/org/apache/kylin/query/util/QueryUtil.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/util/QueryUtil.java b/query/src/main/java/org/apache/kylin/query/util/QueryUtil.java
index da18bd7..4de6a2c 100644
--- a/query/src/main/java/org/apache/kylin/query/util/QueryUtil.java
+++ b/query/src/main/java/org/apache/kylin/query/util/QueryUtil.java
@@ -142,7 +142,7 @@ public class QueryUtil {
 
     public static String removeCommentInSql(String sql1) {
         // match two patterns, one is "-- comment", the other is "/* comment */"
-        final String[] commentPatterns = new String[] { "--.*?[\r\n]", "/\\*.*?\\*/" };
+        final String[] commentPatterns = new String[] { "--[^\r\n]*", "/\\*[\\s\\S]*?\\*/"
};
 
         for (int i = 0; i < commentPatterns.length; i++) {
             sql1 = sql1.replaceAll(commentPatterns[i], "");

http://git-wip-us.apache.org/repos/asf/kylin/blob/f1e9f188/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java
----------------------------------------------------------------------
diff --git a/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java b/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java
index e3cd819..01c2f7f 100644
--- a/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java
+++ b/query/src/test/java/org/apache/kylin/query/util/QueryUtilTest.java
@@ -164,7 +164,12 @@ public class QueryUtilTest extends LocalFileMetadataTestCase {
         }
 
         {
-            String sqlWithComment = "/* comment1 * comment2 */ -- comment 5\n" + originSql
+ "/* comment3 / comment4 */";
+            String sqlWithComment = "/* comment1 * \ncomment2 */ -- comment 5\n" + originSql
+ "/* comment3 / comment4 */";
+            Assert.assertEquals(originSql, QueryUtil.removeCommentInSql(sqlWithComment));
+        }
+
+        {
+            String sqlWithComment = "/* comment1 * \ncomment2 */ -- comment 3\n" + originSql
+ "-- comment 5";
             Assert.assertEquals(originSql, QueryUtil.removeCommentInSql(sqlWithComment));
         }
     }


Mime
View raw message