You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by cloud-fan <gi...@git.apache.org> on 2017/09/06 16:51:53 UTC

[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

GitHub user cloud-fan opened a pull request:

    https://github.com/apache/spark/pull/19148

    [SPARK-21936][SQL][WIP] backward compatibility test framework for HiveExternalCatalog

    ## What changes were proposed in this pull request?
    
    `HiveExternalCatalog` is a semi-public interface. When creating tables, `HiveExternalCatalog` converts the table metadata to hive table format and save into hive metastore. It's very import to guarantee backward compatibility here, i.e., tables created by previous Spark versions should still be readable in newer Spark versions.
    
    Previously we find backward compatibility issues manually, which is really easy to miss bugs. This PR introduces a test framework to automatically test `HiveExternalCatalog` backward compatibility, by downloading Spark binaries with different versions, and create tables with these Spark versions, and read these tables with current Spark version.
    
    TODO:
    add more test cases
    make sure it works on jenkins
    
    ## How was this patch tested?
    
    test-only change

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cloud-fan/spark test

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/19148.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #19148
    
----
commit 283bc45d5b8ae63ba00d74c0322469c10b4f88eb
Author: Wenchen Fan <we...@databricks.com>
Date:   2017-09-06T05:39:53Z

    backward compatibility test framework for HiveExternalCatalog

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81520 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81520/testReport)** for PR 19148 at commit [`3d827f9`](https://github.com/apache/spark/commit/3d827f9265c37ad3bf9ac0c2141d1fd5e0dcaa82).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137357440
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,199 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.sql.Timestamp
    +import java.util.Date
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import org.scalatest.concurrent.Timeouts
    +import org.scalatest.exceptions.TestFailedDueToTimeoutException
    +import org.scalatest.time.SpanSugar._
    +
    +import org.apache.spark.{SparkFunSuite, TestUtils}
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.test.ProcessTestUtils.ProcessOutputCapturer
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkFunSuite with Timeouts {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    super.afterAll()
    +  }
    +
    +  // NOTE: This is an expensive operation in terms of time (10 seconds+). Use sparingly.
    +  // This is copied from org.apache.spark.deploy.SparkSubmitSuite
    +  private def runSparkSubmit(args: Seq[String], sparkHomeOpt: Option[String] = None): Unit = {
    +    val sparkHome = sparkHomeOpt.getOrElse(
    +      sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!")))
    +    val history = ArrayBuffer.empty[String]
    +    val sparkSubmit = if (Utils.isWindows) {
    +      // On Windows, `ProcessBuilder.directory` does not change the current working directory.
    +      new File("..\\..\\bin\\spark-submit.cmd").getAbsolutePath
    +    } else {
    +      "./bin/spark-submit"
    +    }
    +    val commands = Seq(sparkSubmit) ++ args
    +    val commandLine = commands.mkString("'", "' '", "'")
    +
    +    val builder = new ProcessBuilder(commands: _*).directory(new File(sparkHome))
    +    val env = builder.environment()
    +    env.put("SPARK_TESTING", "1")
    +    env.put("SPARK_HOME", sparkHome)
    +
    +    def captureOutput(source: String)(line: String): Unit = {
    +      // This test suite has some weird behaviors when executed on Jenkins:
    +      //
    +      // 1. Sometimes it gets extremely slow out of unknown reason on Jenkins.  Here we add a
    +      //    timestamp to provide more diagnosis information.
    +      // 2. Log lines are not correctly redirected to unit-tests.log as expected, so here we print
    +      //    them out for debugging purposes.
    +      val logLine = s"${new Timestamp(new Date().getTime)} - $source> $line"
    +      // scalastyle:off println
    +      println(logLine)
    +      // scalastyle:on println
    +      history += logLine
    +    }
    +
    +    val process = builder.start()
    +    new ProcessOutputCapturer(process.getInputStream, captureOutput("stdout")).start()
    +    new ProcessOutputCapturer(process.getErrorStream, captureOutput("stderr")).start()
    +
    +    try {
    +      val exitCode = failAfter(300.seconds) { process.waitFor() }
    +      if (exitCode != 0) {
    +        // include logs in output. Note that logging is async and may not have completed
    +        // at the time this exception is raised
    +        Thread.sleep(1000)
    +        val historyLog = history.mkString("\n")
    +        fail {
    +          s"""spark-submit returned with exit code $exitCode.
    +             |Command line: $commandLine
    +             |
    +             |$historyLog
    +           """.stripMargin
    +        }
    +      }
    +    } catch {
    +      case to: TestFailedDueToTimeoutException =>
    +        val historyLog = history.mkString("\n")
    +        fail(s"Timeout of $commandLine" +
    +          s" See the log4j logs for more detail." +
    +          s"\n$historyLog", to)
    +      case t: Throwable => throw t
    +    } finally {
    +      // Ensure we still kill the process in case it timed out
    +      process.destroy()
    +    }
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url =
    +      s"http://mirrors.hust.edu.cn/apache/spark/spark-$version/spark-$version-bin-hadoop2.7.tgz"
    +
    +    Seq("wget", url, "-q", "-P", sparkTestingDir).!
    +
    +    val downloaded = new File(sparkTestingDir, s"spark-$version-bin-hadoop2.7.tgz").getCanonicalPath
    +    val targetDir = new File(sparkTestingDir, s"spark-$version").getCanonicalPath
    +
    +    Seq("mkdir", targetDir).!
    +
    +    Seq("tar", "-xzf", downloaded, "-C", targetDir, "--strip-components=1").!
    +
    +    Seq("rm", downloaded).!
    +  }
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +    READ_TABLES.testingVersions.zipWithIndex.foreach { case (version, index) =>
    +      val sparkHome = new File(sparkTestingDir, s"spark-$version")
    +      if (!sparkHome.exists()) {
    +        downloadSpark(version)
    +      }
    +
    +      val args = Seq(
    +        "--class", PREPARE_TABLES.getClass.getName.stripSuffix("$"),
    +        "--name", "prepare testing tables",
    +        "--master", "local[2]",
    +        "--conf", "spark.ui.enabled=false",
    +        "--conf", "spark.master.rest.enabled=false",
    +        "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +        "--conf", s"spark.sql.test.version.index=$index",
    +        "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +        unusedJar.toString)
    +      runSparkSubmit(args, Some(sparkHome.getCanonicalPath))
    +    }
    +  }
    +
    +  test("backward compatibility") {
    +    val args = Seq(
    +      "--class", READ_TABLES.getClass.getName.stripSuffix("$"),
    +      "--name", "HiveExternalCatalog backward compatibility test",
    +      "--master", "local[2]",
    +      "--conf", "spark.ui.enabled=false",
    +      "--conf", "spark.master.rest.enabled=false",
    +      "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +      "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +      unusedJar.toString)
    +    runSparkSubmit(args)
    +  }
    +}
    +
    +object PREPARE_TABLES {
    +  def main(args: Array[String]): Unit = {
    +    val session = SparkSession.builder()
    +      .enableHiveSupport()
    +      .getOrCreate()
    +
    +    val index = session.conf.get("spark.sql.test.version.index")
    +    session.sql(s"create table t$index using parquet as select 1 a")
    --- End diff --
    
    Also create a view.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/81524/
    Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Could you send a PR to 2.2 branch?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137704899
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val tmpDataDir = Utils.createTempDir(namePrefix = "test-data")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    Utils.deleteRecursively(tmpDataDir)
    +    super.afterAll()
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url = s"https://d3kbcqa49mib13.cloudfront.net/spark-$version-bin-hadoop2.7.tgz"
    +
    +    Seq("wget", url, "-q", "-P", sparkTestingDir).!
    +
    +    val downloaded = new File(sparkTestingDir, s"spark-$version-bin-hadoop2.7.tgz").getCanonicalPath
    +    val targetDir = new File(sparkTestingDir, s"spark-$version").getCanonicalPath
    +
    +    Seq("mkdir", targetDir).!
    +
    +    Seq("tar", "-xzf", downloaded, "-C", targetDir, "--strip-components=1").!
    +
    +    Seq("rm", downloaded).!
    +  }
    +
    +  private def genDataDir(name: String): String = {
    +    new File(tmpDataDir, name).getCanonicalPath
    +  }
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +
    +    val tempPyFile = File.createTempFile("test", ".py")
    +    Files.write(tempPyFile.toPath,
    +      s"""
    +        |from pyspark.sql import SparkSession
    +        |
    +        |spark = SparkSession.builder.enableHiveSupport().getOrCreate()
    +        |version_index = spark.conf.get("spark.sql.test.version.index", None)
    +        |
    +        |spark.sql("create table data_source_tbl_{} using json as select 1 i".format(version_index))
    +        |
    +        |spark.sql("create table hive_compatible_data_source_tbl_" + version_index + \\
    +        |          " using parquet as select 1 i")
    +        |
    +        |json_file = "${genDataDir("json_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file)
    +        |spark.sql("create table external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using json options (path '{}')".format(json_file))
    +        |
    +        |parquet_file = "${genDataDir("parquet_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.parquet(parquet_file)
    +        |spark.sql("create table hive_compatible_external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using parquet options (path '{}')".format(parquet_file))
    +        |
    +        |json_file2 = "${genDataDir("json2_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file2)
    +        |spark.sql("create table external_table_without_schema_" + version_index + \\
    +        |          " using json options (path '{}')".format(json_file2))
    +        |
    +        |spark.sql("create view v_{} as select 1 i".format(version_index))
    +      """.stripMargin.getBytes("utf8"))
    +
    +    PROCESS_TABLES.testingVersions.zipWithIndex.foreach { case (version, index) =>
    +      val sparkHome = new File(sparkTestingDir, s"spark-$version")
    +      if (!sparkHome.exists()) {
    +        downloadSpark(version)
    +      }
    +
    +      val args = Seq(
    +        "--name", "prepare testing tables",
    +        "--master", "local[2]",
    +        "--conf", "spark.ui.enabled=false",
    +        "--conf", "spark.master.rest.enabled=false",
    +        "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +        "--conf", s"spark.sql.test.version.index=$index",
    +        "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +        tempPyFile.getCanonicalPath)
    +      runSparkSubmit(args, Some(sparkHome.getCanonicalPath))
    +    }
    +
    +    tempPyFile.delete()
    +  }
    +
    +  test("backward compatibility") {
    +    val args = Seq(
    +      "--class", PROCESS_TABLES.getClass.getName.stripSuffix("$"),
    +      "--name", "HiveExternalCatalog backward compatibility test",
    +      "--master", "local[2]",
    +      "--conf", "spark.ui.enabled=false",
    +      "--conf", "spark.master.rest.enabled=false",
    +      "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +      "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +      unusedJar.toString)
    +    runSparkSubmit(args)
    +  }
    +}
    +
    +object PROCESS_TABLES extends QueryTest with SQLTestUtils {
    +  // Tests the latest version of every release line.
    +  val testingVersions = Seq("2.0.2", "2.1.1", "2.2.0")
    +
    +  protected var spark: SparkSession = _
    +
    +  def main(args: Array[String]): Unit = {
    +    val session = SparkSession.builder()
    +      .enableHiveSupport()
    +      .getOrCreate()
    +    spark = session
    +
    +    testingVersions.indices.foreach { index =>
    +      Seq(
    +        s"data_source_tbl_$index",
    +        s"hive_compatible_data_source_tbl_$index",
    +        s"external_data_source_tbl_$index",
    +        s"hive_compatible_external_data_source_tbl_$index",
    +        s"external_table_without_schema_$index").foreach { tbl =>
    +        val tableMeta = spark.sharedState.externalCatalog.getTable("default", tbl)
    +
    +        // make sure we can insert and query these tables.
    +        session.sql(s"insert into $tbl select 2")
    +        checkAnswer(session.sql(s"select * from $tbl"), Row(1) :: Row(2) :: Nil)
    +        checkAnswer(session.sql(s"select i from $tbl where i > 1"), Row(2))
    --- End diff --
    
    I'm not sure we can easily identify the problematic version here if any check fails?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137682115
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,193 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val tmpDataDir = Utils.createTempDir(namePrefix = "test-data")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    --- End diff --
    
    Also delete `tmpDataDir ` and `sparkTestingDir `?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137699802
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/SparkSubmitTestUtils.scala ---
    @@ -0,0 +1,101 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.sql.Timestamp
    +import java.util.Date
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import org.scalatest.concurrent.Timeouts
    +import org.scalatest.exceptions.TestFailedDueToTimeoutException
    +import org.scalatest.time.SpanSugar._
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.test.ProcessTestUtils.ProcessOutputCapturer
    +import org.apache.spark.util.Utils
    +
    +trait SparkSubmitTestUtils extends SparkFunSuite with Timeouts {
    --- End diff --
    
    nit. Let's use `TimeLimits` instead of `Timeouts`. `Timeouts` is deprecated now.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81520 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81520/testReport)** for PR 19148 at commit [`3d827f9`](https://github.com/apache/spark/commit/3d827f9265c37ad3bf9ac0c2141d1fd5e0dcaa82).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `class HiveExternalCatalogVersionsSuite extends SparkFunSuite with Timeouts `


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137704429
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val tmpDataDir = Utils.createTempDir(namePrefix = "test-data")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    Utils.deleteRecursively(tmpDataDir)
    +    super.afterAll()
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url = s"https://d3kbcqa49mib13.cloudfront.net/spark-$version-bin-hadoop2.7.tgz"
    +
    +    Seq("wget", url, "-q", "-P", sparkTestingDir).!
    +
    +    val downloaded = new File(sparkTestingDir, s"spark-$version-bin-hadoop2.7.tgz").getCanonicalPath
    +    val targetDir = new File(sparkTestingDir, s"spark-$version").getCanonicalPath
    +
    +    Seq("mkdir", targetDir).!
    +
    +    Seq("tar", "-xzf", downloaded, "-C", targetDir, "--strip-components=1").!
    +
    +    Seq("rm", downloaded).!
    +  }
    +
    +  private def genDataDir(name: String): String = {
    +    new File(tmpDataDir, name).getCanonicalPath
    +  }
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +
    +    val tempPyFile = File.createTempFile("test", ".py")
    +    Files.write(tempPyFile.toPath,
    +      s"""
    +        |from pyspark.sql import SparkSession
    +        |
    +        |spark = SparkSession.builder.enableHiveSupport().getOrCreate()
    +        |version_index = spark.conf.get("spark.sql.test.version.index", None)
    +        |
    +        |spark.sql("create table data_source_tbl_{} using json as select 1 i".format(version_index))
    --- End diff --
    
    Instead of only using lowercase column name, should we use mix-case Hive schema for those tables?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81465 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81465/testReport)** for PR 19148 at commit [`283bc45`](https://github.com/apache/spark/commit/283bc45d5b8ae63ba00d74c0322469c10b4f88eb).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `class HiveExternalCatalogVersionsSuite extends SparkFunSuite with Timeouts `


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137663570
  
    --- Diff: sql/hive/pom.xml ---
    @@ -177,6 +177,10 @@
           <artifactId>libfb303</artifactId>
         </dependency>
         <dependency>
    +      <groupId>org.apache.derby</groupId>
    +      <artifactId>derby</artifactId>
    --- End diff --
    
    I see. Thank you!


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Merged build finished. Test FAILed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137620814
  
    --- Diff: sql/hive/pom.xml ---
    @@ -177,6 +177,10 @@
           <artifactId>libfb303</artifactId>
         </dependency>
         <dependency>
    +      <groupId>org.apache.derby</groupId>
    +      <artifactId>derby</artifactId>
    --- End diff --
    
    Hive metastore depends on derby 10.10.2, and we package derby 10.12.1 when building Spark, so at last we are using derby 10.12.1 when Spark uses local hive metastore.
    
    However this is a tricky approach, e.g. it doesn't work for SBT. When you build Spark with SBT, you are still using derby 10.10.2. It's probably the reason why the test failed on jenkins.
    
    Here I explicitly add the derby dependency to the hive module, to overwrite the default derby 10.10.2 dependency.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Merged build finished. Test FAILed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137699853
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    --- End diff --
    
    After removing the added derby dependency, this test can work.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81532 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81532/testReport)** for PR 19148 at commit [`00cdd0a`](https://github.com/apache/spark/commit/00cdd0a63bdd4f531eb06de8d9651e934f2bb448).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81524 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81524/testReport)** for PR 19148 at commit [`08dcf22`](https://github.com/apache/spark/commit/08dcf2291a0b1ae4b0e8f29c7628ff04b1924029).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils `
      * `trait SparkSubmitTestUtils extends SparkFunSuite with Timeouts `


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    LGTM except two minor comments.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Merged build finished. Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/19148


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    @cloud-fan Thanks. I'll do it.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137621130
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala ---
    @@ -1354,31 +1354,4 @@ class MetastoreDataSourcesSuite extends QueryTest with SQLTestUtils with TestHiv
           sparkSession.sparkContext.conf.set(DEBUG_MODE, previousValue)
         }
       }
    -
    -  test("SPARK-18464: support old table which doesn't store schema in table properties") {
    --- End diff --
    
    This is covered by the new test suite.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137703092
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    --- End diff --
    
    Ok. After a build clean it works now.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137683665
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,193 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val tmpDataDir = Utils.createTempDir(namePrefix = "test-data")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    super.afterAll()
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url = s"https://d3kbcqa49mib13.cloudfront.net/spark-$version-bin-hadoop2.7.tgz"
    +
    +    Seq("wget", url, "-q", "-P", sparkTestingDir).!
    +
    +    val downloaded = new File(sparkTestingDir, s"spark-$version-bin-hadoop2.7.tgz").getCanonicalPath
    +    val targetDir = new File(sparkTestingDir, s"spark-$version").getCanonicalPath
    +
    +    Seq("mkdir", targetDir).!
    +
    +    Seq("tar", "-xzf", downloaded, "-C", targetDir, "--strip-components=1").!
    +
    +    Seq("rm", downloaded).!
    +  }
    +
    +  private def genDataDir(name: String): String = {
    +    new File(tmpDataDir, name).getCanonicalPath
    +  }
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +
    +    val tempPyFile = File.createTempFile("test", ".py")
    +    Files.write(tempPyFile.toPath,
    +      s"""
    +        |from pyspark.sql import SparkSession
    +        |
    +        |spark = SparkSession.builder.enableHiveSupport().getOrCreate()
    +        |version_index = spark.conf.get("spark.sql.test.version.index", None)
    +        |
    +        |spark.sql("create table data_source_tbl_{} using json as select 1 i".format(version_index))
    +        |
    +        |spark.sql("create table hive_compatible_data_source_tbl_" + version_index + \\
    +        |          " using parquet as select 1 i")
    +        |
    +        |json_file = "${genDataDir("json_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file)
    +        |spark.sql("create table external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using json options (path '{}')".format(json_file))
    +        |
    +        |parquet_file = "${genDataDir("parquet_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.parquet(parquet_file)
    +        |spark.sql("create table hive_compatible_external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using parquet options (path '{}')".format(parquet_file))
    +        |
    +        |json_file2 = "${genDataDir("json2_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file2)
    +        |spark.sql("create table external_table_without_schema_" + version_index + \\
    +        |          " using json options (path '{}')".format(json_file2))
    +        |
    +        |spark.sql("create view v_{} as select 1 i".format(version_index))
    --- End diff --
    
    In the future, we can add more. So far, it sounds good enough.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137621065
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogBackwardCompatibilitySuite.scala ---
    @@ -1,260 +0,0 @@
    -/*
    - * 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.hive
    -
    -import java.net.URI
    -
    -import org.apache.hadoop.fs.Path
    -import org.scalatest.BeforeAndAfterEach
    -
    -import org.apache.spark.sql.QueryTest
    -import org.apache.spark.sql.catalyst.TableIdentifier
    -import org.apache.spark.sql.catalyst.catalog.{CatalogStorageFormat, CatalogTable, CatalogTableType}
    -import org.apache.spark.sql.hive.client.HiveClient
    -import org.apache.spark.sql.hive.test.TestHiveSingleton
    -import org.apache.spark.sql.test.SQLTestUtils
    -import org.apache.spark.sql.types.StructType
    -import org.apache.spark.util.Utils
    -
    -
    -class HiveExternalCatalogBackwardCompatibilitySuite extends QueryTest
    --- End diff --
    
    This is covered by the new test suite.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/81465/
    Test FAILed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/81520/
    Test FAILed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137686311
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,193 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val tmpDataDir = Utils.createTempDir(namePrefix = "test-data")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    --- End diff --
    
    I wanna keep the `sparkTestingDir`, so we don't need to download spark again if this jenkins machine has already run this suite before.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/81512/
    Test FAILed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81532 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81532/testReport)** for PR 19148 at commit [`00cdd0a`](https://github.com/apache/spark/commit/00cdd0a63bdd4f531eb06de8d9651e934f2bb448).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Merged build finished. Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81524 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81524/testReport)** for PR 19148 at commit [`08dcf22`](https://github.com/apache/spark/commit/08dcf2291a0b1ae4b0e8f29c7628ff04b1924029).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137412267
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,199 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.sql.Timestamp
    +import java.util.Date
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import org.scalatest.concurrent.Timeouts
    +import org.scalatest.exceptions.TestFailedDueToTimeoutException
    +import org.scalatest.time.SpanSugar._
    +
    +import org.apache.spark.{SparkFunSuite, TestUtils}
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.test.ProcessTestUtils.ProcessOutputCapturer
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkFunSuite with Timeouts {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    super.afterAll()
    +  }
    +
    +  // NOTE: This is an expensive operation in terms of time (10 seconds+). Use sparingly.
    +  // This is copied from org.apache.spark.deploy.SparkSubmitSuite
    +  private def runSparkSubmit(args: Seq[String], sparkHomeOpt: Option[String] = None): Unit = {
    +    val sparkHome = sparkHomeOpt.getOrElse(
    +      sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!")))
    +    val history = ArrayBuffer.empty[String]
    +    val sparkSubmit = if (Utils.isWindows) {
    +      // On Windows, `ProcessBuilder.directory` does not change the current working directory.
    +      new File("..\\..\\bin\\spark-submit.cmd").getAbsolutePath
    +    } else {
    +      "./bin/spark-submit"
    +    }
    +    val commands = Seq(sparkSubmit) ++ args
    +    val commandLine = commands.mkString("'", "' '", "'")
    +
    +    val builder = new ProcessBuilder(commands: _*).directory(new File(sparkHome))
    +    val env = builder.environment()
    +    env.put("SPARK_TESTING", "1")
    +    env.put("SPARK_HOME", sparkHome)
    +
    +    def captureOutput(source: String)(line: String): Unit = {
    +      // This test suite has some weird behaviors when executed on Jenkins:
    +      //
    +      // 1. Sometimes it gets extremely slow out of unknown reason on Jenkins.  Here we add a
    +      //    timestamp to provide more diagnosis information.
    +      // 2. Log lines are not correctly redirected to unit-tests.log as expected, so here we print
    +      //    them out for debugging purposes.
    +      val logLine = s"${new Timestamp(new Date().getTime)} - $source> $line"
    +      // scalastyle:off println
    +      println(logLine)
    +      // scalastyle:on println
    +      history += logLine
    +    }
    +
    +    val process = builder.start()
    +    new ProcessOutputCapturer(process.getInputStream, captureOutput("stdout")).start()
    +    new ProcessOutputCapturer(process.getErrorStream, captureOutput("stderr")).start()
    +
    +    try {
    +      val exitCode = failAfter(300.seconds) { process.waitFor() }
    +      if (exitCode != 0) {
    +        // include logs in output. Note that logging is async and may not have completed
    +        // at the time this exception is raised
    +        Thread.sleep(1000)
    +        val historyLog = history.mkString("\n")
    +        fail {
    +          s"""spark-submit returned with exit code $exitCode.
    +             |Command line: $commandLine
    +             |
    +             |$historyLog
    +           """.stripMargin
    +        }
    +      }
    +    } catch {
    +      case to: TestFailedDueToTimeoutException =>
    +        val historyLog = history.mkString("\n")
    +        fail(s"Timeout of $commandLine" +
    +          s" See the log4j logs for more detail." +
    +          s"\n$historyLog", to)
    +      case t: Throwable => throw t
    +    } finally {
    +      // Ensure we still kill the process in case it timed out
    +      process.destroy()
    +    }
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url =
    +      s"http://mirrors.hust.edu.cn/apache/spark/spark-$version/spark-$version-bin-hadoop2.7.tgz"
    --- End diff --
    
    It's great to have this. Is it okay to use this single site?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137699720
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    --- End diff --
    
    can you print `org.apache.derby.tools.sysinfo.getVersionString` in `IsolatedClientLoader.createClient` to see what's your actual derby version?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137700499
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    --- End diff --
    
    Did you try a clean clone? I added the derby dependency to make the test work on jenkins...


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    yea will do. @viirya feel free to send PRs to improve it like using mixed-case column names, thanks!


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Thanks! Merged to master.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81535 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81535/testReport)** for PR 19148 at commit [`62369e3`](https://github.com/apache/spark/commit/62369e3a07bc23d68068e809edf1c43de448740a).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    The test cases pass in my local environment when I run this test suite individually. It took 4 mins. It is not too bad.
    ```
    [info] Run completed in 4 minutes, 25 seconds.
    [info] Total number of tests run: 1
    [info] Suites: completed 1, aborted 0
    [info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
    [info] All tests passed.
    ```


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Merged build finished. Test FAILed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137706271
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val tmpDataDir = Utils.createTempDir(namePrefix = "test-data")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    Utils.deleteRecursively(tmpDataDir)
    +    super.afterAll()
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url = s"https://d3kbcqa49mib13.cloudfront.net/spark-$version-bin-hadoop2.7.tgz"
    +
    +    Seq("wget", url, "-q", "-P", sparkTestingDir).!
    +
    +    val downloaded = new File(sparkTestingDir, s"spark-$version-bin-hadoop2.7.tgz").getCanonicalPath
    +    val targetDir = new File(sparkTestingDir, s"spark-$version").getCanonicalPath
    +
    +    Seq("mkdir", targetDir).!
    +
    +    Seq("tar", "-xzf", downloaded, "-C", targetDir, "--strip-components=1").!
    +
    +    Seq("rm", downloaded).!
    +  }
    +
    +  private def genDataDir(name: String): String = {
    +    new File(tmpDataDir, name).getCanonicalPath
    +  }
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +
    +    val tempPyFile = File.createTempFile("test", ".py")
    +    Files.write(tempPyFile.toPath,
    +      s"""
    +        |from pyspark.sql import SparkSession
    +        |
    +        |spark = SparkSession.builder.enableHiveSupport().getOrCreate()
    +        |version_index = spark.conf.get("spark.sql.test.version.index", None)
    +        |
    +        |spark.sql("create table data_source_tbl_{} using json as select 1 i".format(version_index))
    +        |
    +        |spark.sql("create table hive_compatible_data_source_tbl_" + version_index + \\
    +        |          " using parquet as select 1 i")
    +        |
    +        |json_file = "${genDataDir("json_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file)
    +        |spark.sql("create table external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using json options (path '{}')".format(json_file))
    +        |
    +        |parquet_file = "${genDataDir("parquet_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.parquet(parquet_file)
    +        |spark.sql("create table hive_compatible_external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using parquet options (path '{}')".format(parquet_file))
    +        |
    +        |json_file2 = "${genDataDir("json2_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file2)
    +        |spark.sql("create table external_table_without_schema_" + version_index + \\
    +        |          " using json options (path '{}')".format(json_file2))
    +        |
    +        |spark.sql("create view v_{} as select 1 i".format(version_index))
    +      """.stripMargin.getBytes("utf8"))
    +
    +    PROCESS_TABLES.testingVersions.zipWithIndex.foreach { case (version, index) =>
    +      val sparkHome = new File(sparkTestingDir, s"spark-$version")
    +      if (!sparkHome.exists()) {
    +        downloadSpark(version)
    +      }
    +
    +      val args = Seq(
    +        "--name", "prepare testing tables",
    +        "--master", "local[2]",
    +        "--conf", "spark.ui.enabled=false",
    +        "--conf", "spark.master.rest.enabled=false",
    +        "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +        "--conf", s"spark.sql.test.version.index=$index",
    +        "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +        tempPyFile.getCanonicalPath)
    +      runSparkSubmit(args, Some(sparkHome.getCanonicalPath))
    +    }
    +
    +    tempPyFile.delete()
    +  }
    +
    +  test("backward compatibility") {
    +    val args = Seq(
    +      "--class", PROCESS_TABLES.getClass.getName.stripSuffix("$"),
    +      "--name", "HiveExternalCatalog backward compatibility test",
    +      "--master", "local[2]",
    +      "--conf", "spark.ui.enabled=false",
    +      "--conf", "spark.master.rest.enabled=false",
    +      "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +      "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +      unusedJar.toString)
    +    runSparkSubmit(args)
    +  }
    +}
    +
    +object PROCESS_TABLES extends QueryTest with SQLTestUtils {
    +  // Tests the latest version of every release line.
    +  val testingVersions = Seq("2.0.2", "2.1.1", "2.2.0")
    +
    +  protected var spark: SparkSession = _
    +
    +  def main(args: Array[String]): Unit = {
    +    val session = SparkSession.builder()
    +      .enableHiveSupport()
    +      .getOrCreate()
    +    spark = session
    +
    +    testingVersions.indices.foreach { index =>
    +      Seq(
    +        s"data_source_tbl_$index",
    +        s"hive_compatible_data_source_tbl_$index",
    +        s"external_data_source_tbl_$index",
    +        s"hive_compatible_external_data_source_tbl_$index",
    +        s"external_table_without_schema_$index").foreach { tbl =>
    +        val tableMeta = spark.sharedState.externalCatalog.getTable("default", tbl)
    +
    +        // make sure we can insert and query these tables.
    +        session.sql(s"insert into $tbl select 2")
    +        checkAnswer(session.sql(s"select * from $tbl"), Row(1) :: Row(2) :: Nil)
    +        checkAnswer(session.sql(s"select i from $tbl where i > 1"), Row(2))
    --- End diff --
    
    you can tell the version via table name. I agree it's a little tricky, but I don't have a better idea...


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137357402
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,199 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.sql.Timestamp
    +import java.util.Date
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import org.scalatest.concurrent.Timeouts
    +import org.scalatest.exceptions.TestFailedDueToTimeoutException
    +import org.scalatest.time.SpanSugar._
    +
    +import org.apache.spark.{SparkFunSuite, TestUtils}
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.test.ProcessTestUtils.ProcessOutputCapturer
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkFunSuite with Timeouts {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    super.afterAll()
    +  }
    +
    +  // NOTE: This is an expensive operation in terms of time (10 seconds+). Use sparingly.
    +  // This is copied from org.apache.spark.deploy.SparkSubmitSuite
    +  private def runSparkSubmit(args: Seq[String], sparkHomeOpt: Option[String] = None): Unit = {
    +    val sparkHome = sparkHomeOpt.getOrElse(
    +      sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!")))
    +    val history = ArrayBuffer.empty[String]
    +    val sparkSubmit = if (Utils.isWindows) {
    +      // On Windows, `ProcessBuilder.directory` does not change the current working directory.
    +      new File("..\\..\\bin\\spark-submit.cmd").getAbsolutePath
    +    } else {
    +      "./bin/spark-submit"
    +    }
    +    val commands = Seq(sparkSubmit) ++ args
    +    val commandLine = commands.mkString("'", "' '", "'")
    +
    +    val builder = new ProcessBuilder(commands: _*).directory(new File(sparkHome))
    +    val env = builder.environment()
    +    env.put("SPARK_TESTING", "1")
    +    env.put("SPARK_HOME", sparkHome)
    +
    +    def captureOutput(source: String)(line: String): Unit = {
    +      // This test suite has some weird behaviors when executed on Jenkins:
    +      //
    +      // 1. Sometimes it gets extremely slow out of unknown reason on Jenkins.  Here we add a
    +      //    timestamp to provide more diagnosis information.
    +      // 2. Log lines are not correctly redirected to unit-tests.log as expected, so here we print
    +      //    them out for debugging purposes.
    +      val logLine = s"${new Timestamp(new Date().getTime)} - $source> $line"
    +      // scalastyle:off println
    +      println(logLine)
    +      // scalastyle:on println
    +      history += logLine
    +    }
    +
    +    val process = builder.start()
    +    new ProcessOutputCapturer(process.getInputStream, captureOutput("stdout")).start()
    +    new ProcessOutputCapturer(process.getErrorStream, captureOutput("stderr")).start()
    +
    +    try {
    +      val exitCode = failAfter(300.seconds) { process.waitFor() }
    +      if (exitCode != 0) {
    +        // include logs in output. Note that logging is async and may not have completed
    +        // at the time this exception is raised
    +        Thread.sleep(1000)
    +        val historyLog = history.mkString("\n")
    +        fail {
    +          s"""spark-submit returned with exit code $exitCode.
    +             |Command line: $commandLine
    +             |
    +             |$historyLog
    +           """.stripMargin
    +        }
    +      }
    +    } catch {
    +      case to: TestFailedDueToTimeoutException =>
    +        val historyLog = history.mkString("\n")
    +        fail(s"Timeout of $commandLine" +
    +          s" See the log4j logs for more detail." +
    +          s"\n$historyLog", to)
    +      case t: Throwable => throw t
    +    } finally {
    +      // Ensure we still kill the process in case it timed out
    +      process.destroy()
    +    }
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url =
    +      s"http://mirrors.hust.edu.cn/apache/spark/spark-$version/spark-$version-bin-hadoop2.7.tgz"
    +
    +    Seq("wget", url, "-q", "-P", sparkTestingDir).!
    +
    +    val downloaded = new File(sparkTestingDir, s"spark-$version-bin-hadoop2.7.tgz").getCanonicalPath
    +    val targetDir = new File(sparkTestingDir, s"spark-$version").getCanonicalPath
    +
    +    Seq("mkdir", targetDir).!
    +
    +    Seq("tar", "-xzf", downloaded, "-C", targetDir, "--strip-components=1").!
    +
    +    Seq("rm", downloaded).!
    +  }
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +    READ_TABLES.testingVersions.zipWithIndex.foreach { case (version, index) =>
    +      val sparkHome = new File(sparkTestingDir, s"spark-$version")
    +      if (!sparkHome.exists()) {
    +        downloadSpark(version)
    +      }
    +
    +      val args = Seq(
    +        "--class", PREPARE_TABLES.getClass.getName.stripSuffix("$"),
    +        "--name", "prepare testing tables",
    +        "--master", "local[2]",
    +        "--conf", "spark.ui.enabled=false",
    +        "--conf", "spark.master.rest.enabled=false",
    +        "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +        "--conf", s"spark.sql.test.version.index=$index",
    +        "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +        unusedJar.toString)
    +      runSparkSubmit(args, Some(sparkHome.getCanonicalPath))
    +    }
    +  }
    +
    +  test("backward compatibility") {
    +    val args = Seq(
    +      "--class", READ_TABLES.getClass.getName.stripSuffix("$"),
    +      "--name", "HiveExternalCatalog backward compatibility test",
    +      "--master", "local[2]",
    +      "--conf", "spark.ui.enabled=false",
    +      "--conf", "spark.master.rest.enabled=false",
    +      "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +      "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +      unusedJar.toString)
    +    runSparkSubmit(args)
    +  }
    +}
    +
    +object PREPARE_TABLES {
    +  def main(args: Array[String]): Unit = {
    +    val session = SparkSession.builder()
    +      .enableHiveSupport()
    +      .getOrCreate()
    +
    +    val index = session.conf.get("spark.sql.test.version.index")
    +    session.sql(s"create table t$index using parquet as select 1 a")
    +  }
    +}
    +
    +object READ_TABLES extends QueryTest {
    +  val testingVersions = Seq("2.0.2", "2.1.1", "2.2.0")
    +
    +  protected var spark: SparkSession = _
    +
    +  def main(args: Array[String]): Unit = {
    +    val session = SparkSession.builder()
    +      .enableHiveSupport()
    +      .getOrCreate()
    +    spark = session
    +
    +    testingVersions.indices.foreach { index =>
    +      checkAnswer(session.sql(s"select * from t$index"), Row(1))
    --- End diff --
    
    We should also do the other basic SQL. For example, insert, describe, drop table


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81465 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81465/testReport)** for PR 19148 at commit [`283bc45`](https://github.com/apache/spark/commit/283bc45d5b8ae63ba00d74c0322469c10b4f88eb).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137700913
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    --- End diff --
    
    Let me do build clean and try again.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137699367
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,194 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    --- End diff --
    
    I ran this test locally and encountered the failure like:
    
        2017-09-07 19:28:07.595 - stderr> Caused by: java.sql.SQLException: Database at
        /root/repos/spark-1/target/tmp/warehouse-66dad501-c743-4ac3-83cc-51451c6d697a/metastore_db
        has an incompatible format with the current version of the software.  The database was created by or
        upgraded by version 10.12.
    



---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/81535/
    Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81512 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81512/testReport)** for PR 19148 at commit [`850536e`](https://github.com/apache/spark/commit/850536e6c86835ffa4f464191b7365f6b849533c).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    cc @gatorsmile


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137413347
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,199 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.sql.Timestamp
    +import java.util.Date
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import org.scalatest.concurrent.Timeouts
    +import org.scalatest.exceptions.TestFailedDueToTimeoutException
    +import org.scalatest.time.SpanSugar._
    +
    +import org.apache.spark.{SparkFunSuite, TestUtils}
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.test.ProcessTestUtils.ProcessOutputCapturer
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkFunSuite with Timeouts {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    --- End diff --
    
    This single warehouse seems to make a failure. Maybe, Spark 2.0.2 tries to read 2.2.0?
    ```
    build/sbt -Phive "project hive" "test-only *.HiveExternalCatalogVersionsSuite"
    ...
    [info] - backward compatibility *** FAILED *** (17 seconds, 712 milliseconds)
    [info]   spark-submit returned with exit code 1.
    ...
    [info]   2017-09-06 16:07:41.744 - stderr> Caused by: java.sql.SQLException: Database at /Users/dongjoon/PR-19148/target/tmp/warehouse-d2818ad2-f141-4fc7-bc68-e7f67c89f3f4/metastore_db has an incompatible format with the current version of the software.  The database was created by or upgraded by version 10.12.
    ```


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/81532/
    Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL][WIP] backward compatibility te...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137621549
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,193 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val tmpDataDir = Utils.createTempDir(namePrefix = "test-data")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    super.afterAll()
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url = s"https://d3kbcqa49mib13.cloudfront.net/spark-$version-bin-hadoop2.7.tgz"
    +
    +    Seq("wget", url, "-q", "-P", sparkTestingDir).!
    +
    +    val downloaded = new File(sparkTestingDir, s"spark-$version-bin-hadoop2.7.tgz").getCanonicalPath
    +    val targetDir = new File(sparkTestingDir, s"spark-$version").getCanonicalPath
    +
    +    Seq("mkdir", targetDir).!
    +
    +    Seq("tar", "-xzf", downloaded, "-C", targetDir, "--strip-components=1").!
    +
    +    Seq("rm", downloaded).!
    +  }
    +
    +  private def genDataDir(name: String): String = {
    +    new File(tmpDataDir, name).getCanonicalPath
    +  }
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +
    +    val tempPyFile = File.createTempFile("test", ".py")
    +    Files.write(tempPyFile.toPath,
    +      s"""
    +        |from pyspark.sql import SparkSession
    +        |
    +        |spark = SparkSession.builder.enableHiveSupport().getOrCreate()
    +        |version_index = spark.conf.get("spark.sql.test.version.index", None)
    +        |
    +        |spark.sql("create table data_source_tbl_{} using json as select 1 i".format(version_index))
    +        |
    +        |spark.sql("create table hive_compatible_data_source_tbl_" + version_index + \\
    +        |          " using parquet as select 1 i")
    +        |
    +        |json_file = "${genDataDir("json_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file)
    +        |spark.sql("create table external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using json options (path '{}')".format(json_file))
    +        |
    +        |parquet_file = "${genDataDir("parquet_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.parquet(parquet_file)
    +        |spark.sql("create table hive_compatible_external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using parquet options (path '{}')".format(parquet_file))
    +        |
    +        |json_file2 = "${genDataDir("json2_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file2)
    +        |spark.sql("create table external_table_without_schema_" + version_index + \\
    +        |          " using json options (path '{}')".format(json_file2))
    +        |
    +        |spark.sql("create view v_{} as select 1 i".format(version_index))
    --- End diff --
    
    Hive serde tables are excluded, because they are always compatible. Partitioned tables are excluded, becuase previous compatibility bugs are all about non-partitioned tables.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Merged build finished. Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    Less than 2 mins to finish the suite. It looks pretty good! 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL][WIP] backward compatibility test fram...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81512 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81512/testReport)** for PR 19148 at commit [`850536e`](https://github.com/apache/spark/commit/850536e6c86835ffa4f464191b7365f6b849533c).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `class HiveExternalCatalogVersionsSuite extends SparkFunSuite with Timeouts `


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #19148: [SPARK-21936][SQL] backward compatibility test framework...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19148
  
    **[Test build #81535 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81535/testReport)** for PR 19148 at commit [`62369e3`](https://github.com/apache/spark/commit/62369e3a07bc23d68068e809edf1c43de448740a).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `public class NettyMemoryMetrics implements MetricSet `


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #19148: [SPARK-21936][SQL] backward compatibility test fr...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19148#discussion_r137682740
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala ---
    @@ -0,0 +1,193 @@
    +/*
    + * 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.hive
    +
    +import java.io.File
    +import java.nio.file.Files
    +
    +import org.apache.spark.TestUtils
    +import org.apache.spark.sql.{QueryTest, Row, SparkSession}
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.catalog.CatalogTableType
    +import org.apache.spark.sql.test.SQLTestUtils
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Test HiveExternalCatalog backward compatibility.
    + *
    + * Note that, this test suite will automatically download spark binary packages of different
    + * versions to a local directory `/tmp/spark-test`. If there is already a spark folder with
    + * expected version under this local directory, e.g. `/tmp/spark-test/spark-2.0.3`, we will skip the
    + * downloading for this spark version.
    + */
    +class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
    +  private val wareHousePath = Utils.createTempDir(namePrefix = "warehouse")
    +  private val tmpDataDir = Utils.createTempDir(namePrefix = "test-data")
    +  private val sparkTestingDir = "/tmp/spark-test"
    +  private val unusedJar = TestUtils.createJarWithClasses(Seq.empty)
    +
    +  override def afterAll(): Unit = {
    +    Utils.deleteRecursively(wareHousePath)
    +    super.afterAll()
    +  }
    +
    +  private def downloadSpark(version: String): Unit = {
    +    import scala.sys.process._
    +
    +    val url = s"https://d3kbcqa49mib13.cloudfront.net/spark-$version-bin-hadoop2.7.tgz"
    +
    +    Seq("wget", url, "-q", "-P", sparkTestingDir).!
    +
    +    val downloaded = new File(sparkTestingDir, s"spark-$version-bin-hadoop2.7.tgz").getCanonicalPath
    +    val targetDir = new File(sparkTestingDir, s"spark-$version").getCanonicalPath
    +
    +    Seq("mkdir", targetDir).!
    +
    +    Seq("tar", "-xzf", downloaded, "-C", targetDir, "--strip-components=1").!
    +
    +    Seq("rm", downloaded).!
    +  }
    +
    +  private def genDataDir(name: String): String = {
    +    new File(tmpDataDir, name).getCanonicalPath
    +  }
    +
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +
    +    val tempPyFile = File.createTempFile("test", ".py")
    +    Files.write(tempPyFile.toPath,
    +      s"""
    +        |from pyspark.sql import SparkSession
    +        |
    +        |spark = SparkSession.builder.enableHiveSupport().getOrCreate()
    +        |version_index = spark.conf.get("spark.sql.test.version.index", None)
    +        |
    +        |spark.sql("create table data_source_tbl_{} using json as select 1 i".format(version_index))
    +        |
    +        |spark.sql("create table hive_compatible_data_source_tbl_" + version_index + \\
    +        |          " using parquet as select 1 i")
    +        |
    +        |json_file = "${genDataDir("json_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file)
    +        |spark.sql("create table external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using json options (path '{}')".format(json_file))
    +        |
    +        |parquet_file = "${genDataDir("parquet_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.parquet(parquet_file)
    +        |spark.sql("create table hive_compatible_external_data_source_tbl_" + version_index + \\
    +        |          "(i int) using parquet options (path '{}')".format(parquet_file))
    +        |
    +        |json_file2 = "${genDataDir("json2_")}" + str(version_index)
    +        |spark.range(1, 2).selectExpr("cast(id as int) as i").write.json(json_file2)
    +        |spark.sql("create table external_table_without_schema_" + version_index + \\
    +        |          " using json options (path '{}')".format(json_file2))
    +        |
    +        |spark.sql("create view v_{} as select 1 i".format(version_index))
    +      """.stripMargin.getBytes("utf8"))
    +
    +    READ_TABLES.testingVersions.zipWithIndex.foreach { case (version, index) =>
    +      val sparkHome = new File(sparkTestingDir, s"spark-$version")
    +      if (!sparkHome.exists()) {
    +        downloadSpark(version)
    +      }
    +
    +      val args = Seq(
    +        "--name", "prepare testing tables",
    +        "--master", "local[2]",
    +        "--conf", "spark.ui.enabled=false",
    +        "--conf", "spark.master.rest.enabled=false",
    +        "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +        "--conf", s"spark.sql.test.version.index=$index",
    +        "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +        tempPyFile.getCanonicalPath)
    +      runSparkSubmit(args, Some(sparkHome.getCanonicalPath))
    +    }
    +
    +    tempPyFile.delete()
    +  }
    +
    +  test("backward compatibility") {
    +    val args = Seq(
    +      "--class", READ_TABLES.getClass.getName.stripSuffix("$"),
    +      "--name", "HiveExternalCatalog backward compatibility test",
    +      "--master", "local[2]",
    +      "--conf", "spark.ui.enabled=false",
    +      "--conf", "spark.master.rest.enabled=false",
    +      "--conf", s"spark.sql.warehouse.dir=${wareHousePath.getCanonicalPath}",
    +      "--driver-java-options", s"-Dderby.system.home=${wareHousePath.getCanonicalPath}",
    +      unusedJar.toString)
    +    runSparkSubmit(args)
    +  }
    +}
    +
    +object READ_TABLES extends QueryTest with SQLTestUtils {
    --- End diff --
    
    -> `PROCESS_TABLE`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org