carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qiang...@apache.org
Subject [carbondata] branch master updated: [CARBONDATA-3276] Compacting table that do not exist should modify the message of MalformedCarbonCommandException
Date Sat, 23 Feb 2019 02:54:21 GMT
This is an automated email from the ASF dual-hosted git repository.

qiangcai 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 99dfcbe  [CARBONDATA-3276] Compacting table that do not exist should modify the message
of MalformedCarbonCommandException
99dfcbe is described below

commit 99dfcbeaa9335eaafc09650da9ed1e4226c9ad9f
Author: qiuchenjian <807169000@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


Mime
View raw message