cloud-fan commented on a change in pull request #29972: URL: https://github.com/apache/spark/pull/29972#discussion_r503149449
########## File path: external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/DB2IntegrationSuite.scala ########## @@ -0,0 +1,73 @@ +/* + * 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.v2 + +import java.sql.Connection + +import org.apache.spark.SparkConf +import org.apache.spark.sql.AnalysisException +import org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog +import org.apache.spark.sql.jdbc.{DatabaseOnDocker, DockerJDBCIntegrationSuite} +import org.apache.spark.sql.types.{DoubleType, StructType} +import org.apache.spark.tags.DockerTest + +/** + * To run this test suite for a specific version (e.g., ibmcom/db2:11.5.4.0): + * {{{ + * DB2_DOCKER_IMAGE_NAME=ibmcom/db2:11.5.4.0 + * ./build/sbt -Pdocker-integration-tests "test-only *DB2IntegrationSuite" + * }}} + */ +@DockerTest +class DB2IntegrationSuite extends DockerJDBCIntegrationSuite with V2JDBCTest { + override val catalogName: String = "db2" + override val db = new DatabaseOnDocker { + override val imageName = sys.env.getOrElse("DB2_DOCKER_IMAGE_NAME", "ibmcom/db2:11.5.4.0") + override val env = Map( + "DB2INST1_PASSWORD" -> "rootpass", + "LICENSE" -> "accept", + "DBNAME" -> "foo", + "ARCHIVE_LOGS" -> "false", + "AUTOCONFIG" -> "false" + ) + override val usesIpc = false + override val jdbcPort: Int = 50000 + override val privileged = true + override def getJdbcUrl(ip: String, port: Int): String = + s"jdbc:db2://$ip:$port/foo:user=db2inst1;password=rootpass;retrieveMessagesFromServerOnGetMessage=true;" //scalastyle:ignore + } + + override def sparkConf: SparkConf = super.sparkConf + .set("spark.sql.catalog.db2", classOf[JDBCTableCatalog].getName) + .set("spark.sql.catalog.db2.url", db.getJdbcUrl(dockerIp, externalPort)) + + override def dataPreparation(conn: Connection): Unit = {} + + override def updateColumnType: Unit = { + sql(s"CREATE TABLE $catalogName.alt_table (ID INTEGER) USING _") Review comment: can we test the table schema right after creation? ########## File path: external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/OracleIntegrationSuite.scala ########## @@ -73,80 +72,16 @@ class OracleIntegrationSuite extends DockerJDBCIntegrationSuite with SharedSpark override val connectionTimeout = timeout(7.minutes) override def dataPreparation(conn: Connection): Unit = {} - test("SPARK-33034: ALTER TABLE ... add new columns") { - withTable("oracle.alt_table") { - sql("CREATE TABLE oracle.alt_table (ID STRING) USING _") - sql("ALTER TABLE oracle.alt_table ADD COLUMNS (C1 STRING, C2 STRING)") - var t = spark.table("oracle.alt_table") - var expectedSchema = new StructType() - .add("ID", StringType) - .add("C1", StringType) - .add("C2", StringType) - assert(t.schema === expectedSchema) - sql("ALTER TABLE oracle.alt_table ADD COLUMNS (C3 STRING)") - t = spark.table("oracle.alt_table") - expectedSchema = expectedSchema.add("C3", StringType) - assert(t.schema === expectedSchema) - // Add already existing column - val msg = intercept[AnalysisException] { - sql(s"ALTER TABLE oracle.alt_table ADD COLUMNS (C3 DOUBLE)") - }.getMessage - assert(msg.contains("Cannot add column, because C3 already exists")) - } - // Add a column to not existing table - val msg = intercept[AnalysisException] { - sql(s"ALTER TABLE oracle.not_existing_table ADD COLUMNS (C4 STRING)") + override def updateColumnType: Unit = { + sql(s"CREATE TABLE $catalogName.alt_table (ID INTEGER) USING _") Review comment: ditto ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
