You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Adam Binford (Jira)" <ji...@apache.org> on 2021/05/04 12:57:00 UTC

[jira] [Commented] (SPARK-35309) array transform should respect alias in expression

    [ https://issues.apache.org/jira/browse/SPARK-35309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17338966#comment-17338966 ] 

Adam Binford commented on SPARK-35309:
--------------------------------------

You want "x" to be "struct_alias"? That should be
{code:java}
struct(col.alias("struct_alias")){code}

> array transform should respect alias in expression
> --------------------------------------------------
>
>                 Key: SPARK-35309
>                 URL: https://issues.apache.org/jira/browse/SPARK-35309
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.1.0
>            Reporter: Derk Crezee
>            Priority: Major
>
> When an array is transformed using the transform function in combination with an alias, I get an unexpected column name.
> {code:scala}
> // code placeholder
> val data = Seq((Array(1, 2, 3)))
> val df = sc.parallelize(data).toDF("a")
> val dfRes = df.select(
>   transform(
>     $"a",
>     (col: Column) => struct(col).alias("struct_alias")
>   ).alias("a")
> )
> dfRes.printSchema
> // root
> //  |-- a: array (nullable = true)
> //  |    |-- element: struct (containsNull = false)
> //  |    |    |-- x: integer (nullable = false)
> {code}
> I expected the inner element to have the name 'struct_alias'.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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