[
https://issues.apache.org/jira/browse/SPARK-61290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tim Meehan updated SPARK-61290:
-------------------------------
Fix Version/s: connect-rust-4.3.0
> Raise CANNOT_INFER_ARRAY_ELEMENT_TYPE for a list without an element type in
> the Column methods of the Python client, as PySpark does
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: SPARK-61290
> URL: https://issues.apache.org/jira/browse/SPARK-61290
> Project: Spark
> Issue Type: Bug
> Components: Connect
> Affects Versions: connect-rust-4.3.0
> Reporter: Tim Meehan
> Priority: Major
> Fix For: connect-rust-4.3.0
>
>
> PySpark's Column methods, such as when, otherwise and isin, send a Python
> list as an array literal whose element type they infer, and raise
> CANNOT_INFER_ARRAY_ELEMENT_TYPE for an empty list or one that starts with
> None (pyspark/sql/connect/expressions.py:368). In the Python client of
> spark-connect-rust, such a list becomes array(...) of its elements, so these
> lists are accepted.
> {code:python}
> from pyspark.sql import SparkSession, functions as F
> spark = SparkSession.builder.remote("sc://localhost:15002").getOrCreate()
> spark.range(2).select(F.when(F.col("id") > 0,
> F.array(F.lit(1))).otherwise([]).alias("o")).collect()
> {code}
> Against an OSS Spark 4.3.0 Connect server on loopback:
> * pyspark-client 4.3.0: PySparkTypeError: \[CANNOT_INFER_ARRAY_ELEMENT_TYPE\]
> Can not infer the element data type, a non-empty list starting with a
> non-None value is required. otherwise(\[None, 2\]) raises the same.
> * spark-connect-rust master 8768cc4: \[Row(o=\[\]), Row(o=\[1\])\], and with
> otherwise(\[None, 2\]), \[Row(o=\[None, 2\]), Row(o=\[1\])\].
> From source: to_column (crates/pyspark-rs/src/functions.rs:224) sends every
> list through pyspark.sql.functions.lit (:239-247), which builds array(...).
> That is right for PySpark's functions: F.when(F.lit(True), \[\]) returns
> \[Row(w=\[\])\] in both clients.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]