carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject [15/50] [abbrv] carbondata git commit: [CARBONDATA-2734] Fix struct of date issue in create table
Date Wed, 18 Jul 2018 02:19:48 GMT
[CARBONDATA-2734] Fix struct of date issue in create table

problem: Struct of date is not supported currently in create table flow
as date datatype check is missing during parsing.
Hence child date column was not appended with parent name, leading to
StringOutOfIndex exception.

solution: Handle the date DataType as a complex child during column
formation.

This closes #2494


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

Branch: refs/heads/carbonstore
Commit: 18381e3db164802258b28b794c15d45cbf687f2f
Parents: 56e7dad
Author: ajantha-bhat <ajanthabhat@gmail.com>
Authored: Wed Jul 11 17:28:45 2018 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Fri Jul 13 11:58:45 2018 +0530

----------------------------------------------------------------------
 .../testsuite/complexType/TestComplexDataType.scala  | 15 +++++++++++++++
 .../spark/sql/catalyst/CarbonDDLSqlParser.scala      |  6 ++++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/18381e3d/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala
index 276ed30..1068ba2 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala
@@ -667,4 +667,19 @@ class TestComplexDataType extends QueryTest with BeforeAndAfterAll {
     checkAnswer(sql("select a.b from test where id=3 or a.c=3"),Seq(Row(5),Row(2)))
   }
 
+  /* test struct of date*/
+  test("test struct complex type with date") {
+    var backupdateFormat = CarbonProperties.getInstance().getProperty(
+      CarbonCommonConstants.CARBON_DATE_FORMAT, CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT)
+    CarbonProperties.getInstance()
+      .addProperty(CarbonCommonConstants.CARBON_DATE_FORMAT,
+        CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT)
+    sql("DROP TABLE IF EXISTS test")
+    sql("create table test(a struct<b:date>) stored by 'carbondata'")
+    sql("insert into test select '1992-02-19' ")
+    checkAnswer(sql("select * from test "), Row(Row(java.sql.Date.valueOf("1992-02-19"))))
+    CarbonProperties.getInstance()
+      .addProperty(CarbonCommonConstants.CARBON_DATE_FORMAT,
+        backupdateFormat)
+  }
 }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/18381e3d/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 0a0b49f..44adff3 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
@@ -1254,6 +1254,10 @@ abstract class CarbonDDLSqlParser extends AbstractCarbonSparkSQLParser
{
         Field(field.column, Some("Timestamp"), field.name, Some(null),
           field.parent, field.storeType, field.schemaOrdinal,
           field.precision, field.scale, field.rawSchema, field.columnComment)
+      case "date" =>
+        Field(field.column, Some("Date"), field.name, Some(null),
+          field.parent, field.storeType, field.schemaOrdinal,
+          field.precision, field.scale, field.rawSchema, field.columnComment)
       case "numeric" => Field(field.column, Some("Numeric"), field.name, Some(null), field.parent,
         field.storeType, field.schemaOrdinal, field.precision, field.scale, field.rawSchema,
         field.columnComment)
@@ -1326,6 +1330,8 @@ abstract class CarbonDDLSqlParser extends AbstractCarbonSparkSQLParser
{
         Some(parentName + "." + field.name.getOrElse(None)), Some(null), parentName)
       case "Timestamp" => Field(parentName + "." + field.column, Some("Timestamp"),
         Some(parentName + "." + field.name.getOrElse(None)), Some(null), parentName)
+      case "Date" => Field(parentName + "." + field.column, Some("Date"),
+        Some(parentName + "." + field.name.getOrElse(None)), Some(null), parentName)
       case "Numeric" => Field(parentName + "." + field.column, Some("Numeric"),
         Some(parentName + "." + field.name.getOrElse(None)), Some(null), parentName)
       case "Array" => Field(parentName + "." + field.column, Some("Array"),


Mime
View raw message