Anshul Baliga created SPARK-62073:
-------------------------------------
Summary: Fix ClassCastException in classic randomSplit with int
weights
Key: SPARK-62073
URL: https://issues.apache.org/jira/browse/SPARK-62073
Project: Spark
Issue Type: Bug
Components: PySpark
Affects Versions: 4.4.0, 4.5.0
Reporter: Anshul Baliga
Classic {{DataFrame.randomSplit}} passes the weights through {{_to_list}} to a
JVM method that takes a list of {{{}Double{}}}. A Python {{int}} in the list
reaches the JVM as a {{{}java.lang.Integer{}}}, which cannot be cast to
{{{}Double{}}}:
{code:java}
>>> spark.range(10).randomSplit([1, 2], 24)
py4j.protocol.Py4JJavaError: ... java.lang.ClassCastException: class
java.lang.Integer cannot be cast to class java.lang.Double{code}
The signature is {{{}weights: List[float]{}}}, which accepts ints, and the
Spark Connect implementation already does. SPARK-61464 fixed the same problem
for {{{}approxQuantile{}}}. Fix: convert the weights to {{float}} before
calling the JVM.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]