carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [23/51] [abbrv] carbondata git commit: [CARBONDATA-1413]Validate for invalid range info in partition definition
Date Mon, 18 Sep 2017 10:01:42 GMT
[CARBONDATA-1413]Validate for invalid range info in partition definition

This closes #1323


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

Branch: refs/heads/branch-1.2
Commit: 9f0ac24d900549c0d88810e7d95007a0544ce086
Parents: b8ecf81
Author: Raghunandan S <carbondatacontributions@gmail.com>
Authored: Tue Sep 5 16:58:31 2017 +0530
Committer: Ravindra Pesala <ravi.pesala@gmail.com>
Committed: Wed Sep 13 08:41:54 2017 +0530

----------------------------------------------------------------------
 .../partition/TestDDLForPartitionTable.scala    | 20 ++++++++++++++++++++
 .../carbondata/spark/util/CommonUtil.scala      |  4 ++++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/9f0ac24d/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestDDLForPartitionTable.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestDDLForPartitionTable.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestDDLForPartitionTable.scala
index 8083fde..8c79398 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestDDLForPartitionTable.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestDDLForPartitionTable.scala
@@ -367,6 +367,25 @@ class TestDDLForPartitionTable  extends QueryTest with BeforeAndAfterAll
{
     assert(exception_test_range_decimal.getMessage.contains("Invalid Partition Values"))
   }
 
+  test("Invalid Partition Range") {
+    val exceptionMessage: Exception = intercept[Exception] {
+      sql(
+        """
+          | CREATE TABLE default.rangeTableInvalid (empno int, empname String, designation
String,
+          |  workgroupcategory int, workgroupcategoryname String, deptno int, deptname String,
+          |  projectcode int, projectjoindate Timestamp, projectenddate Timestamp,attendance
int,
+          |  utilization int,salary int)
+          | PARTITIONED BY (doj Timestamp)
+          | STORED BY 'org.apache.carbondata.format'
+          | TBLPROPERTIES('PARTITION_TYPE'='RANGE',
+          |  'RANGE_INFO'='2017-06-11 00:00:02')
+        """.stripMargin)
+    }
+
+    assert(exceptionMessage.getMessage
+      .contains("Range info must define a valid range.Please check again!"))
+  }
+
   override def afterAll = {
     dropTable
   }
@@ -395,6 +414,7 @@ class TestDDLForPartitionTable  extends QueryTest with BeforeAndAfterAll
{
     sql("DROP TABLE IF EXISTS test_range_date")
     sql("DROP TABLE IF EXISTS test_range_timestamp")
     sql("DROP TABLE IF EXISTS test_range_decimal")
+    sql("DROP TABLE IF EXISTS rangeTableInvalid")
   }
 
 }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/9f0ac24d/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
index c67806e..ed4d784 100644
--- a/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
+++ b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
@@ -323,6 +323,10 @@ object CommonUtil {
    */
   def validateRangeInfo(rangeInfo: List[String], columnDataType: DataType,
       timestampFormatter: SimpleDateFormat, dateFormatter: SimpleDateFormat): Unit = {
+    if (rangeInfo.size <= 1) {
+      throw new
+         MalformedCarbonCommandException("Range info must define a valid range.Please check
again!")
+    }
     val comparator = Comparator.getComparator(columnDataType)
     var head = columnDataType match {
       case DataType.STRING => ByteUtil.toBytes(rangeInfo.head)


Mime
View raw message