You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (JIRA)" <ji...@apache.org> on 2018/09/04 17:06:28 UTC
[jira] [Commented] (SPARK-25333) Ability to add new columns in the
beginning of a Dataset
[ https://issues.apache.org/jira/browse/SPARK-25333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16603329#comment-16603329 ]
Apache Spark commented on SPARK-25333:
--------------------------------------
User 'wmellouli' has created a pull request for this issue:
https://github.com/apache/spark/pull/22332
> Ability to add new columns in the beginning of a Dataset
> --------------------------------------------------------
>
> Key: SPARK-25333
> URL: https://issues.apache.org/jira/browse/SPARK-25333
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 2.4.0
> Reporter: Walid Mellouli
> Priority: Minor
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> When we add new columns in a Dataset, they are added automatically at the end of the Dataset.
> {code:java}
> val df = sc.parallelize(Seq(1, 2, 3)).toDF
> df.printSchema
> root
> |-- value: integer (nullable = true)
> {code}
> When we add a new column:
> {code:java}
> val newDf = df.withColumn("newColumn", col("value") + 1)
> newDf.printSchema
> root
> |-- value: integer (nullable = true)
> |-- newColumn: integer (nullable = true)
> {code}
> Generally users want to add new columns either at the end or in the beginning, depends on use cases.
> In my case for example, we add technical columns in the beginning of a Dataset and we add business columns at the end.
--
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