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

Column.__repr__ shouldn't encode JVM response

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.1.0
    • None
    • PySpark, SQL
    • None

    Description

      At the moment PySpark Column encodes JVM response in _repr_ method.

      As a result, column names using only ASCII characters get b prefix

      >>> from pyspark.sql.functions import col                                                                                                                                                
      >>> col("abc")                                                                                                                                                                           
      Column<b'abc'>
      

      and the others ugly byte string

      >>> col("wąż")                                                                                                                                                                           
      Column<b'w\xc4\x85\xc5\xbc'>
      

      This behaviour is inconsistent with other parts of the API, for example:

      >>> spark.createDataFrame([], "`wąż` long")                                                                                                                                              
      DataFrame[wąż: bigint]
      

      and Scala

      scala> col("wąż")
      res0: org.apache.spark.sql.Column = wąż
      

      and R

      > column("wąż")
      Column wąż 
      

      Encoding has been originally introduced with SPARK-5859, but it doesn't seem like it is really required.

      Desired behaviour

      >>> col("wąż")                                                                                                                                                                           
      Column<'wąż'>
      

      or

      >>> col("wąż")                                                                                                                                                                           
      Column<wąż>
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            zero323 Maciej Szymkiewicz
            zero323 Maciej Szymkiewicz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment