niuge01 commented on a change in pull request #3661: [CARBONDATA-3704] Support
create materialized view on all type table, and make mv support mutil-tenant.
URL: https://github.com/apache/carbondata/pull/3661#discussion_r400681680
##########
File path:
integration/spark/src/test/scala/org/apache/carbondata/view/MaterializedViewTest.scala
##########
@@ -0,0 +1,194 @@
+package org.apache.carbondata.view
+
+import java.io.File
+
+import org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException
+import org.apache.spark.sql.catalyst.catalog.HiveTableRelation
+import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
+import org.apache.spark.sql.execution.datasources.LogicalRelation
+import org.apache.spark.sql.test.util.QueryTest
+import org.scalatest.BeforeAndAfterAll
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.carbondata.spark.exception.ProcessMetaDataException
+
+class MaterializedViewTest extends QueryTest with BeforeAndAfterAll {
+
+ override def beforeAll {
+ drop()
+ CarbonProperties.getInstance()
+ .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, "yyyy/MM/dd")
+ val projectPath = new File(this.getClass.getResource("/").getPath +
"../../../../")
+ .getCanonicalPath.replaceAll("\\\\", "/")
+ val integrationPath = s"$projectPath/integration"
+ val resourcesPath = s"$integrationPath/spark/src/test/resources"
+ sql(
+ """
+ | CREATE TABLE fact_table (empname String, designation String, doj
Timestamp,
+ | workgroupcategory int, workgroupcategoryname String, deptno int,
deptname String,
+ | projectcode int, projectjoindate Timestamp, projectenddate
Timestamp,attendance int,
+ | utilization int,salary int)
+ | STORED AS carbondata
+ """.stripMargin)
+ sql(s"""LOAD DATA local inpath '$resourcesPath/data_big.csv' INTO TABLE
fact_table OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""")
+ sql(s"""LOAD DATA local inpath '$resourcesPath/data_big.csv' INTO TABLE
fact_table OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""")
+ }
+
+ test("test create mv on hive table") {
+ sql("drop materialized view if exists mv1")
+ sql("drop table if exists source")
+ sql("create table source as select * from fact_table")
+ sql("create materialized view mv1 as select empname, deptname, avg(salary)
from source group by empname, deptname")
Review comment:
Currently, all mv tables which created by CREATE MATERIALIZED VIEW
statement is carbon mv table.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services