You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kylin.apache.org by GitBox <gi...@apache.org> on 2018/06/20 02:57:00 UTC

[GitHub] shaofengshi closed pull request #135: KYLIN-3347 : calcite function QueryService Exception

shaofengshi closed pull request #135: KYLIN-3347 : calcite function QueryService Exception
URL: https://github.com/apache/kylin/pull/135
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/query/src/main/java/org/apache/kylin/query/util/DefaultQueryTransformer.java b/query/src/main/java/org/apache/kylin/query/util/DefaultQueryTransformer.java
index 671d9dbf35..f8ab8f24d6 100644
--- a/query/src/main/java/org/apache/kylin/query/util/DefaultQueryTransformer.java
+++ b/query/src/main/java/org/apache/kylin/query/util/DefaultQueryTransformer.java
@@ -43,7 +43,7 @@
     private static final Pattern PTN_INTERVAL = Pattern.compile(
             "interval" + SM + "(floor\\()([\\d\\.]+)(\\))" + SM + "(second|minute|hour|day|month|year)",
             Pattern.CASE_INSENSITIVE);
-    private static final Pattern PTN_HAVING_ESCAPE_FUNCTION = Pattern.compile("\\{fn" + SM + "(EXTRACT\\(.*?\\))" + "\\}",
+    private static final Pattern PTN_HAVING_ESCAPE_FUNCTION = Pattern.compile("\\{fn" + SM + "(EXTRACT\\(.*?\\)||CURRENT_TIMESTAMP\\(.*?\\))" + "\\}",
             Pattern.CASE_INSENSITIVE);
     private static final Pattern PIN_SUM_OF_CAST = Pattern.compile(S0 + "SUM" + S0 + "\\(" + S0 + "CAST" + S0 + "\\("
             + S0 + "([^\\s,]+)" + S0 + "AS" + SM + "DOUBLE" + S0 + "\\)" + S0 + "\\)", Pattern.CASE_INSENSITIVE);
@@ -137,7 +137,6 @@ public String transform(String sql, String project, String defaultSchema) {
             int value = (int) Math.floor(Double.valueOf(m.group(2)));
             sql = sql.substring(0, m.start(1)) + "'" + value + "'" + sql.substring(m.end(3));
         }
-
         
         return sql;
     }
diff --git a/query/src/test/java/org/apache/kylin/query/util/DefaultQueryTransformerTest.java b/query/src/test/java/org/apache/kylin/query/util/DefaultQueryTransformerTest.java
index 8ce10174e7..b6265b3795 100644
--- a/query/src/test/java/org/apache/kylin/query/util/DefaultQueryTransformerTest.java
+++ b/query/src/test/java/org/apache/kylin/query/util/DefaultQueryTransformerTest.java
@@ -100,5 +100,10 @@ public void functionEscapeTransform() throws Exception {
         String fnConvertSumSql = "select {fn EXTRACT(YEAR from PART_DT)} from KYLIN_SALES";
         String correctSql = transformer.transform(fnConvertSumSql, "", "");
         assertTrue("select EXTRACT(YEAR from PART_DT) from KYLIN_SALES".equalsIgnoreCase(correctSql));
+
+        fnConvertSumSql = "SELECT {fn CURRENT_TIMESTAMP(0)}";
+        correctSql = transformer.transform(fnConvertSumSql, "", "");
+        assertTrue("SELECT CURRENT_TIMESTAMP(0)".equalsIgnoreCase(correctSql));
+
     }
 }
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services