carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject [06/17] carbondata git commit: [CARBONDATA-2075][CARBONDATA-1516] Fix test error with new creating timeseries pre-aggregate table syntax
Date Wed, 31 Jan 2018 11:32:40 GMT
[CARBONDATA-2075][CARBONDATA-1516] Fix test error with new creating timeseries pre-aggregate
table syntax

This closes #1890


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

Branch: refs/heads/carbonstore
Commit: 15fabf9ab6596e6f14c7d61065a19bbf2ae9af3f
Parents: 033870d
Author: xubo245 <601450868@qq.com>
Authored: Wed Jan 31 10:49:08 2018 +0800
Committer: Jacky Li <jacky.likun@qq.com>
Committed: Wed Jan 31 19:07:31 2018 +0800

----------------------------------------------------------------------
 .../preaggregate/TestPreAggCreateCommand.scala  |  8 ++--
 .../timeseries/TestTimeSeriesDropSuite.scala    | 42 ++++++++++----------
 .../testsuite/datamap/TestDataMapCommand.scala  | 28 ++++++++++---
 3 files changed, 47 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/15fabf9a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
index d3f0ff8..303abf4 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/preaggregate/TestPreAggCreateCommand.scala
@@ -217,7 +217,7 @@ class TestPreAggCreateCommand extends QueryTest with BeforeAndAfterAll
{
 
   val timeSeries = TIMESERIES.toString
 
-  test("test PreAggregate table selection: create with preaggregate and hierarchy") {
+  test("test pre agg  create table 21: create with preaggregate and hierarchy") {
     sql("DROP TABLE IF EXISTS maintabletime")
     sql(
       """
@@ -252,8 +252,8 @@ class TestPreAggCreateCommand extends QueryTest with BeforeAndAfterAll
{
     sql("DROP TABLE IF EXISTS maintabletime")
   }
 
-  test("test pre agg create table 21: using") {
-    sql("DROP DATAMAP agg0 ON TABLE maintable")
+  test("test pre agg create table 22: using invalid datamap provider") {
+    sql("DROP DATAMAP IF EXISTS agg0 ON TABLE maintable")
 
     val e: Exception = intercept[Exception] {
       sql(
@@ -267,7 +267,7 @@ class TestPreAggCreateCommand extends QueryTest with BeforeAndAfterAll
{
     }
     assert(e.getMessage.contains(
       s"Unknown data map type abc"))
-    sql("DROP DATAMAP agg0 ON TABLE maintable")
+    sql("DROP DATAMAP IF EXISTS agg0 ON TABLE maintable")
   }
 
   def getCarbontable(plan: LogicalPlan) : CarbonTable ={

http://git-wip-us.apache.org/repos/asf/carbondata/blob/15fabf9a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesDropSuite.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesDropSuite.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesDropSuite.scala
index f6d41fb..545c4de 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesDropSuite.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesDropSuite.scala
@@ -28,10 +28,10 @@ class TestTimeSeriesDropSuite extends QueryTest with BeforeAndAfterAll
with Befo
     sql(
       """
         | CREATE TABLE mainTable(
-        |   dataTime timestamp,
-        |   name string,
-        |   city string,
-        |   age int)
+        |   dataTime TIMESTAMP,
+        |   name STRING,
+        |   city STRING,
+        |   age INT)
         | STORED BY 'org.apache.carbondata.format'
       """.stripMargin)
   }
@@ -42,46 +42,46 @@ class TestTimeSeriesDropSuite extends QueryTest with BeforeAndAfterAll
with Befo
     val e: Exception = intercept[Exception] {
       sql(s"DROP DATAMAP agg1_month ON TABLE mainTable")
     }
-    assert(e.getMessage.contains("Datamap with name agg1_month does not exist under table
mainTable"))
+    assert(e.getMessage.equals("Datamap with name agg1_month does not exist under table mainTable"))
   }
 
-  test("test timeseries drop datamap 2: drop datamap should SUCCESS if haveIF EXISTS") {
+  test("test timeseries drop datamap 2: drop datamap should SUCCESS if have IF EXISTS") {
     // DROP DATAMAP DataMapName if the DataMapName not exists
-    checkExistence(sql("show datamap on table mainTable"), false, "agg1_month")
+    checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), false, "agg1_month")
     try {
       sql(s"DROP DATAMAP IF EXISTS agg1_month ON TABLE mainTable")
       assert(true)
     } catch {
-      case e: Exception =>
-        println(e)
+      case _: Exception =>
         assert(false)
     }
   }
 
   test("test timeseries drop datamap 3: drop datamap should throw proper exception") {
     sql(
-      """create datamap agg1 on table mainTable
-        |using 'preaggregate'
-        |DMPROPERTIES (
-        |   'timeseries.eventTime'='dataTime',
-        |   'timeseries.hierarchy'='month=1,year=1')
-        |as select dataTime, sum(age) from mainTable
-        |group by dataTime
+      """
+        | CREATE DATAMAP agg1_month ON TABLE mainTable
+        | USING 'timeseries'
+        | DMPROPERTIES (
+        |   'event_Time'='dataTime',
+        |   'month_granularity'='1')
+        | AS SELECT dataTime, SUM(age) FROM mainTable
+        | GROUP BY dataTime
       """.stripMargin)
 
     // Before DROP DATAMAP
-    checkExistence(sql("show datamap on table mainTable"), true, "agg1_month", "agg1_year")
+    checkExistence(sql("show datamap on table mainTable"), true, "agg1_month")
 
     // DROP DATAMAP DataMapName
     sql(s"DROP DATAMAP agg1_month ON TABLE mainTable")
-    checkExistence(sql("show datamap on table mainTable"), false, "agg1_month")
+    checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), false, "agg1_month")
     val e: Exception = intercept[MalformedCarbonCommandException] {
       sql(s"DROP DATAMAP agg1_month ON TABLE mainTable")
     }
