From 52ac0083f14a2454b1109b5f535c05ac7fd5a2b4 Mon Sep 17 00:00:00 2001 From: thomastechs Date: Mon, 22 Feb 2016 22:46:15 +0530 Subject: [PATCH 01/17] Adding new test suite for [SPARK-12941][SQL] Added this new integration suite for creating the docker based test suite for the bug fix in SPARK-12941 --- .../sql/jdbc/OracleIntegrationSuite.scala | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala diff --git a/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala b/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala new file mode 100644 index 0000000000000..c0c0d76de90e3 --- /dev/null +++ b/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala @@ -0,0 +1,57 @@ +/* + * 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.jdbc + +import java.math.BigDecimal +import java.sql.{Connection, Date, Timestamp} +import java.util.Properties +import org.apache.spark.sql.types._ +import org.apache.spark.sql.test.SharedSQLContext +import org.apache.spark.tags.DockerTest + + +@DockerTest +class OracleIntegrationSuite extends DockerJDBCIntegrationSuite with SharedSQLContext { + import testImplicits._ + + override val db = new DatabaseOnDocker { + override val imageName = "wnameless/oracle-xe-11g:latest" + override val env = Map( + "ORACLE_ROOT_PASSWORD" -> "oracle" + ) + override val jdbcPort: Int = 1521 + override def getJdbcUrl(ip: String, port: Int): String = + s"jdbc:oracle:thin:system/oracle@//$ip:$port/xe" + } + + test("SPARK-12941: String datatypes to be mapped to Varchar in Oracle") { + // create a sample dataframe with string type + val df1 = sparkContext.parallelize(Seq(("foo"))).toDF("x") + // write the dataframe to the oracle table tbl + df1.write.jdbc(jdbcUrl, "tbl2", new Properties) + // read the table from the oracle + val dfRead = sqlContext.read.jdbc(jdbcUrl, "tbl2", new Properties) + // get the rows + val rows = dfRead.collect() + // verify the data type is inserted + val types = rows(0).toSeq.map(x => x.getClass.toString) + assert(types(0).equals("class java.lang.String")) + // verify the value is the inserted correct or not + assert(rows(0).getString(0).equals("foo")) + } +} From b711688be233ab78fd92f42b22bcfb852a0bb1b9 Mon Sep 17 00:00:00 2001 From: thomastechs Date: Mon, 22 Feb 2016 22:50:19 +0530 Subject: [PATCH 02/17] Update pom.xml for [SPARK-12941] docker test suite addition Updated this pom.xml with the ojdbc jar related dependency to test the OracleIntegrationSuite related to SPARK-12941 bug fix --- docker-integration-tests/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker-integration-tests/pom.xml b/docker-integration-tests/pom.xml index 833ca29cd8218..4ca9705150e86 100644 --- a/docker-integration-tests/pom.xml +++ b/docker-integration-tests/pom.xml @@ -131,6 +131,12 @@ postgresql test + + com.oracle + ojdbc6 + 11.2.0.2.0 + test +