[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3495: [CARBONDATA-3532] Support Query Rollup for MV TimeSeries Queries

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3495: [CARBONDATA-3532] Support Query Rollup for MV TimeSeries Queries

GitBox
Indhumathi27 commented on a change in pull request #3495: [CARBONDATA-3532] Support Query Rollup for MV TimeSeries Queries
URL: https://github.com/apache/carbondata/pull/3495#discussion_r373327070
 
 

 ##########
 File path: datamap/mv/core/src/test/scala/org/apache/carbondata/mv/timeseries/TestMVTimeSeriesQueryRollUp.scala
 ##########
 @@ -0,0 +1,259 @@
+  /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *    http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+
+  package org.apache.carbondata.mv.timeseries
+
+  import org.apache.spark.sql.test.util.QueryTest
+  import org.scalatest.BeforeAndAfterAll
+
+  import org.apache.carbondata.mv.rewrite.TestUtil
+
+  class TestMVTimeSeriesQueryRollUp extends QueryTest with BeforeAndAfterAll {
+
+    override def beforeAll(): Unit = {
+      drop()
+      createTable()
+      loadData("maintable")
+    }
+
+    override def afterAll(): Unit = {
+      drop()
+    }
+
+    test("test timeseries query rollup with simple projection") {
+      val result  = sql("select timeseries(projectjoindate,'day'),projectcode from maintable")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second'),projectcode from maintable")
+      sql(
+        "create datamap datamap2 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'hour'),projectcode from maintable")
+      val df = sql("select timeseries(projectjoindate,'day'),projectcode from maintable")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("test timeseries query rollup with simple projection with group by - scenario-1") {
+      val result  = sql("select timeseries(projectjoindate,'day'),projectcode from maintable group by timeseries(projectjoindate,'day'),projectcode")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second'),projectcode from maintable group by timeseries(projectjoindate,'second'),projectcode")
+      sql(
+        "create datamap datamap2 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'hour'),projectcode from maintable group by timeseries(projectjoindate,'hour'),projectcode")
+      val df = sql("select timeseries(projectjoindate,'day'),projectcode from maintable group by timeseries(projectjoindate,'day'),projectcode")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("test timeseries query rollup with simple projection with group by - scenario-2") {
+      val result  = sql("select timeseries(projectjoindate,'day'),sum(projectcode) from maintable group by timeseries(projectjoindate,'day')")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second'),sum(projectcode) from maintable group by timeseries(projectjoindate,'second')")
+      sql(
+        "create datamap datamap2 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'hour'),sum(projectcode) from maintable group by timeseries(projectjoindate,'hour')")
+      val df =sql("select timeseries(projectjoindate,'day'),sum(projectcode) from maintable group by timeseries(projectjoindate,'day')")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("test timeseries query rollup with simple projection with filter") {
+      val result  = sql("select timeseries(projectjoindate,'day'),projectcode from maintable where projectcode=8")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second'),projectcode from maintable")
+      sql(
+        "create datamap datamap2 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'hour'),projectcode from maintable")
+      val df = sql("select timeseries(projectjoindate,'day'),projectcode from maintable where projectcode=8")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("test timeseries query rollup with simple projection with group by & filter - scenario 1") {
+      val result = sql("select timeseries(projectjoindate,'day'),projectcode from maintable where projectcode=8 " +
+                       "group by timeseries(projectjoindate,'day'),projectcode")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql("create datamap datamap1 on table maintable using 'mv' as " +
+          "select timeseries(projectjoindate,'second'),projectcode from maintable group by " +
+          "timeseries(projectjoindate,'second'),projectcode")
+      sql("create datamap datamap2 on table maintable using 'mv' as " +
+          "select timeseries(projectjoindate,'hour'),projectcode from maintable group by timeseries" +
+          "(projectjoindate,'hour'),projectcode")
+      val df = sql("select timeseries(projectjoindate,'day'),projectcode from maintable where projectcode=8 " +
+                   "group by timeseries(projectjoindate,'day'),projectcode")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result, df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("test timeseries query rollup with simple projection with group by & filter - scenario 2") {
+      val result  = sql("select timeseries(projectjoindate,'day'),projectcode from maintable where projectcode=8 group by timeseries(projectjoindate,'day'),projectcode")
+      sql("drop datamap if exists datamap1")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second'),projectcode from maintable where projectcode=1 group by timeseries(projectjoindate,'second'),projectcode")
+      val df = sql("select timeseries(projectjoindate,'day'),projectcode from maintable where projectcode=8 group by timeseries(projectjoindate,'day'),projectcode")
+      assert(!TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap1"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+    }
+
+    test("test timeseries query rollup with simple projection with alias- scenario 1") {
+      val result  = sql("select timeseries(projectjoindate,'day') as a,projectcode as b from maintable")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second'),projectcode from maintable")
+      sql(
+        "create datamap datamap2 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'hour'),projectcode from maintable")
+      val df = sql("select timeseries(projectjoindate,'day') as a,projectcode as b from maintable")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("test timeseries query rollup with simple projection with alias- scenario 2") {
+      val result  = sql("select timeseries(projectjoindate,'day'),projectcode from maintable")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second') as a,projectcode as b from maintable")
+      sql(
+        "create datamap datamap2 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'hour') as a,projectcode as b from maintable")
+      val df = sql("select timeseries(projectjoindate,'day'),projectcode from maintable")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("test timeseries query rollup with projection with alias and group by- scenario 1") {
+      val result  = sql("select timeseries(projectjoindate,'day') as a,sum(projectcode) as b from maintable group by timeseries(projectjoindate,'day')")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second'),sum(projectcode) from maintable group by timeseries(projectjoindate,'second')")
+      sql(
+        "create datamap datamap2 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'hour'),sum(projectcode) from maintable group by timeseries(projectjoindate,'hour')")
+      val df = sql("select timeseries(projectjoindate,'day') as a,sum(projectcode) as b from maintable group by timeseries(projectjoindate,'day')")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("test timeseries query rollup with projection with alias and group by- scenario 2") {
+      val result  = sql("select timeseries(projectjoindate,'day'),sum(projectcode) from maintable group by timeseries(projectjoindate,'day')")
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+      sql(
+        "create datamap datamap1 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'second') as a,sum(projectcode) as b from maintable group by timeseries(projectjoindate,'second')")
+      sql(
+        "create datamap datamap2 on table maintable using 'mv' as " +
+        "select timeseries(projectjoindate,'hour') as a,sum(projectcode) as b from maintable group by timeseries(projectjoindate,'hour')")
+      val df = sql("select timeseries(projectjoindate,'day'),sum(projectcode) from maintable group by timeseries(projectjoindate,'day')")
+      assert(TestUtil.verifyMVDataMap(df.queryExecution.optimizedPlan, "datamap2"))
+      checkAnswer(result,df)
+      sql("drop datamap if exists datamap1")
+      sql("drop datamap if exists datamap2")
+    }
+
+    test("rollup not supported for join queries") {
 
 Review comment:
   For Join queries and queries with OrderBy, rollUp is currently not supported. Can be supported in future PR

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


With regards,
Apache Git Services