kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [01/26] kylin git commit: fix ci
Date Mon, 03 Jul 2017 07:44:12 GMT
Repository: kylin
Updated Branches:
  refs/heads/kylin-2.1.x [created] 82b578a56


fix ci


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

Branch: refs/heads/kylin-2.1.x
Commit: 2f7aa456640885dfde622966a6d487579a117931
Parents: 8603297
Author: Hongbin Ma <mahongbin@apache.org>
Authored: Thu Jun 29 12:34:03 2017 +0800
Committer: Hongbin Ma <ma@kyligence.io>
Committed: Thu Jun 29 13:51:45 2017 +0800

----------------------------------------------------------------------
 .../apache/kylin/rest/util/AdHocUtilTest.java   | 45 ++++++++++----------
 1 file changed, 22 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/2f7aa456/server-base/src/test/java/org/apache/kylin/rest/util/AdHocUtilTest.java
----------------------------------------------------------------------
diff --git a/server-base/src/test/java/org/apache/kylin/rest/util/AdHocUtilTest.java b/server-base/src/test/java/org/apache/kylin/rest/util/AdHocUtilTest.java
index b93e2d3..724844c 100644
--- a/server-base/src/test/java/org/apache/kylin/rest/util/AdHocUtilTest.java
+++ b/server-base/src/test/java/org/apache/kylin/rest/util/AdHocUtilTest.java
@@ -30,36 +30,28 @@ public class AdHocUtilTest {
     @Test
     public void testReplaceIdentifierInExpr() {
         {
-            String ret = AdHocUtil.replaceIdentifierInExpr("a.b.x * a.b.y", null, false);
-            Assert.assertEquals("b.x * b.y", ret);
+            String ret = AdHocUtil.replaceIdentifierInExpr("x * y", null, false);
+            Assert.assertEquals("x * y", ret);
         }
         {
-            String ret = AdHocUtil.replaceIdentifierInExpr("a_1.b_2.x_3 * a_1.b_2.y_3", null,
false);
+            String ret = AdHocUtil.replaceIdentifierInExpr("x_3 * y_3", "b_2", false);
             Assert.assertEquals("b_2.x_3 * b_2.y_3", ret);
         }
         {
-            String ret = AdHocUtil.replaceIdentifierInExpr("a.b.x * a.b.y", "c", false);
-            Assert.assertEquals("c.x * c.y", ret);
+            String ret = AdHocUtil.replaceIdentifierInExpr("substr(x,1,3)>y", "c", true);
+            Assert.assertEquals("substr(c.x,1,3)>c.y", ret);
         }
         {
-            String ret = AdHocUtil.replaceIdentifierInExpr("a.b.x * a.b.y", "c", true);
-            Assert.assertEquals("\"C\".\"X\" * \"C\".\"Y\"", ret);
+            String ret = AdHocUtil.replaceIdentifierInExpr("strcmp(substr(x,1,3),y)", "c",
true);
+            Assert.assertEquals("strcmp(substr(c.x,1,3),c.y)", ret);
         }
         {
-            String ret = AdHocUtil.replaceIdentifierInExpr("substr(a.b.x,1,3)>a.b.y",
"c", true);
-            Assert.assertEquals("substr(\"C\".\"X\",1,3)>\"C\".\"Y\"", ret);
+            String ret = AdHocUtil.replaceIdentifierInExpr("strcmp(substr(x,1,3),y)", null,
true);
+            Assert.assertEquals("strcmp(substr(x,1,3),y)", ret);
         }
         {
-            String ret = AdHocUtil.replaceIdentifierInExpr("strcmp(substr(a.b.x,1,3),a.b.y)
> 0", "c", true);
-            Assert.assertEquals("strcmp(substr(\"C\".\"X\",1,3),\"C\".\"Y\") > 0", ret);
-        }
-        {
-            String ret = AdHocUtil.replaceIdentifierInExpr("strcmp(substr(a.b.x,1,3),a.b.y)
> 0", null, true);
-            Assert.assertEquals("strcmp(substr(\"B\".\"X\",1,3),\"B\".\"Y\") > 0", ret);
-        }
-        {
-            String ret = AdHocUtil.replaceIdentifierInExpr("strcmp(substr(a.b.x, 1, 3),a.b.y)
> 0", null, false);
-            Assert.assertEquals("strcmp(substr(b.x, 1, 3),b.y) > 0", ret);
+            String ret = AdHocUtil.replaceIdentifierInExpr("strcmp(substr(x,1,3),y)", null,
false);
+            Assert.assertEquals("strcmp(substr(x,1,3),y)", ret);
         }
     }
 
@@ -68,7 +60,7 @@ public class AdHocUtilTest {
 
         ComputedColumnDesc computedColumnDesc = mock(ComputedColumnDesc.class);
         when(computedColumnDesc.getColumnName()).thenReturn("DEAL_AMOUNT");
-        when(computedColumnDesc.getExpression()).thenReturn("DB.TABLE.price * DB.TABLE.number");
+        when(computedColumnDesc.getExpression()).thenReturn("price * number");
 
         CCInfo ccInfo = mock(CCInfo.class);
         when(ccInfo.getComputedColumnDesc()).thenReturn(computedColumnDesc);
@@ -77,22 +69,29 @@ public class AdHocUtilTest {
             String ret = AdHocUtil.restoreComputedColumnToExpr(
                     "select DEAL_AMOUNT from DB.TABLE group by date order by DEAL_AMOUNT",
ccInfo);
             Assert.assertEquals(
-                    "select (TABLE.price * TABLE.number) from DB.TABLE group by date order
by (TABLE.price * TABLE.number)",
+                    "select (price * number) from DB.TABLE group by date order by (price
* number)",
                     ret);
         }
         {
             String ret = AdHocUtil.restoreComputedColumnToExpr(
                     "select DEAL_AMOUNT as DEAL_AMOUNT from DB.TABLE group by date order
by DEAL_AMOUNT", ccInfo);
             Assert.assertEquals(
-                    "select (TABLE.price * TABLE.number) as DEAL_AMOUNT from DB.TABLE group
by date order by (TABLE.price * TABLE.number)",
+                    "select (price * number) as DEAL_AMOUNT from DB.TABLE group by date order
by (price * number)",
                     ret);
         }
         {
             String ret = AdHocUtil.restoreComputedColumnToExpr(
                     "select \"DEAL_AMOUNT\" AS deal_amount from DB.TABLE group by date order
by DEAL_AMOUNT", ccInfo);
             Assert.assertEquals(
-                    "select (\"TABLE\".\"PRICE\" * \"TABLE\".\"NUMBER\") AS deal_amount from
DB.TABLE group by date order by (TABLE.price * TABLE.number)",
+                    "select (price * number) AS deal_amount from DB.TABLE group by date order
by (price * number)",
                     ret);
         }
+        {
+            String ret = AdHocUtil.restoreComputedColumnToExpr(
+                "select x.DEAL_AMOUNT AS deal_amount from DB.TABLE x group by date order
by x.DEAL_AMOUNT", ccInfo);
+            Assert.assertEquals(
+                "select (x.price * x.number) AS deal_amount from DB.TABLE x group by date
order by (x.price * x.number)",
+                ret);
+        }
     }
 }


Mime
View raw message