Github user hhbyyh commented on a diff in the pull request: https://github.com/apache/spark/pull/19993#discussion_r158170154 --- Diff: mllib/src/test/scala/org/apache/spark/ml/param/ParamsSuite.scala --- @@ -430,4 +433,49 @@ object ParamsSuite extends SparkFunSuite { require(copyReturnType === obj.getClass, s"${clazz.getName}.copy should return ${clazz.getName} instead of ${copyReturnType.getName}.") } + + /** + * Checks that the class throws an exception in case both `inputCols` and `inputCol` are set and + * in case both `outputCols` and `outputCol` are set. + * These checks are performed only whether the class extends respectively both `HasInputCols` and + * `HasInputCol` and both `HasOutputCols` and `HasOutputCol`. + * + * @param paramsClass The Class to be checked + * @param spark A `SparkSession` instance to use + */ + def checkMultiColumnParams(paramsClass: Class[_ <: Params], spark: SparkSession): Unit = { + import spark.implicits._ + // create fake input Dataset + val feature1 = Array(-1.0, 0.0, 1.0) + val feature2 = Array(1.0, 0.0, -1.0) + val df = feature1.zip(feature2).toSeq.toDF("feature1", "feature2") --- End diff -- Send column names as parameter if necessary. We need to ensure the test utility can be used by most transformers with multiple column support. > I think that the type check is performed later, thus it is not a problem here. I don't quite get it, in either `transform` or `fit` the data type will be checked and they will trigger exceptions. > I preferred to use paramsClass: Class[_ <: Params] I'm only thinking about the case that default constructor is not sufficient to create a working Estimator/Transformer. If that's not a concern, then reflection is OK.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org