MaxGekk commented on a change in pull request #26547: [SPARK-29914][ML] ML 
models attach metadata in `transform`/`transformSchema`
URL: https://github.com/apache/spark/pull/26547#discussion_r355204027
 
 

 ##########
 File path: mllib/src/test/scala/org/apache/spark/ml/util/MLTest.scala
 ##########
 @@ -64,6 +65,38 @@ trait MLTest extends StreamTest with TempDirectory { self: 
Suite =>
     }
   }
 
+  private[ml] def checkVectorSizeOnDF(
+      dataframe: DataFrame,
+      vecColName: String,
+      vecSize: Int): Unit = {
+    import dataframe.sparkSession.implicits._
+    val group = AttributeGroup.fromStructField(dataframe.schema(vecColName))
+    assert(group.size === vecSize,
+      s"the vector size obtained from schema should be $vecSize, but got 
${group.size}")
+    val sizeUDF = udf { vector: Vector => vector.size }
+    assert(dataframe.select(sizeUDF(col(vecColName)))
+      .as[Int]
+      .collect()
+      .forall(_ === vecSize))
+  }
+
+  private[ml] def checkNominalOnDF(
+      dataframe: DataFrame,
+      colName: String,
+      numValues: Int): Unit = {
+    import dataframe.sparkSession.implicits._
+    val n = Attribute.fromStructField(dataframe.schema(colName)) match {
 
 Review comment:
   Scala compiler prints the warning here:
   ```scala
   Warning:(88, 38) match may not be exhaustive.
   It would fail on the following inputs: NumericAttribute(), 
UnresolvedAttribute
       val n = Attribute.fromStructField(dataframe.schema(colName)) match {
   ```
   Just in case, do we cover all cases?

----------------------------------------------------------------
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]

Reply via email to