Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 0c8fca4

Browse files
MrBagoHyukjinKwon
authored andcommitted
[SPARK-22811][PYSPARK][ML] Fix pyspark.ml.tests failure when Hive is not available.
## What changes were proposed in this pull request? pyspark.ml.tests is missing a py4j import. I've added the import and fixed the test that uses it. This test was only failing when testing without Hive. ## How was this patch tested? Existing tests. Please review http://spark.apache.org/contributing.html before opening a pull request. Author: Bago Amirbekian <[email protected]> Closes apache#19997 from MrBago/fix-ImageReaderTest2.
1 parent 4677623 commit 0c8fca4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

python/pyspark/ml/tests.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import numpy as np
4545
from numpy import abs, all, arange, array, array_equal, inf, ones, tile, zeros
4646
import inspect
47+
import py4j
4748

4849
from pyspark import keyword_only, SparkContext
4950
from pyspark.ml import Estimator, Model, Pipeline, PipelineModel, Transformer, UnaryTransformer
@@ -1859,8 +1860,9 @@ class ImageReaderTest2(PySparkTestCase):
18591860

18601861
@classmethod
18611862
def setUpClass(cls):
1862-
PySparkTestCase.setUpClass()
1863+
super(ImageReaderTest2, cls).setUpClass()
18631864
# Note that here we enable Hive's support.
1865+
cls.spark = None
18641866
try:
18651867
cls.sc._jvm.org.apache.hadoop.hive.conf.HiveConf()
18661868
except py4j.protocol.Py4JError:
@@ -1873,8 +1875,10 @@ def setUpClass(cls):
18731875

18741876
@classmethod
18751877
def tearDownClass(cls):
1876-
PySparkTestCase.tearDownClass()
1877-
cls.spark.sparkSession.stop()
1878+
super(ImageReaderTest2, cls).tearDownClass()
1879+
if cls.spark is not None:
1880+
cls.spark.sparkSession.stop()
1881+
cls.spark = None
18781882

18791883
def test_read_images_multiple_times(self):
18801884
# This test case is to check if `ImageSchema.readImages` tries to

0 commit comments

Comments
 (0)