@@ -52,14 +52,18 @@ import org.apache.spark.util.Utils
5252@ ExtendedHiveTest
5353class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
5454 import HiveExternalCatalogVersionsSuite ._
55- private val isTestAtLeastJava9 = SystemUtils .isJavaVersionAtLeast(JavaVersion .JAVA_9 )
5655 private val wareHousePath = Utils .createTempDir(namePrefix = " warehouse" )
5756 private val tmpDataDir = Utils .createTempDir(namePrefix = " test-data" )
5857 // For local test, you can set `spark.test.cache-dir` to a static value like `/tmp/test-spark`, to
5958 // avoid downloading Spark of different versions in each run.
6059 private val sparkTestingDir = Option (System .getProperty(SPARK_TEST_CACHE_DIR_SYSTEM_PROPERTY ))
6160 .map(new File (_)).getOrElse(Utils .createTempDir(namePrefix = " test-spark" ))
6261 private val unusedJar = TestUtils .createJarWithClasses(Seq .empty)
62+ val hiveVersion = if (SystemUtils .isJavaVersionAtLeast(JavaVersion .JAVA_9 )) {
63+ " 2.3.7"
64+ } else {
65+ " 1.2.1"
66+ }
6367
6468 override def afterAll (): Unit = {
6569 try {
@@ -149,7 +153,9 @@ class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
149153 new String (Files .readAllBytes(contentPath), StandardCharsets .UTF_8 )
150154 }
151155
152- private def prepare (): Unit = {
156+ override def beforeAll (): Unit = {
157+ super .beforeAll()
158+
153159 val tempPyFile = File .createTempFile(" test" , " .py" )
154160 // scalastyle:off line.size.limit
155161 Files .write(tempPyFile.toPath,
@@ -199,7 +205,7 @@ class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
199205 " --master" , " local[2]" ,
200206 " --conf" , s " ${UI_ENABLED .key}=false " ,
201207 " --conf" , s " ${MASTER_REST_SERVER_ENABLED .key}=false " ,
202- " --conf" , s " ${HiveUtils .HIVE_METASTORE_VERSION .key}=1.2.1 " ,
208+ " --conf" , s " ${HiveUtils .HIVE_METASTORE_VERSION .key}= $hiveVersion " ,
203209 " --conf" , s " ${HiveUtils .HIVE_METASTORE_JARS .key}=maven " ,
204210 " --conf" , s " ${WAREHOUSE_PATH .key}= ${wareHousePath.getCanonicalPath}" ,
205211 " --conf" , s " spark.sql.test.version.index= $index" ,
@@ -211,23 +217,14 @@ class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
211217 tempPyFile.delete()
212218 }
213219
214- override def beforeAll (): Unit = {
215- super .beforeAll()
216- if (! isTestAtLeastJava9) {
217- prepare()
218- }
219- }
220-
221220 test(" backward compatibility" ) {
222- // TODO SPARK-28704 Test backward compatibility on JDK9+ once we have a version supports JDK9+
223- assume(! isTestAtLeastJava9)
224221 val args = Seq (
225222 " --class" , PROCESS_TABLES .getClass.getName.stripSuffix(" $" ),
226223 " --name" , " HiveExternalCatalog backward compatibility test" ,
227224 " --master" , " local[2]" ,
228225 " --conf" , s " ${UI_ENABLED .key}=false " ,
229226 " --conf" , s " ${MASTER_REST_SERVER_ENABLED .key}=false " ,
230- " --conf" , s " ${HiveUtils .HIVE_METASTORE_VERSION .key}=1.2.1 " ,
227+ " --conf" , s " ${HiveUtils .HIVE_METASTORE_VERSION .key}= $hiveVersion " ,
231228 " --conf" , s " ${HiveUtils .HIVE_METASTORE_JARS .key}=maven " ,
232229 " --conf" , s " ${WAREHOUSE_PATH .key}= ${wareHousePath.getCanonicalPath}" ,
233230 " --driver-java-options" , s " -Dderby.system.home= ${wareHousePath.getCanonicalPath}" ,
@@ -252,7 +249,9 @@ object PROCESS_TABLES extends QueryTest with SQLTestUtils {
252249 // do not throw exception during object initialization.
253250 case NonFatal (_) => Seq (" 3.0.1" , " 2.4.7" ) // A temporary fallback to use a specific version
254251 }
255- versions.filter(v => v.startsWith(" 3" ) || ! TestUtils .isPythonVersionAtLeast38())
252+ versions
253+ .filter(v => v.startsWith(" 3" ) || ! TestUtils .isPythonVersionAtLeast38())
254+ .filter(v => v.startsWith(" 3" ) || ! SystemUtils .isJavaVersionAtLeast(JavaVersion .JAVA_9 ))
256255 }
257256
258257 protected var spark : SparkSession = _
0 commit comments