You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ja...@apache.org on 2017/05/08 09:48:20 UTC

[08/14] incubator-carbondata git commit: fix non partition table error

fix non partition table error


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

Branch: refs/heads/12-dev
Commit: f6fe9dcc75a3010478ecaf5ea66c80f446847e01
Parents: 74a8315
Author: lionelcao <wh...@gmail.com>
Authored: Fri May 5 11:14:51 2017 +0800
Committer: lionelcao <wh...@gmail.com>
Committed: Fri May 5 11:14:51 2017 +0800

----------------------------------------------------------------------
 .../carbondata/examples/CarbonPartitionExample.scala | 15 +++++++++++++++
 .../apache/carbondata/spark/util/CommonUtil.scala    |  6 +++---
 .../spark/sql/catalyst/CarbonDDLSqlParser.scala      |  6 +++++-
 3 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/f6fe9dcc/examples/spark2/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
----------------------------------------------------------------------
diff --git a/examples/spark2/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala b/examples/spark2/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
index 0b63c9c..6b1b54e 100644
--- a/examples/spark2/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
+++ b/examples/spark2/src/main/scala/org/apache/carbondata/examples/CarbonPartitionExample.scala
@@ -48,6 +48,21 @@ object CarbonPartitionExample {
 
     spark.sparkContext.setLogLevel("WARN")
 
+    // none partition table
+    spark.sql("DROP TABLE IF EXISTS t0")
+
+    spark.sql("""
+                | CREATE TABLE IF NOT EXISTS t0
+                | (
+                | vin String,
+                | logdate Timestamp,
+                | phonenumber Long,
+                | country String,
+                | area String
+                | )
+                | STORED BY 'carbondata'
+              """.stripMargin)
+
     // range partition
     spark.sql("DROP TABLE IF EXISTS t1")
 

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/f6fe9dcc/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 918106b..f40cc4e 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
@@ -163,7 +163,7 @@ object CommonUtil {
     val rangeInfo = tableProperties.get(CarbonCommonConstants.RANGE_INFO)
     val listInfo = tableProperties.get(CarbonCommonConstants.LIST_INFO)
 
-    // partition column and partitioning should be both exist or not exist
+    // partition column and partition_type should be both exist or not exist
     if (partitionCols.isEmpty ^ partitionType.isEmpty) {
       isValid = false
     } else if (partitionCols.nonEmpty) {
@@ -174,9 +174,9 @@ object CommonUtil {
         case "RANGE_INTERVAL" => isValid = false
         case _ => isValid = false
       }
+      // only support one partition column for now
+      if (partitionCols.length > 1) isValid = false
     }
-    // only support one partition column for now
-    if (partitionCols.length > 1) isValid = false
     isValid
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/f6fe9dcc/integration/spark-common/src/main/scala/org/apache/spark/sql/catalyst/CarbonDDLSqlParser.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common/src/main/scala/org/apache/spark/sql/catalyst/CarbonDDLSqlParser.scala b/integration/spark-common/src/main/scala/org/apache/spark/sql/catalyst/CarbonDDLSqlParser.scala
index 30660a8..3ccfbb1 100644
--- a/integration/spark-common/src/main/scala/org/apache/spark/sql/catalyst/CarbonDDLSqlParser.scala
+++ b/integration/spark-common/src/main/scala/org/apache/spark/sql/catalyst/CarbonDDLSqlParser.scala
@@ -262,7 +262,11 @@ abstract class CarbonDDLSqlParser extends AbstractCarbonSparkSQLParser {
     // get no inverted index columns from table properties.
     val noInvertedIdxCols = extractNoInvertedIndexColumns(fields, tableProperties)
     // get partitionInfo
-    val partitionInfo = getPartitionInfo(partitionCols, tableProperties)
+    var partitionInfo: Option[PartitionInfo] = None
+
+    if (!(partitionCols.length < 1)) {
+      partitionInfo = getPartitionInfo(partitionCols, tableProperties)
+    }
     // validate the tableBlockSize from table properties
     CommonUtil.validateTableBlockSize(tableProperties)