Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1981#discussion_r175446224
--- Diff:
integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/PreAggregateTestCase.scala
---
@@ -0,0 +1,312 @@
+
+/*
+ * 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.cluster.sdv.generated
+
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.common.util.{Include, QueryTest}
+import org.junit.Assert
+import org.scalatest.BeforeAndAfterEach
+import org.scalatest.Matchers._
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+
+
+class PreAggregateTestCase extends QueryTest with BeforeAndAfterEach {
+ val csvPath = s"$resourcesPath/source.csv"
+
+ override def beforeEach: Unit = {
+ sql("drop table if exists PreAggMain")
+ sql("drop table if exists AggMain")
+ CarbonProperties.getInstance()
+ .addProperty(CarbonCommonConstants.CARBON_DATE_FORMAT, "yyyy/MM/dd")
+ sql("CREATE TABLE PreAggMain (id Int, date date, country string,
phonetype string, " +
+ "serialname String,salary int ) STORED BY
'org.apache.carbondata.format' " +
+ "tblproperties('dictionary_include'='country')")
+ sql("CREATE TABLE AggMain (id Int, date date, country string,
phonetype string, " +
+ "serialname String,salary int ) STORED BY
'org.apache.carbondata.format'" +
+ "tblproperties('dictionary_include'='country')")
+ sql("create datamap PreAggSum on table PreAggMain using 'preaggregate'
as " +
+ "select country,sum(salary) as sum from PreAggMain group by
country")
+ sql("create datamap PreAggAvg on table PreAggMain using 'preaggregate'
as " +
+ "select country,avg(salary) as avg from PreAggMain group by
country")
+ sql("create datamap PreAggCount on table PreAggMain using
'preaggregate' as " +
+ "select country,count(salary) as count from PreAggMain group by
country")
+ sql("create datamap PreAggMin on table PreAggMain using 'preaggregate'
as " +
+ "select country,min(salary) as min from PreAggMain group by
country")
+ sql("create datamap PreAggMax on table PreAggMain using 'preaggregate'
as " +
+ "select country,max(salary) as max from PreAggMain group by
country")
+ }
+
+ //test to check the table and datamap creation
+ test("PreAggregateTestCase_TC001", Include) {
+ checkExistence(sql("Describe formatted PreAggMain"), true)
+ Assert.assertEquals(sql("show datamap on table PreAggMain").count(), 5)
+ }
+
+ //test to check preaggregate table with dictionary
+ test("PreAggregateTestCase_TC002", Include) {
+ checkExistence(sql("Describe formatted PreAggMain_PreAggSum"), true,
"DICTIONARY")
+ }
+
+ //test for exception in datamap having wrong column in group by
+ test("PreAggregateTestCase_TC003", Include) {
+ intercept[Exception] {
+ sql("create datamap testDatamap on table PreAggMain using
'preaggregate' as " +
+ "select name,sum(salary) as sum from PreAggMain group by
country")
+ }
+ }
+ // test for the exception in datamap having nested aggregate
+ test("PreAggregateTestCase_TC004", Include) {
+ intercept[Exception] {
+ sql("create testDatamap PreAggSum on table PreAggMain using
'preaggregate' as " +
+ "select country,sum(distinct(salary)) as sum from PreAggMain
group by country")
+ }
+ }
+
+ // test for the exception in datamap having nested aggregate
+ test("PreAggregateTestCase_TC005", Include) {
--- End diff --
no need for this scenario. Already covered in PreAggregateTestCase_TC004
---