MaxGekk commented on PR #44665:
URL: https://github.com/apache/spark/pull/44665#issuecomment-2009888375
> You never know how people will use Spark and I'm not sure why it's
necessary to ban this use case.
I believe it is not too bad to ban such output in any case (this is even
insecure). @cloud-fan Do you see any use-case for that?
Array:
```scala
val valueSchema = StructType(Seq(StructField("age", LongType),
StructField("name", StringType), StructField("scores", ArrayType(LongType))))
val schema = StructType(Seq(StructField("key", LongType),
StructField("value", valueSchema)))
val df = spark.createDataFrame(rows, schema)
df.select(to_csv($"value")).show(false)
+--------------------------------------------------------------------------+
|to_csv(value) |
+--------------------------------------------------------------------------+
|2,Alice,org.apache.spark.sql.catalyst.expressions.UnsafeArrayData@e7bb2e54|
+--------------------------------------------------------------------------+
```
Map:
```scala
+------------------------------------------------------------------------+
|to_csv(value) |
+------------------------------------------------------------------------+
|2,Alice,org.apache.spark.sql.catalyst.expressions.UnsafeMapData@65ab9790|
+------------------------------------------------------------------------+
```
Struct:
```scala
val rows = new java.util.ArrayList[Row]()
rows.add(Row(1L, Row(2L, "Alice", Row(100L, 200L, null))))
val valueSchema = StructType(Seq(StructField("age", LongType),
StructField("name", StringType), StructField("scores",
StructType(Seq(StructField("id1", LongType), StructField("id2", LongType),
StructField("id3", LongType))))))
val schema = StructType(Seq(StructField("key", LongType),
StructField("value", valueSchema)))
val df = spark.createDataFrame(rows, schema)
+---------------------+
|to_csv(value) |
+---------------------+
|2,Alice,"[4,64,c8,0]"|
+---------------------+
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]