Throwing exception in case of improper MAXCOULUMN value

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

Branch: refs/heads/branch-0.1
Commit: 6861b7e4544fe01fd8a4f3c6d2f812f465c307d2
Parents: 595460c
Author: Manohar <manohar.craz...@gmail.com>
Authored: Sat Sep 17 19:17:58 2016 +0530
Committer: ravipesala <ravi.pes...@gmail.com>
Committed: Thu Sep 22 09:44:44 2016 +0530

----------------------------------------------------------------------
 .../TestDataLoadWithColumnsMoreThanSchema.scala | 20 ++++++++++++++++++++
 .../processing/csvload/DataGraphExecuter.java   |  2 +-
 .../processing/csvreaderstep/CsvInput.java      |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/6861b7e4/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/dataload/TestDataLoadWithColumnsMoreThanSchema.scala
----------------------------------------------------------------------
diff --git 
a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/dataload/TestDataLoadWithColumnsMoreThanSchema.scala
 
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/dataload/TestDataLoadWithColumnsMoreThanSchema.scala
index 4755a01..7bd29d5 100644
--- 
a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/dataload/TestDataLoadWithColumnsMoreThanSchema.scala
+++ 
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/dataload/TestDataLoadWithColumnsMoreThanSchema.scala
@@ -25,6 +25,8 @@ import org.apache.spark.sql.common.util.CarbonHiveContext._
 import org.apache.spark.sql.common.util.QueryTest
 import org.scalatest.BeforeAndAfterAll
 
+import org.apache.carbondata.spark.exception.MalformedCarbonCommandException
+
 /**
  * This class will test data load in which number of columns in data are more 
than
  * the number of columns in schema
@@ -68,8 +70,26 @@ class TestDataLoadWithColumnsMoreThanSchema extends 
QueryTest with BeforeAndAfte
     }
   }
 
+  test("test with invalid maxColumns value") {
+    sql(
+      "CREATE TABLE max_columns_value_test (imei string,age int,task 
bigint,num double,level " +
+      "decimal(10,3),productdate timestamp,mark int,name string) STORED BY 
'org.apache.carbondata" +
+      ".format'")
+    try {
+      sql(
+        "LOAD DATA LOCAL INPATH './src/test/resources/character_carbon.csv' 
into table " +
+        "max_columns_value_test 
options('FILEHEADER='imei,age','MAXCOLUMNS'='2')")
+      throw new MalformedCarbonCommandException("Invalid")
+    } catch {
+      case me: MalformedCarbonCommandException =>
+        assert(false)
+      case _ => assert(true)
+    }
+  }
+
   override def afterAll {
     sql("DROP TABLE IF EXISTS char_test")
     sql("DROP TABLE IF EXISTS hive_char_test")
+    sql("DROP TABLE IF EXISTS max_columns_value_test")
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/6861b7e4/processing/src/main/java/org/apache/carbondata/processing/csvload/DataGraphExecuter.java
----------------------------------------------------------------------
diff --git 
a/processing/src/main/java/org/apache/carbondata/processing/csvload/DataGraphExecuter.java
 
b/processing/src/main/java/org/apache/carbondata/processing/csvload/DataGraphExecuter.java
index 67d77a3..680cb37 100644
--- 
a/processing/src/main/java/org/apache/carbondata/processing/csvload/DataGraphExecuter.java
+++ 
b/processing/src/main/java/org/apache/carbondata/processing/csvload/DataGraphExecuter.java
@@ -209,7 +209,7 @@ public class DataGraphExecuter {
 
     if (trans.getErrors() > 0) {
       LOGGER.error("Graph Execution had errors");
-      throw new DataLoadingException("Internal Errors");
+      throw new DataLoadingException("Due to internal errors, please check 
logs for more details.");
     } else if (null != BadRecordslogger.hasBadRecord(key)) {
       LOGGER.error("Graph Execution is partcially success");
       throw new DataLoadingException(DataProcessorConstants.BAD_REC_FOUND,

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/6861b7e4/processing/src/main/java/org/apache/carbondata/processing/csvreaderstep/CsvInput.java
----------------------------------------------------------------------
diff --git 
a/processing/src/main/java/org/apache/carbondata/processing/csvreaderstep/CsvInput.java
 
b/processing/src/main/java/org/apache/carbondata/processing/csvreaderstep/CsvInput.java
index c01a682..ab3dbd8 100644
--- 
a/processing/src/main/java/org/apache/carbondata/processing/csvreaderstep/CsvInput.java
+++ 
b/processing/src/main/java/org/apache/carbondata/processing/csvreaderstep/CsvInput.java
@@ -390,6 +390,7 @@ public class CsvInput extends BaseStep implements 
StepInterface {
           LOGGER.info("*****************Completed csv reading by 
thread***********");
         } catch (Throwable e) {
           LOGGER.error(e, "Thread is terminated due to error");
+          throw new RuntimeException("Thread is terminated due to error : " + 
e.getMessage());
         }
         return null;
       }

Reply via email to