Commit 0782024
[SPARK-37026][ML][BUILD] Ensure the element type of
### 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 apache#34301 from sarutak/fix-rformula-scala-2.13.
Authored-by: Kousuke Saruta <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>ResolvedRFormula.terms is scala.Seq for Scala 2.131 parent f9cc7fb commit 0782024
File tree
2 files changed
+12
-1
lines changed- mllib/src
- main/scala/org/apache/spark/ml/feature
- test/scala/org/apache/spark/ml/feature
2 files changed
+12
-1
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
| 452 | + | |
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
630 | 641 | | |
0 commit comments