Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CARBONDATA-3276] Compacting table that do not exist should modify the message of MalformedCarbonCommandException #3106

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
Expand Down Expand Up @@ -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[NoSuchTableException] {
sql("alter table no_table compact 'major'")
}
assertResult("Table or view 'no_table' not found in database 'default';")(ex.getMessage)
}


//Check bad record locaion isnot changed when table name is altered
test("BadRecords_001_01", Include) {
Expand Down
Expand Up @@ -18,7 +18,7 @@ package org.apache.spark.sql.execution.strategy

import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.analysis.{NoSuchDatabaseException, UnresolvedRelation}
import org.apache.spark.sql.catalyst.analysis.{NoSuchDatabaseException, NoSuchTableException, UnresolvedRelation}
import org.apache.spark.sql.catalyst.catalog.CatalogTable
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
import org.apache.spark.sql.execution.{SparkPlan, SparkStrategy}
Expand All @@ -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
Expand Down Expand Up @@ -124,8 +124,8 @@ class DDLStrategy(sparkSession: SparkSession) extends SparkStrategy {
if (isCarbonTable) {
ExecutedCommandExec(alterTable) :: Nil
} else {
throw new MalformedCarbonCommandException(
"Operation not allowed : " + altertablemodel.alterSql)
throw new NoSuchTableException(altertablemodel.dbName.getOrElse("default"),
altertablemodel.tableName)
}
case colRenameDataTypeChange@CarbonAlterTableColRenameDataTypeChangeCommand(
alterTableColRenameAndDataTypeChangeModel, _) =>
Expand All @@ -146,7 +146,9 @@ class DDLStrategy(sparkSession: SparkSession) extends SparkStrategy {
ExecutedCommandExec(colRenameDataTypeChange) :: Nil
}
} else {
throw new MalformedCarbonCommandException("Unsupported alter operation on hive table")
throw new NoSuchTableException(alterTableColRenameAndDataTypeChangeModel.
databaseName.getOrElse("default"),
alterTableColRenameAndDataTypeChangeModel.tableName)
}
case addColumn@CarbonAlterTableAddColumnCommand(alterTableAddColumnsModel) =>
val isCarbonTable = CarbonEnv.getInstance(sparkSession).carbonMetaStore
Expand Down