-    assert(e.getMessage.contains("Datamap with name agg1_month does not exist under table
mainTable"))
+    assert(e.getMessage.equals("Datamap with name agg1_month does not exist under table mainTable"))
   }
 
-  test("test timeseries drop datamap: drop datamap should throw exception if table not exist")
{
+  test("test timeseries drop datamap 4: drop datamap should throw exception if table not
exist") {
     // DROP DATAMAP DataMapName if the DataMapName not exists and
     checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), false, "agg1_month")
     val e: Exception = intercept[Exception] {
@@ -91,7 +91,7 @@ class TestTimeSeriesDropSuite extends QueryTest with BeforeAndAfterAll with
Befo
       "Dropping datamap agg1_month failed: Table or view 'maintablenotexist' not found "))
   }
 
-  test("test timeseries drop datamap: should throw exception if table not exist with IF EXISTS")
{
+  test("test timeseries drop datamap 5: should throw exception if table not exist with IF
EXISTS") {
     // DROP DATAMAP DataMapName if the DataMapName not exists
     // DROP DATAMAP should throw exception if table not exist, even though there is IF EXISTS"
     checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), false, "agg1_month")

http://git-wip-us.apache.org/repos/asf/carbondata/blob/15fabf9a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/datamap/TestDataMapCommand.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/datamap/TestDataMapCommand.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/datamap/TestDataMapCommand.scala
index 0860da1..146ad62 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/datamap/TestDataMapCommand.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/datamap/TestDataMapCommand.scala
@@ -244,14 +244,30 @@ class TestDataMapCommand extends QueryTest with BeforeAndAfterAll {
   test("create pre-agg table with path") {
     sql("drop table if exists main_preagg")
     sql("drop table if exists main ")
-    val path = "./_pre-agg_test"
-    sql("create table main(year int,month int,name string,salary int) stored by 'carbondata'
tblproperties('sort_columns'='month,year,name')")
+    val warehouse = s"$metastoredb/warehouse"
+    val path = warehouse + "/" + System.nanoTime + "_preAggTestPath"
+    sql(
+      s"""
+         | create table main(
+         |     year int,
+         |     month int,
+         |     name string,
+         |     salary int)
+         | stored by 'carbondata'
+         | tblproperties('sort_columns'='month,year,name')
+      """.stripMargin)
     sql("insert into main select 10,11,'amy',12")
     sql("insert into main select 10,11,'amy',14")
-    sql("create datamap preagg on table main " +
-      "using 'preaggregate' " +
-      s"dmproperties ('path'='$path') " +
-      "as select name,avg(salary) from main group by name")
+    sql(
+      s"""
+         | create datamap preagg
+         | on table main
+         | using 'preaggregate'
+         | dmproperties ('path'='$path')
+         | as select name,avg(salary)
+         |    from main
+         |    group by name
+       """.stripMargin)
     assertResult(true)(new File(path).exists())
     assertResult(true)(new File(s"${CarbonTablePath.getSegmentPath(path, "0")}")
       .list(new FilenameFilter {


Mime
View raw message