You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ku...@apache.org on 2021/03/23 12:30:14 UTC
[carbondata] branch master updated: [CARBONDATA-4155] Fix Create
table like table with MV
This is an automated email from the ASF dual-hosted git repository.
kunalkapoor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/carbondata.git
The following commit(s) were added to refs/heads/master by this push:
new 0f53bdb [CARBONDATA-4155] Fix Create table like table with MV
0f53bdb is described below
commit 0f53bdb0de7a501d6ee4bb07321599a05a0de1ee
Author: Indhumathi27 <in...@gmail.com>
AuthorDate: Mon Mar 22 20:42:35 2021 +0530
[CARBONDATA-4155] Fix Create table like table with MV
Why is this PR needed?
PR-4076 has added a new table property to fact table.
While executing create table like command, this property
is not excluded, which leads to parsing exception.
What changes were proposed in this PR?
Remove MV related info from destination table properties
This closes #4111
---
.../command/table/CarbonCreateTableLikeCommand.scala | 4 ++++
.../carbondata/view/rewrite/TestAllOperationsOnMV.scala | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonCreateTableLikeCommand.scala b/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonCreateTableLikeCommand.scala
index 926b951..8921601 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonCreateTableLikeCommand.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/table/CarbonCreateTableLikeCommand.scala
@@ -26,6 +26,7 @@ import org.apache.spark.sql.execution.command.MetadataCommand
import org.apache.carbondata.common.exceptions.sql.MalformedCarbonCommandException
import org.apache.carbondata.common.logging.LogServiceFactory
+import org.apache.carbondata.core.constants.CarbonCommonConstants
import org.apache.carbondata.core.metadata.schema.{SchemaEvolution, SchemaEvolutionEntry}
import org.apache.carbondata.core.metadata.schema.table.{TableInfo, TableSchema}
@@ -59,6 +60,9 @@ case class CarbonCreateTableLikeCommand(
dstTableSchema.setTableName(targetTable.table)
dstTableSchema.setTableId(UUID.randomUUID().toString)
+ // remove mv related info from source table tblProperties
+ dstTableSchema.getTableProperties.remove(CarbonCommonConstants.RELATED_MV_TABLES_MAP)
+
val schemaEvol: SchemaEvolution = new SchemaEvolution
val schEntryList: util.List[SchemaEvolutionEntry] = new util.ArrayList[SchemaEvolutionEntry]
schemaEvol.setSchemaEvolutionEntryList(schEntryList)
diff --git a/integration/spark/src/test/scala/org/apache/carbondata/view/rewrite/TestAllOperationsOnMV.scala b/integration/spark/src/test/scala/org/apache/carbondata/view/rewrite/TestAllOperationsOnMV.scala
index 167d628..251e460 100644
--- a/integration/spark/src/test/scala/org/apache/carbondata/view/rewrite/TestAllOperationsOnMV.scala
+++ b/integration/spark/src/test/scala/org/apache/carbondata/view/rewrite/TestAllOperationsOnMV.scala
@@ -708,6 +708,22 @@ class TestAllOperationsOnMV extends QueryTest with BeforeAndAfterEach {
}.getMessage.contains("Materialized view default.does_not_exist does not exist")
}
+ test("test create table like maintable having mv") {
+ sql("drop table IF EXISTS maintable")
+ sql("create table maintable(name string, c_code int, price int) STORED AS carbondata")
+ sql("drop materialized view if exists mv_table ")
+ sql("create materialized view mv_table as select name, sum(price) from maintable group by name")
+ sql("drop table if exists new_Table")
+ sql("create table new_Table like maintable")
+ sql("insert into table new_Table select 'abc',21,2000")
+ checkAnswer(sql("select * from new_Table"), Seq(Row("abc", 21, 2000)))
+ intercept[MalformedCarbonCommandException] {
+ sql("create table new_Table1 like mv_table")
+ }.getMessage.contains("Unsupported operation on SI table or MV.")
+ sql("drop table if exists new_Table")
+ sql("drop table IF EXISTS maintable")
+ }
+
test("drop meta cache on mv materialized view table") {
defaultConfig()
sql("drop table IF EXISTS maintable")