Skip to content

Commit 8a965a5

Browse files
committed
initial commit: check for test udf and hive assembly
1 parent 4d37008 commit 8a965a5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

python/pyspark/sql/tests.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
individual modules.
2222
"""
2323
import os
24+
import glob
2425
import sys
2526
import subprocess
2627
import pydoc
@@ -84,6 +85,31 @@
8485
from pyspark.sql.utils import AnalysisException, ParseException, IllegalArgumentException
8586

8687

88+
def found_file(pattern):
89+
SPARK_HOME = os.environ["SPARK_HOME"]
90+
files = glob.glob(os.path.join(SPARK_HOME, pattern))
91+
return len(files) > 0
92+
93+
94+
def search_hive_assembly_jars():
95+
pattern = "assembly/target/scala-*/jars/spark-hive_*-*.jar"
96+
if not found_file(pattern):
97+
raise Exception(
98+
("Failed to find Hive assembly jar. ") +
99+
"You need to build Spark with "
100+
"'build/sbt -Phive package' or "
101+
"'build/mvn -DskipTests -Phive package' before running this test.")
102+
103+
104+
def search_test_udf_classes():
105+
pattern = "sql/core/target/scala-*/test-classes/" + \
106+
"test/org/apache/spark/sql/JavaStringLength.class"
107+
if not found_file(pattern):
108+
raise Exception(
109+
("Failed to find test udf classes. ") +
110+
"You need to build Spark with 'build/sbt sql/test:compile'")
111+
112+
87113
class UTCOffsetTimezone(datetime.tzinfo):
88114
"""
89115
Specifies timezone in UTC offset
@@ -5205,6 +5231,8 @@ def test_invalid_args(self):
52055231

52065232
if __name__ == "__main__":
52075233
from pyspark.sql.tests import *
5234+
search_hive_assembly_jars()
5235+
search_test_udf_classes()
52085236
if xmlrunner:
52095237
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='target/test-reports'))
52105238
else:

0 commit comments

Comments
 (0)