Changes

Summary

  1. [SPARK-37026][ML][BUILD] Ensure the element type of (details)
Commit 0782024045a3f024168686fff2fa8d04a399de6d by gurwls223
[SPARK-37026][ML][BUILD] Ensure the element type of `ResolvedRFormula.terms` is scala.Seq for Scala 2.13

### What changes were proposed in this pull request?

This PR fixes the issue that `scala.Seq[scala.collection.mutable.ArraySeq$ofRef]` will be passed to `ResolvedRFormula.terms` though it expects `scala.Seq[scala.Seq[String]]` with Scala 2.13.
As of Scala 2.13, `scala.Seq` is `scala.collection.immutable.Seq`, so this issue happens.

### Why are the changes needed?

Bug fix.
Due to this issue, `ResolvedRFormula.toString` throws `ClassCastException`.
```
java.lang.ClassCastException: scala.collection.mutable.ArraySeq$ofRef cannot be cast to scala.collection.immutable.Seq
        at scala.collection.immutable.List.map(List.scala:246)
        at scala.collection.immutable.List.map(List.scala:79)
        at org.apache.spark.ml.feature.ResolvedRFormula.toString(RFormulaParser.scala:143)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:282)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.ClientServerConnection.waitForCommands(ClientServerConnection.java:182)
        at py4j.ClientServerConnection.run(ClientServerConnection.java:106)
        at java.lang.Thread.run(Thread.java:748)
```

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

New test is added and `build/sbt -Pscala-2.13 "testOnly org.apache.spark.ml.feature.RFormulaSuite"` passes.
CIs should ensure that this change works with Scala 2.12 too.

Closes #34301 from sarutak/fix-rformula-scala-2.13.

Authored-by: Kousuke Saruta <sarutak@oss.nttdata.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
The file was modifiedmllib/src/test/scala/org/apache/spark/ml/feature/RFormulaSuite.scala (diff)
The file was modifiedmllib/src/main/scala/org/apache/spark/ml/feature/RFormula.scala (diff)