You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Sean Owen (JIRA)" <ji...@apache.org> on 2017/07/31 09:13:00 UTC

[jira] [Commented] (SPARK-21582) DataFrame.withColumnRenamed cause huge performance overhead

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

Sean Owen commented on SPARK-21582:
-----------------------------------

This is a really slow way to rename the columns. I think you want to just set the schema manually? or pass the col names in a call to toDF()? you have a chain of 900 operations here.

> DataFrame.withColumnRenamed cause huge performance overhead
> -----------------------------------------------------------
>
>                 Key: SPARK-21582
>                 URL: https://issues.apache.org/jira/browse/SPARK-21582
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 2.1.0
>            Reporter: GuangFancui(ISCAS)
>         Attachments: 4654.stack
>
>
> Table "item_feature" (DataFrame) has over 900 columns. 
> When I use
> {code:java}
> val nameSequeceExcept = Set("gid","category_name","merchant_id")
> val df1 = spark.table("item_feature")
> val newdf1 = df1.schema.map(_.name).filter(name => !nameSequeceExcept.contains(name)).foldLeft(df1)((df1, name) => df1.withColumnRenamed(name, name + "_1" ))
> {code}
> It took over 30 minutes.
> *PID* in stack file is *0x126d*
> It seems that _transform_ took too long time.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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