You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (JIRA)" <ji...@apache.org> on 2019/05/21 04:01:12 UTC

[jira] [Updated] (SPARK-23479) struct() cannot be combined with alias(metadata={})

     [ https://issues.apache.org/jira/browse/SPARK-23479?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hyukjin Kwon updated SPARK-23479:
---------------------------------
    Labels: bulk-closed  (was: )

> struct() cannot be combined with alias(metadata={})
> ---------------------------------------------------
>
>                 Key: SPARK-23479
>                 URL: https://issues.apache.org/jira/browse/SPARK-23479
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.2.1
>            Reporter: Tomasz Bartczak
>            Priority: Minor
>              Labels: bulk-closed
>
> when creating a struct with 'struct()' function - metadata added with alias() is lost:
> {code:java}
> df =spark.createDataFrame([{'a':1}])
> df.select(struct(col('a').alias('a',metadata={'description':'xxx'}))).schema.fields[0].dataType.fields[0].metadata{code}
> gives:
> {code:java}
> {}{code}
> workaround is to create the column with metadata before adding it to the struct, but this is obviously bad behaviour:
> {code:java}
> df =spark.createDataFrame([{'a':1}])
> df.select(col('a').alias('a',metadata={'description':'xxx'})).select(struct('a')).schema.fields[0].dataType.fields[0].metadata{code}
> keeps metadata:
> {code:java}
> {'description': 'xxx'}{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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