Given this, seem have done this in the past ok, but...:
val arrayStructData2 = Seq(
Row("James", 2),
Row("Alex", 3)
)
val arrayStructSchema2 = new StructType()
.add("names",new StructType()
.add("name", StringType)
.add("extraField", IntegerType)
)
val df = spark.createDataFrame(spark.sparkContext.parallelize(arrayStructData2),arrayStructSchema2)
df.printSchema()
df.show()
I get this:
...
Caused by: RuntimeException: java.lang.String is not a valid external type for schema of struct<name:string,extraField:int>
Can't see it immediately.