Skip to content

Conversation

@cryeo
Copy link
Contributor

@cryeo cryeo commented Sep 29, 2018

What changes were proposed in this pull request?

Add withColumnsRenamed method to rename multiple columns at a time as follows.

// before
ds.withColumnRenamed("first_name", "firstName")
  .withColumnRenamed("last_name", "lastName")
  .withColumnRenamed("postal_code", "postalCode")

// after
ds.withColumnsRenamed(
  "first_name" -> "firstName",
  "last_name" -> "lastName",
  "postal_code" -> "postalCode"
)
// or
ds.withColumnsRenamed(Map(
  "first_name" -> "firstName",
  "last_name" -> "lastName",
  "postal_code" -> "postalCode"
))

How was this patch tested?

This patch is tested by unit test.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

* @group untypedrel
* @since 3.0.0
*/
def withColumnsRenamed(columnMap: Map[String, String]): DataFrame = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HyukjinKwon
Copy link
Member

// before
ds.withColumnRenamed("first_name", "firstName")
  .withColumnRenamed("last_name", "lastName")
  .withColumnRenamed("postal_code", "postalCode")

// after
ds.withColumnsRenamed(
  "first_name" -> "firstName",
  "last_name" -> "lastName",
  "postal_code" -> "postalCode"
)
// or
ds.withColumnsRenamed(Map(
  "first_name" -> "firstName",
  "last_name" -> "lastName",
  "postal_code" -> "postalCode"
))

This doesn't looks useful or making the codes even shorter. I don't think we should add this.

@HyukjinKwon
Copy link
Member

Please take a look for PRs or JIRAs before creating them. It's an exact duplicate of SPARK-25430.

@wangyum wangyum mentioned this pull request Nov 3, 2018
@asfgit asfgit closed this in 463a676 Nov 4, 2018
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 22, 2025
Closes apache#22859
Closes apache#22849
Closes apache#22591
Closes apache#22322
Closes apache#22312
Closes apache#19590

Closes apache#22934 from wangyum/CloseStalePRs.

Authored-by: Yuming Wang <[email protected]>
Signed-off-by: hyukjinkwon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants