You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Felix Altenberg (Jira)" <ji...@apache.org> on 2022/04/29 11:40:00 UTC

[jira] [Created] (SPARK-39070) Pivoting a dataframe after two explodes raises an org.codehaus.commons.compiler.CompileException

Felix Altenberg created SPARK-39070:
---------------------------------------

             Summary: Pivoting a dataframe after two explodes raises an org.codehaus.commons.compiler.CompileException
                 Key: SPARK-39070
                 URL: https://issues.apache.org/jira/browse/SPARK-39070
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.2.1, 3.2.0
         Environment: Tested on:
MacOS 12.3.1, python versions 3.8.10, 3.9.12
Ubuntu 20.04, python version 3.8.10

Tested spark versions 3.2.1 and 3.2.0 installed through conda and pip
            Reporter: Felix Altenberg


The following Code raises an exception starting in spark version 3.2.0
{code:java}
import pyspark.sql.functions as sf
from pyspark.sql import Row
data = [
    Row(
        other_value=10,
        ships=[
            Row(
                fields=[
                    Row(name="field1", value=1),
                    Row(name="field2", value=2),
                ]
            ),
            Row(
                fields=[
                    Row(name="field1", value=3),
                    Row(name="field3", value=4),
                ]
            ),
        ],
    )
]

df = spark.createDataFrame(data)
df = df.withColumn("ships", sf.explode("ships")).select(
    sf.col("other_value"), sf.col("ships.*")
)
df = df.withColumn("fields", sf.explode("fields")).select("other_value", "fields.*")
df = df.groupBy("other_value").pivot("name") #ERROR THROWN HERE {code}
The "pivot("name")" is what causes the error to be thrown.

I'll try to attach the full error message.



 



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org