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/11/17 17:32:54 UTC
carbondata git commit: [CARBONDATA-1764] Fix issue of when create
table with short data type
Repository: carbondata
Updated Branches:
refs/heads/master 589f126de -> d74251fa3
[CARBONDATA-1764] Fix issue of when create table with short data type
Fix issue of when create table with short data type
This closes #1526
Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/d74251fa
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/d74251fa
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/d74251fa
Branch: refs/heads/master
Commit: d74251fa35debc5703fc8cb128eef3f58d9ab59f
Parents: 589f126
Author: xubo245 <60...@qq.com>
Authored: Fri Nov 17 23:23:31 2017 +0800
Committer: Jacky Li <ja...@qq.com>
Committed: Sat Nov 18 01:32:34 2017 +0800
----------------------------------------------------------------------
.../aggquery/IntegerDataTypeTestCase.scala | 21 ++++++++++++-
.../spark/util/DataTypeConverterUtilSuite.scala | 33 ++++++++++++++++++++
.../spark/util/DataTypeConverterUtil.scala | 1 +
3 files changed, 54 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/carbondata/blob/d74251fa/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala
index dc4dc3a..4f9d09d 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/aggquery/IntegerDataTypeTestCase.scala
@@ -32,6 +32,7 @@ class IntegerDataTypeTestCase extends QueryTest with BeforeAndAfterAll {
override def beforeAll {
sql("DROP TABLE IF EXISTS integertypetableAgg")
+ sql("DROP TABLE IF EXISTS short_table")
sql("CREATE TABLE integertypetableAgg (empno int, workgroupcategory string, deptno int, projectcode int, attendance int) STORED BY 'org.apache.carbondata.format'")
sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE integertypetableAgg OPTIONS ('DELIMITER'= ',', 'QUOTECHAR'= '\"', 'FILEHEADER'='')""")
}
@@ -141,7 +142,25 @@ class IntegerDataTypeTestCase extends QueryTest with BeforeAndAfterAll {
| DROP TABLE short_int_target_table
""".stripMargin)
}
-
+
+ test("Create a table that contains short data type") {
+ sql("CREATE TABLE if not exists short_table(col1 short, col2 BOOLEAN) STORED BY 'carbondata'")
+
+ sql("insert into short_table values(1,true)")
+ sql("insert into short_table values(11,false)")
+ sql("insert into short_table values(211,false)")
+ sql("insert into short_table values(3111,true)")
+ sql("insert into short_table values(31111,false)")
+ sql("insert into short_table values(411111,false)")
+ sql("insert into short_table values(5111111,true)")
+
+ checkAnswer(
+ sql("select count(*) from short_table"),
+ Row(7)
+ )
+ sql("DROP TABLE IF EXISTS short_table")
+ }
+
override def afterAll {
sql("drop table if exists integertypetableAgg")
CarbonProperties.getInstance().addProperty(
http://git-wip-us.apache.org/repos/asf/carbondata/blob/d74251fa/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/util/DataTypeConverterUtilSuite.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/util/DataTypeConverterUtilSuite.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/util/DataTypeConverterUtilSuite.scala
new file mode 100644
index 0000000..0dd7b23
--- /dev/null
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/util/DataTypeConverterUtilSuite.scala
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.carbondata.spark.util
+
+import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
+
+import org.apache.spark.sql.test.util.QueryTest
+
+import org.apache.carbondata.core.metadata.datatype.DataTypes
+
+/**
+ * test [[DataTypeConverterUtil]]
+ */
+class DataTypeConverterUtilSuite extends QueryTest with BeforeAndAfterEach with BeforeAndAfterAll {
+ test("test short convert") {
+ assert(DataTypeConverterUtil.convertToCarbonType("short") == DataTypes.SHORT)
+ }
+}
http://git-wip-us.apache.org/repos/asf/carbondata/blob/d74251fa/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/DataTypeConverterUtil.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/DataTypeConverterUtil.scala b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/DataTypeConverterUtil.scala
index 38657ac..0969fdf 100644
--- a/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/DataTypeConverterUtil.scala
+++ b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/DataTypeConverterUtil.scala
@@ -32,6 +32,7 @@ object DataTypeConverterUtil {
case "integer" => DataTypes.INT
case "tinyint" => DataTypes.SHORT
case "smallint" => DataTypes.SHORT
+ case "short" => DataTypes.SHORT
case "long" => DataTypes.LONG
case "bigint" => DataTypes.LONG
case "numeric" => DataTypes.DOUBLE