viirya commented on a change in pull request #24945:
[SPARK-27893][SQL][PYTHON][FOLLOW-UP] Allow Scalar Pandas and Python UDFs can
be tested with Scala test base
URL: https://github.com/apache/spark/pull/24945#discussion_r296984408
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/IntegratedUDFTestUtils.scala
##########
@@ -40,32 +40,37 @@ import org.apache.spark.sql.types.StringType
*
* To register Scala UDF in SQL:
* {{{
- * registerTestUDF(TestScalaUDF(name = "udf_name"), spark)
+ * val scalaTestUDF = TestScalaUDF(name = "udf_name")
+ * registerTestUDF(scalaTestUDF, spark)
* }}}
*
* To register Python UDF in SQL:
* {{{
- * registerTestUDF(TestPythonUDF(name = "udf_name"), spark)
+ * val pythonTestUDF = TestScalaUDF(name = "udf_name")
+ * registerTestUDF(pythonTestUDF, spark)
* }}}
*
* To register Scalar Pandas UDF in SQL:
* {{{
- * registerTestUDF(TestScalarPandasUDF(name = "udf_name"), spark)
+ * val pandasTestUDF = TestScalaUDF(name = "udf_name")
+ * registerTestUDF(pandasTestUDF, spark)
* }}}
*
* To use it in Scala API and SQL:
* {{{
* sql("SELECT udf_name(1)")
- * spark.select(expr("udf_name(1)")
+ * spark.range(10).select(expr("udf_name(id)")
+ * spark.range(10).select(pandasTestUDF($"id"))
* }}}
*/
object IntegratedUDFTestUtils extends SQLHelper {
import scala.sys.process._
private lazy val pythonPath = sys.env.getOrElse("PYTHONPATH", "")
private lazy val sparkHome = if (sys.props.contains(Tests.IS_TESTING.key)) {
- assert(sys.props.contains("spark.test.home"), "spark.test.home is not
set.")
- sys.props("spark.test.home")
+ assert(sys.props.contains("spark.test.home") ||
+ sys.env.contains("SPARK_HOME"), "spark.test.home or SPARK_HOME is not
set.")
+ sys.props.getOrElse("spark.test.home", sys.env("SPARK_HOME"))
Review comment:
Should we add a comment for this reason?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]