carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject carbondata git commit: [CARBONDATA-1808] [BugFix] Inconsistency in create table and alter table usage for char and varchar
Date Tue, 05 Dec 2017 16:13:13 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master f70e6d700 -> 3d8f09bac


[CARBONDATA-1808] [BugFix] Inconsistency in create table and alter table usage for char and
varchar

 Inconsistency in create table and alter table usage for char and varchar

This closes #1580


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

Branch: refs/heads/master
Commit: 3d8f09bac97874a0c8ca5e47e56af0d2030580c3
Parents: f70e6d7
Author: anubhav100 <anubhav.tarar@knoldus.in>
Authored: Tue Nov 28 13:30:29 2017 +0530
Committer: Jacky Li <jacky.likun@qq.com>
Committed: Wed Dec 6 00:02:47 2017 +0800

----------------------------------------------------------------------
 .../apache/spark/sql/catalyst/CarbonDDLSqlParser.scala  |  8 ++++----
 .../restructure/vectorreader/AddColumnTestCases.scala   | 12 ++++++++++--
 2 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/3d8f09ba/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 094a629..8972b3d 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
@@ -971,12 +971,12 @@ abstract class CarbonDDLSqlParser extends AbstractCarbonSparkSQLParser
{
     DATE ^^^ "date" | charType
 
   /**
-   * Matching the decimal(10,0) data type and returning the same.
+   * Matching the char data type and returning the same.
    */
   private lazy val charType =
-    (CHAR | VARCHAR ) ~ ("(" ~>numericLit <~ ")") ^^ {
-      case char ~ digit =>
-        s"$char($digit)"
+    (CHAR | VARCHAR ) ~ opt("(" ~>numericLit <~ ")") ^^ {
+      case (char ~ _) =>
+        s"$char"
     }
 
   /**

http://git-wip-us.apache.org/repos/asf/carbondata/blob/3d8f09ba/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
b/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
index cddbd7a..e32ca04 100644
--- a/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
+++ b/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
@@ -239,7 +239,7 @@ class AddColumnTestCases extends Spark2QueryTest with BeforeAndAfterAll
{
 
   test("test to check if exception is thrown with wrong char syntax") {
     sqlContext.setConf("carbon.enable.vector.reader", "false")
-    intercept[Exception] {
+    try {
       sql("DROP TABLE IF EXISTS carbon_table")
       sql(
         "CREATE TABLE carbon_table(intField INT,stringField STRING,charField STRING,timestampField
" +
@@ -249,6 +249,10 @@ class AddColumnTestCases extends Spark2QueryTest with BeforeAndAfterAll
{
       sql(
         "ALTER TABLE carbon_table ADD COLUMNS(newfield char) TBLPROPERTIES ('DEFAULT.VALUE.newfield'='c')")
       sql("DROP TABLE IF EXISTS carbon_table")
+      assert(true)
+    }
+    catch {
+      case _ => assert(false)
     }
   }
 
@@ -268,7 +272,7 @@ class AddColumnTestCases extends Spark2QueryTest with BeforeAndAfterAll
{
 
   test("test to check if exception is thrown with wrong varchar syntax") {
     sqlContext.setConf("carbon.enable.vector.reader", "false")
-    intercept[Exception] {
+    try {
       sql("DROP TABLE IF EXISTS carbon_table")
       sql(
         "CREATE TABLE carbon_table(intField INT,stringField STRING,charField STRING,timestampField
" +
@@ -278,6 +282,10 @@ class AddColumnTestCases extends Spark2QueryTest with BeforeAndAfterAll
{
       sql(
         "ALTER TABLE carbon_table ADD COLUMNS(newfield varchar) TBLPROPERTIES ('DEFAULT.VALUE.newfield'='c')")
       sql("DROP TABLE IF EXISTS carbon_table")
+      assert(true)
+    }
+    catch {
+      case exception:Exception => assert(false)
     }
   }
 


Mime
View raw message