[CARBONDATA-2090] Fix the error message of alter streaming property Fix the error message of alter streaming property
This closes #1873 Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/c9a501dc Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/c9a501dc Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/c9a501dc Branch: refs/heads/fgdatamap Commit: c9a501dca672678093fe0e5f526b226057b96d5d Parents: 4d3f398 Author: QiangCai <qiang...@qq.com> Authored: Mon Jan 29 11:40:47 2018 +0800 Committer: chenliang613 <chenliang...@huawei.com> Committed: Wed Jan 31 11:58:44 2018 +0800 ---------------------------------------------------------------------- .../spark/sql/execution/strategy/DDLStrategy.scala | 7 ++++++- .../spark/carbondata/TestStreamingTableOperation.scala | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/carbondata/blob/c9a501dc/integration/spark2/src/main/scala/org/apache/spark/sql/execution/strategy/DDLStrategy.scala ---------------------------------------------------------------------- diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/strategy/DDLStrategy.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/strategy/DDLStrategy.scala index 57be754..db8c6a2 100644 --- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/strategy/DDLStrategy.scala +++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/strategy/DDLStrategy.scala @@ -231,9 +231,14 @@ class DDLStrategy(sparkSession: SparkSession) extends SparkStrategy { // TODO remove this limitation later val property = properties.find(_._1.equalsIgnoreCase("streaming")) if (property.isDefined) { - if (!property.get._2.trim.equalsIgnoreCase("true")) { + if (carbonTable.isStreamingTable) { throw new MalformedCarbonCommandException( "Streaming property can not be changed once it is 'true'") + } else { + if (!property.get._2.trim.equalsIgnoreCase("true")) { + throw new MalformedCarbonCommandException( + "Streaming property value is incorrect") + } } } ExecutedCommandExec(CarbonAlterTableSetCommand(tableName, properties, isView)) :: Nil http://git-wip-us.apache.org/repos/asf/carbondata/blob/c9a501dc/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala ---------------------------------------------------------------------- diff --git a/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala b/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala index 18e52f6..44204d4 100644 --- a/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala +++ b/integration/spark2/src/test/scala/org/apache/spark/carbondata/TestStreamingTableOperation.scala @@ -181,7 +181,11 @@ class TestStreamingTableOperation extends QueryTest with BeforeAndAfterAll { } // normal table not support streaming ingest - test("normal table not support streaming ingest") { + test("normal table not support streaming ingest and alter normal table's streaming property") { + // alter normal table's streaming property + val msg = intercept[MalformedCarbonCommandException](sql("alter table streaming.batch_table set tblproperties('streaming'='false')")) + assertResult("Streaming property value is incorrect")(msg.getMessage) + val identifier = new TableIdentifier("batch_table", Option("streaming")) val carbonTable = CarbonEnv.getInstance(spark).carbonMetastore.lookupRelation(identifier)(spark) .asInstanceOf[CarbonRelation].metaData.carbonTable @@ -518,6 +522,11 @@ class TestStreamingTableOperation extends QueryTest with BeforeAndAfterAll { case _ => assert(false, "should support set table to streaming") } + + // alter streaming table's streaming property + val msg = intercept[MalformedCarbonCommandException](sql("alter table streaming.stream_table_handoff set tblproperties('streaming'='false')")) + assertResult("Streaming property can not be changed once it is 'true'")(msg.getMessage) + val segments = sql("show segments for table streaming.stream_table_handoff").collect() assert(segments.length == 2 || segments.length == 3) assertResult("Streaming")(segments(0).getString(1))