[CARBONDATA-2288] [Test] Exception is Masked Inside 
StandardPartitionTableQueryTestCase

This closes #2034


Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/334a420a
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/334a420a
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/334a420a

Branch: refs/heads/master
Commit: 334a420ad59dca166f11945092daf9d7de154fe8
Parents: 76135d8
Author: anubhav100 <anubhav.ta...@knoldus.in>
Authored: Tue Mar 6 12:08:48 2018 +0530
Committer: Jacky Li <jacky.li...@qq.com>
Committed: Wed Mar 14 12:11:11 2018 +0800

----------------------------------------------------------------------
 .../StandardPartitionTableQueryTestCase.scala   | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/334a420a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala
----------------------------------------------------------------------
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 163e662..4cce7d5 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(

Reply via email to