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 5a9d1e2 [CARBONDATA-3398]Block show/drop metacache directly on child
table
5a9d1e2 is described below
commit 5a9d1e2e6997c60f21a09d001fd76150474f4ff0
Author: Indhumathi27 <[email protected]>
AuthorDate: Fri Jun 21 09:14:58 2019 +0530
[CARBONDATA-3398]Block show/drop metacache directly on child table
Problem:
show/drop metacache directly on mv child table is not blocked
Solution:
Blocked show/drop metacache directly on mv child table
This closes #3302
---
.../carbondata/mv/rewrite/TestAllOperationsOnMV.scala | 15 +++++++++++++++
.../execution/command/cache/DropCacheEventListeners.scala | 2 +-
.../execution/command/cache/ShowCacheEventListeners.scala | 2 +-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git
a/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/TestAllOperationsOnMV.scala
b/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/TestAllOperationsOnMV.scala
index d7fc2b3..c74bb94 100644
---
a/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/TestAllOperationsOnMV.scala
+++
b/datamap/mv/core/src/test/scala/org/apache/carbondata/mv/rewrite/TestAllOperationsOnMV.scala
@@ -520,5 +520,20 @@ class TestAllOperationsOnMV extends QueryTest with
BeforeAndAfterEach {
sql("drop table IF EXISTS maintable")
}
+ test("test drop/show meta cache directly on mv datamap table") {
+ sql("drop table IF EXISTS maintable")
+ sql("create table maintable(name string, c_code int, price int) stored by
'carbondata'")
+ sql("insert into table maintable select 'abc',21,2000")
+ sql("drop datamap if exists dm ")
+ sql("create datamap dm using 'mv' as select name, sum(price) from
maintable group by name")
+ sql("select name, sum(price) from maintable group by name").collect()
+ intercept[UnsupportedOperationException] {
+ sql("show metacache on table dm_table").show(false)
+ }.getMessage.contains("Operation not allowed on child table.")
+ intercept[UnsupportedOperationException] {
+ sql("drop metacache on table dm_table").show(false)
+ }.getMessage.contains("Operation not allowed on child table.")
+ }
+
}
diff --git
a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/DropCacheEventListeners.scala
b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/DropCacheEventListeners.scala
index 6c8bb54..61d546e 100644
---
a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/DropCacheEventListeners.scala
+++
b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/DropCacheEventListeners.scala
@@ -49,7 +49,7 @@ object DropCachePreAggEventListener extends
OperationEventListener {
val carbonTable = dropCacheEvent.carbonTable
val sparkSession = dropCacheEvent.sparkSession
val internalCall = dropCacheEvent.internalCall
- if (carbonTable.isChildDataMap && !internalCall) {
+ if ((carbonTable.isChildDataMap || carbonTable.isChildTable) &&
!internalCall) {
throw new UnsupportedOperationException("Operation not allowed on
child table.")
}
diff --git
a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/ShowCacheEventListeners.scala
b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/ShowCacheEventListeners.scala
index 70f63a4..3eab81a 100644
---
a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/ShowCacheEventListeners.scala
+++
b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/cache/ShowCacheEventListeners.scala
@@ -52,7 +52,7 @@ object ShowCachePreAggEventListener extends
OperationEventListener {
val carbonTable = showTableCacheEvent.carbonTable
val sparkSession = showTableCacheEvent.sparkSession
val internalCall = showTableCacheEvent.internalCall
- if (carbonTable.isChildDataMap && !internalCall) {
+ if ((carbonTable.isChildDataMap || carbonTable.isChildTable) &&
!internalCall) {
throw new UnsupportedOperationException("Operation not allowed on
child table.")
}