Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-25430

Add map parameter for withColumnRenamed

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 2.3.1
    • None
    • SQL
    • None

    Description

      WithColumnRenamed method should work with map parameter. It removes code redundancy.

      // example
      df.withColumnRenamed(Map( "c1" -> "first_column", "c2" -> "second_column" ))
      // from abbr columns to desc columns
      val m = Map( "c1" -> "first_column", "c2" -> "second_column" )
      df1.withColumnRenamed(m) 
      df2.withColumnRenamed(m)
      

      It is useful for CJK users when they are working on analysis in notebook environment such as Zeppelin, Databricks, Apache Toree. 

      // for CJK users once define dictionary into map, reuse column map to translate columns whenever report visualization is required
      val m = Map( "c1" -> "컬럼_1", "c2" -> "컬럼_2") 
      df1.withColumnRenamed(m) 
      df2.withColumnRenamed(m)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              goun Goun Na
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: