Skip to content

Commit

Permalink
[SPARK-22811][PYSPARK][ML] Fix pyspark.ml.tests failure when Hive is …
Browse files Browse the repository at this point in the history
…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 <bago@databricks.com>

Closes #19997 from MrBago/fix-ImageReaderTest2.
  • Loading branch information
MrBago authored and HyukjinKwon committed Dec 16, 2017
1 parent 4677623 commit 0c8fca4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/pyspark/ml/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import numpy as np
from numpy import abs, all, arange, array, array_equal, inf, ones, tile, zeros
import inspect
import py4j

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

@classmethod
def setUpClass(cls):
PySparkTestCase.setUpClass()
super(ImageReaderTest2, cls).setUpClass()
# Note that here we enable Hive's support.
cls.spark = None
try:
cls.sc._jvm.org.apache.hadoop.hive.conf.HiveConf()
except py4j.protocol.Py4JError:
Expand All @@ -1873,8 +1875,10 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
PySparkTestCase.tearDownClass()
cls.spark.sparkSession.stop()
super(ImageReaderTest2, cls).tearDownClass()
if cls.spark is not None:
cls.spark.sparkSession.stop()
cls.spark = None

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

0 comments on commit 0c8fca4

Please sign in to comment.