You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ra...@apache.org on 2019/04/02 02:41:27 UTC
[carbondata] 07/41: [CARBONDATA-3276] Compacting table that do not
exist should modify the message of MalformedCarbonCommandException
This is an automated email from the ASF dual-hosted git repository.
ravipesala pushed a commit to branch branch-1.5
in repository https://gitbox.apache.org/repos/asf/carbondata.git
commit f6e1c2e6a7c926d1a73865e2d0a3d267a70a204c
Author: qiuchenjian <80...@qq.com>
AuthorDate: Mon Jan 28 10:26:46 2019 +0800
[CARBONDATA-3276] Compacting table that do not exist should modify the message of MalformedCarbonCommandException
This closes #3106
---
.../cluster/sdv/generated/AlterTableTestCase.scala | 10 +++++++++-
.../apache/spark/sql/execution/strategy/DDLStrategy.scala | 12 +++++++++---
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/AlterTableTestCase.scala b/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/AlterTableTestCase.scala
index 2cf1794..d15f70b 100644
--- a/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/AlterTableTestCase.scala
+++ b/integration/spark-common-cluster-test/src/test/scala/org/apache/carbondata/cluster/sdv/generated/AlterTableTestCase.scala
@@ -23,11 +23,11 @@ import org.apache.spark.sql.Row
import org.apache.spark.sql.common.util._
import org.apache.spark.util.SparkUtil
import org.scalatest.BeforeAndAfterAll
-
import org.apache.carbondata.common.constants.LoggerAction
import org.apache.carbondata.common.exceptions.sql.MalformedCarbonCommandException
import org.apache.carbondata.core.constants.CarbonCommonConstants
import org.apache.carbondata.core.util.CarbonProperties
+import org.apache.spark.sql.catalyst.analysis.NoSuchTableException
/**
* Test Class for AlterTableTestCase to verify all scenerios
@@ -895,6 +895,14 @@ class AlterTableTestCase extends QueryTest with BeforeAndAfterAll {
sql(s"""drop table if exists test1""").collect
}
+ test("Compaction_001_13", Include) {
+ sql("drop table if exists no_table")
+ var ex = intercept[MalformedCarbonCommandException] {
+ sql("alter table no_table compact 'major'")
+ }
+ assertResult("Table or view 'no_table' not found in database 'default' or not carbon fileformat")(ex.getMessage)
+ }
+
//Check bad record locaion isnot changed when table name is altered
test("BadRecords_001_01", Include) {
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 40a8fd5..7d449b5 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
@@ -36,7 +36,7 @@ import org.apache.spark.sql.types.StructField
import org.apache.spark.util.{CarbonReflectionUtils, FileUtils, SparkUtil}
import org.apache.carbondata.common.exceptions.sql.MalformedCarbonCommandException
-import org.apache.carbondata.common.logging.{LogService, LogServiceFactory}
+import org.apache.carbondata.common.logging.LogServiceFactory
import org.apache.carbondata.core.metadata.schema.table.CarbonTable
import org.apache.carbondata.core.util.{CarbonProperties, DataTypeUtil, ThreadLocalSessionInfo}
import org.apache.carbondata.spark.util.Util
@@ -125,7 +125,9 @@ class DDLStrategy(sparkSession: SparkSession) extends SparkStrategy {
ExecutedCommandExec(alterTable) :: Nil
} else {
throw new MalformedCarbonCommandException(
- "Operation not allowed : " + altertablemodel.alterSql)
+ String.format("Table or view '%s' not found in database '%s' or not carbon fileformat",
+ altertablemodel.tableName,
+ altertablemodel.dbName.getOrElse("default")))
}
case colRenameDataTypeChange@CarbonAlterTableColRenameDataTypeChangeCommand(
alterTableColRenameAndDataTypeChangeModel, _) =>
@@ -146,7 +148,11 @@ class DDLStrategy(sparkSession: SparkSession) extends SparkStrategy {
ExecutedCommandExec(colRenameDataTypeChange) :: Nil
}
} else {
- throw new MalformedCarbonCommandException("Unsupported alter operation on hive table")
+ throw new MalformedCarbonCommandException(
+ String.format("Table or view '%s' not found in database '%s' or not carbon fileformat",
+ alterTableColRenameAndDataTypeChangeModel.tableName,
+ alterTableColRenameAndDataTypeChangeModel.
+ databaseName.getOrElse("default")))
}
case addColumn@CarbonAlterTableAddColumnCommand(alterTableAddColumnsModel) =>
val isCarbonTable = CarbonEnv.getInstance(sparkSession).carbonMetaStore