Repository: carbondata
Updated Branches:
  refs/heads/master 9e4da2a6c -> 770e42dfc


http://git-wip-us.apache.org/repos/asf/carbondata/blob/770e42df/integration/spark2/src/test/scala/org/apache/spark/sql/common/util/Spark2QueryTest.scala
----------------------------------------------------------------------
diff --git 
a/integration/spark2/src/test/scala/org/apache/spark/sql/common/util/Spark2QueryTest.scala
 
b/integration/spark2/src/test/scala/org/apache/spark/sql/common/util/Spark2QueryTest.scala
new file mode 100644
index 0000000..7fca02e
--- /dev/null
+++ 
b/integration/spark2/src/test/scala/org/apache/spark/sql/common/util/Spark2QueryTest.scala
@@ -0,0 +1,29 @@
+/*
+ * 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.spark.sql.common.util
+
+import org.apache.spark.sql.hive.CarbonSessionState
+import org.apache.spark.sql.test.util.QueryTest
+
+
+class Spark2QueryTest extends QueryTest {
+
+  val hiveClient = 
sqlContext.sparkSession.sessionState.asInstanceOf[CarbonSessionState]
+    .metadataHive
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/carbondata/blob/770e42df/integration/spark2/src/test/scala/org/apache/spark/util/CarbonCommandSuite.scala
----------------------------------------------------------------------
diff --git 
a/integration/spark2/src/test/scala/org/apache/spark/util/CarbonCommandSuite.scala
 
b/integration/spark2/src/test/scala/org/apache/spark/util/CarbonCommandSuite.scala
index 25be4a0..a456b6d 100644
--- 
a/integration/spark2/src/test/scala/org/apache/spark/util/CarbonCommandSuite.scala
+++ 
b/integration/spark2/src/test/scala/org/apache/spark/util/CarbonCommandSuite.scala
@@ -21,14 +21,65 @@ import java.io.File
 import java.sql.Timestamp
 import java.util.Date
 
-import org.apache.spark.sql.common.util.QueryTest
+import org.apache.spark.sql.common.util.Spark2QueryTest
 import org.apache.spark.sql.test.TestQueryExecutor
 import org.scalatest.BeforeAndAfterAll
 
 import org.apache.carbondata.api.CarbonStore
 import org.apache.carbondata.core.util.CarbonUtil
 
-class CarbonCommandSuite extends QueryTest with BeforeAndAfterAll {
+class CarbonCommandSuite extends Spark2QueryTest with BeforeAndAfterAll {
+
+  protected def createAndLoadInputTable(inputTableName: String, inputPath: 
String): Unit = {
+    sql(
+      s"""
+         | CREATE TABLE $inputTableName
+         | (  shortField short,
+         |    intField int,
+         |    bigintField long,
+         |    doubleField double,
+         |    stringField string,
+         |    timestampField string,
+         |    decimalField decimal(18,2),
+         |    dateField string,
+         |    charField char(5)
+         | )
+         | ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
+       """.stripMargin)
+
+    sql(
+      s"""
+         | LOAD DATA LOCAL INPATH '$inputPath'
+         | INTO TABLE $inputTableName
+       """.stripMargin)
+  }
+
+  protected def createAndLoadTestTable(tableName: String, inputTableName: 
String): Unit = {
+    sql(
+      s"""
+         | CREATE TABLE $tableName(
+         |    shortField short,
+         |    intField int,
+         |    bigintField long,
+         |    doubleField double,
+         |    stringField string,
+         |    timestampField timestamp,
+         |    decimalField decimal(18,2),
+         |    dateField date,
+         |    charField char(5)
+         | )
+         | USING org.apache.spark.sql.CarbonSource
+         | OPTIONS ('tableName' '$tableName')
+       """.stripMargin)
+    sql(
+      s"""
+         | INSERT INTO TABLE $tableName
+         | SELECT shortField, intField, bigintField, doubleField, stringField,
+         | from_unixtime(unix_timestamp(timestampField,'yyyy/M/dd')) 
timestampField, decimalField,
+         | cast(to_date(from_unixtime(unix_timestamp(dateField,'yyyy/M/dd'))) 
as date), charField
+         | FROM $inputTableName
+       """.stripMargin)
+  }
 
   override def beforeAll(): Unit = {
     dropTable("csv_table")
@@ -75,4 +126,8 @@ class CarbonCommandSuite extends QueryTest with 
BeforeAndAfterAll {
     assert(f.list().length == 0)
     dropTable(table)
   }
+
+  protected def dropTable(tableName: String): Unit ={
+    sql(s"DROP TABLE IF EXISTS $tableName")
+  }
 }

Reply via email to