You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by sraghunandan <gi...@git.apache.org> on 2018/02/09 01:44:01 UTC

[GitHub] carbondata pull request #1856: [CARBONDATA-2073][CARBONDATA-1516][Tests] Add...

Github user sraghunandan commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1856#discussion_r167120975
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesDropSuite.scala ---
    @@ -36,16 +48,168 @@ class TestTimeSeriesDropSuite extends QueryTest with BeforeAndAfterAll with Befo
           """.stripMargin)
       }
     
    -  test("test timeseries drop datamap 1: drop datamap should throw exception if no datamap") {
    +  override def afterEach(): Unit = {
    +    dropDataMaps("mainTable", "agg1_second", "agg1_minute",
    +      "agg1_hour", "agg1_day", "agg1_month", "agg1_year")
    +  }
    +
    +  test("test timeseries drop datamap 1: drop datamap should throw exception") {
         // DROP DATAMAP DataMapName if the DataMapName not exists
         checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), false, "agg1_month")
         val e: Exception = intercept[Exception] {
           sql(s"DROP DATAMAP agg1_month ON TABLE mainTable")
         }
    -    assert(e.getMessage.equals("Datamap with name agg1_month does not exist under table mainTable"))
    +    assert(e.getMessage.contains(
    +      "Datamap with name agg1_month does not exist under table mainTable"))
    +  }
    +
    +  test("test timeseries drop datamap 2: should support drop datamap IF EXISTS") {
    +    // DROP DATAMAP IF EXISTS DataMapName
    +    checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), false, "agg1_month")
    +    sql(s"DROP DATAMAP IF EXISTS agg1_month ON TABLE mainTable")
    +    assert(true)
    +  }
    +
    +  test("test timeseries drop datamap 3: should support drop datamap") {
    +    sql(
    +      s"""
    +         | 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")
    +
    +    // DROP DATAMAP DataMapName
    +    sql(s"DROP DATAMAP agg1_month ON TABLE mainTable")
    +    checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), false, "agg1_month")
    +    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"))
    +  }
    +
    +  test("test timeseries drop datamap 4: should support drop datamap with IF EXISTS") {
    +    sql(
    +      s"""
    +         | 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)
    +    // DROP DATAMAP IF EXISTS DataMapName
    +    sql(s"DROP DATAMAP IF EXISTS agg1_year ON TABLE mainTable")
    +    checkExistence(sql("SHOW DATAMAP ON TABLE maintable"), false, "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")
    +    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"))
    +  }
    +
    +  test("test timeseries drop datamap 5: drop datamap when table not exists") {
    --- End diff --
    
    Modify the existing test case to catch MalformedCarbonCommandException


---