carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [17/47] incubator-carbondata git commit: no key columns (#856)
Date Mon, 01 Aug 2016 10:05:15 GMT
no key columns (#856)

when create table without key columns, it should  throw exception

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

Branch: refs/heads/master
Commit: f57a95c65ddf70e2e5ccda45c16f5aab300facf0
Parents: 9089324
Author: Jay <liujunjie9@huawei.com>
Authored: Mon Jul 25 16:13:56 2016 +0800
Committer: sujith71955 <sujithchacko.2010@gmail.com>
Committed: Mon Jul 25 13:43:56 2016 +0530

----------------------------------------------------------------------
 .../core/constants/CarbonCommonConstants.java          |  5 +++++
 .../scala/org/apache/spark/sql/CarbonSqlParser.scala   |  7 +++++++
 .../testsuite/createtable/TestCreateTableSyntax.scala  | 13 +++++++++++++
 3 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/f57a95c6/core/src/main/java/org/carbondata/core/constants/CarbonCommonConstants.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/constants/CarbonCommonConstants.java b/core/src/main/java/org/carbondata/core/constants/CarbonCommonConstants.java
index a7a8c07..739462e 100644
--- a/core/src/main/java/org/carbondata/core/constants/CarbonCommonConstants.java
+++ b/core/src/main/java/org/carbondata/core/constants/CarbonCommonConstants.java
@@ -736,6 +736,11 @@ public final class CarbonCommonConstants {
   public static final String CARBON_MERGE_SORT_PREFETCH = "carbon.merge.sort.prefetch";
   public static final String CARBON_MERGE_SORT_PREFETCH_DEFAULT = "true";
 
+  /**
+   *  default name of data base
+   */
+  public static final String DATABASE_DEFAULT_NAME = "default";
+
   // tblproperties
   public static final String COLUMN_GROUPS = "column_groups";
   public static final String DICTIONARY_EXCLUDE = "dictionary_exclude";

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/f57a95c6/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala b/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
index 7033b85..4fd5f14 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
@@ -498,6 +498,13 @@ class CarbonSqlParser()
 
     val (dims: Seq[Field], noDictionaryDims: Seq[String]) = extractDimColsAndNoDictionaryFields(
       fields, tableProperties)
+    if (dims.length == 0) {
+      throw new MalformedCarbonCommandException(s"Table ${dbName.getOrElse(
+        CarbonCommonConstants.DATABASE_DEFAULT_NAME)}.$tableName"
+        + " can not be created without key columns. Please use DICTIONARY_INCLUDE or " +
+        "DICTIONARY_EXCLUDE to set at least one key column " +
+        "if all specified columns are numeric types")
+    }
     val msrs: Seq[Field] = extractMsrColsFromFields(fields, tableProperties)
 
     // column properties

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/f57a95c6/integration/spark/src/test/scala/org/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
index fe44336..3868928 100644
--- a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
+++ b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
@@ -99,6 +99,19 @@ class TestCreateTableSyntax extends QueryTest with BeforeAndAfterAll {
     sql("drop table if exists hivetable")
   }
 
+  test("create carbon table without dimensions") {
+    try {
+      sql("create table carbontable(msr1 int, msr2 double, msr3 bigint, msr4 decimal)" +
+        " stored by 'org.apache.carbondata.format'")
+      assert(false)
+    } catch {
+      case e : MalformedCarbonCommandException => {
+        assert(e.getMessage.equals("Table default.carbontable can not be created without
" +
+          "key columns. Please use DICTIONARY_INCLUDE or DICTIONARY_EXCLUDE to " +
+          "set at least one key column if all specified columns are numeric types"))
+      }
+    }
+  }
   override def afterAll {
     sql("drop table if exists carbontable")
   }


Mime
View raw message