From b454d3eb732c423e88d9af49c6a4535c9d121110 Mon Sep 17 00:00:00 2001 From: anubhav100 Date: Tue, 6 Mar 2018 12:08:48 +0530 Subject: [PATCH] Fixed Exception is Masked Inside StandardPartitionTableQueryTestCase --- .../StandardPartitionTableQueryTestCase.scala | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala index 163e66285b5..4cce7d570b1 100644 --- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala +++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala @@ -17,6 +17,7 @@ package org.apache.carbondata.spark.testsuite.standardpartition import org.apache.spark.sql.execution.BatchedDataSourceScanExec +import org.apache.spark.sql.test.Spark2TestQueryExecutor import org.apache.spark.sql.test.util.QueryTest import org.apache.spark.sql.{DataFrame, Row} import org.scalatest.BeforeAndAfterAll @@ -244,11 +245,31 @@ class StandardPartitionTableQueryTestCase extends QueryTest with BeforeAndAfterA } test("Creation of partition table should fail if the colname in table schema and partition column is same even if both are case sensitive"){ - intercept[Exception]{ + + val exception = intercept[Exception]{ sql("CREATE TABLE uniqdata_char2(name char,id int) partitioned by (NAME char)stored by 'carbondata' ") } + if(Spark2TestQueryExecutor.spark.version.startsWith("2.1.0")){ + assert(exception.getMessage.contains("Operation not allowed: Partition columns should not be " + + "specified in the schema: [\"name\"]")) + } + else{ + //spark 2.2 allow creating char data type only with digits thats why this assert is here as it will throw this exception + assert(exception.getMessage.contains("DataType char is not supported")) + + } } + test("Creation of partition table should fail for both spark version with same exception when char data type is created with specified digit and colname in table schema and partition column is same even if both are case sensitive"){ + + sql("DROP TABLE IF EXISTS UNIQDATA_CHAR2") + val exception = intercept[Exception]{ + sql("CREATE TABLE uniqdata_char2(name char(10),id int) partitioned by (NAME char(10))stored by 'carbondata' ") + } + assert(exception.getMessage.contains("Operation not allowed: Partition columns should not be " + + "specified in the schema: [\"name\"]")) + } + test("Renaming a partition table should fail"){ sql("drop table if exists partitionTable") sql(