Github user maropu commented on the issue:
https://github.com/apache/spark/pull/21215
Like this?
```
scala> val structTy = StructType.fromDDL("a ARRAY<STRUCT<b: INT, c:
STRING>>")
structTy: org.apache.spark.sql.types.StructType =
StructType(StructField(a,ArrayType(StructType(StructField(b,IntegerType,true),
StructField(c,StringType,true)),true),true))
scala> val newCol = new Column(Literal.create(Seq.empty[Inner],
structTy.head.dataType))
newCol: org.apache.spark.sql.Column = []
scala> val df = Seq(1, 2, 3).toDF("a").withColumn("b", newCol)
df: org.apache.spark.sql.DataFrame = [a: int, b:
array<struct<b:int,c:string>>]
scala> df.show
+---+---+
| a| b|
+---+---+
| 1| []|
| 2| []|
| 3| []|
+---+---+
scala> df.printSchema
root
|-- a: integer (nullable = false)
|-- b: array (nullable = false)
| |-- element: struct (containsNull = true)
| | |-- b: integer (nullable = true)
| | |-- c: string (nullable = true)
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]