You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2024/02/04 06:15:56 UTC

Re: [PR] [SPARK-46654][SQL] Make to_csv can correctly display complex types data [spark]

LuciferYang commented on PR #44665:
URL: https://github.com/apache/spark/pull/44665#issuecomment-1925595731

   I think the current issue is that the original PySpark can display complex struct types, 
   
   ```
   bin/pyspark
   Python 3.11.1 (v3.11.1:a7a450f84a, Dec  6 2022, 15:24:06) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
   Type "help", "copyright", "credits" or "license" for more information.
   Setting default log level to "WARN".
   To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
   24/02/04 14:14:41 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
   24/02/04 14:14:41 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.
   Welcome to
         ____              __
        / __/__  ___ _____/ /__
       _\ \/ _ \/ _ `/ __/  '_/
      /__ / .__/\_,_/_/ /_/\_\   version 4.0.0-SNAPSHOT
         /_/
   
   Using Python version 3.11.1 (v3.11.1:a7a450f84a, Dec  6 2022 15:24:06)
   Spark context Web UI available at http://localhost:4041
   Spark context available as 'sc' (master = local[*], app id = local-1707027281550).
   SparkSession available as 'spark'.
   >>> from pyspark.sql import Row, functions as sf
   >>> data = [(1, Row(age=2, name='Alice', scores=[100, 200, 300]))]
   >>> df = spark.createDataFrame(data, ("key", "value"))
   >>> df.select(sf.to_csv(df.value)).show(truncate=False)
   +-----------------------+                                                       
   |to_csv(value)          |
   +-----------------------+
   |2,Alice,"[100,200,300]"|
   +-----------------------+
   ```
   
   but PyConnect and Scala code cannot. Ultimately, we should make them consistent. Should we consider removing the current capability of PySpark? However, this might be a breaking change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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