You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Ruifeng Zheng (Jira)" <ji...@apache.org> on 2023/01/04 07:17:00 UTC
[jira] [Created] (SPARK-41880) Function `from_json` should support non-literal expression
Ruifeng Zheng created SPARK-41880:
-------------------------------------
Summary: Function `from_json` should support non-literal expression
Key: SPARK-41880
URL: https://issues.apache.org/jira/browse/SPARK-41880
Project: Spark
Issue Type: Sub-task
Components: Connect, PySpark
Affects Versions: 3.4.0
Reporter: Ruifeng Zheng
{code:java}
File "/Users/ruifeng.zheng/Dev/spark/python/pyspark/sql/connect/functions.py", line 1351, in pyspark.sql.connect.functions.from_json
Failed example:
df.select(from_json(df.value, schema).alias("json")).collect()
Exception raised:
Traceback (most recent call last):
File "/Users/ruifeng.zheng/.dev/miniconda3/envs/spark_dev/lib/python3.9/doctest.py", line 1334, in __run
exec(compile(example.source, filename, "single",
File "<doctest pyspark.sql.connect.functions.from_json[12]>", line 1, in <module>
df.select(from_json(df.value, schema).alias("json")).collect()
File "/Users/ruifeng.zheng/Dev/spark/python/pyspark/sql/connect/dataframe.py", line 1019, in collect
pdf = self.toPandas()
File "/Users/ruifeng.zheng/Dev/spark/python/pyspark/sql/connect/dataframe.py", line 1054, in toPandas
return self._session.client.to_pandas(query)
File "/Users/ruifeng.zheng/Dev/spark/python/pyspark/sql/connect/client.py", line 413, in to_pandas
return self._execute_and_fetch(req)
File "/Users/ruifeng.zheng/Dev/spark/python/pyspark/sql/connect/client.py", line 573, in _execute_and_fetch
self._handle_error(rpc_error)
File "/Users/ruifeng.zheng/Dev/spark/python/pyspark/sql/connect/client.py", line 625, in _handle_error
raise SparkConnectException(status.message) from None
pyspark.sql.connect.client.SparkConnectException: Schema in from_json should be literal string, but got 'schema_of_json({"a": 0})
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org