Reputation: 72
with case class we have some restrictions... with StructType is it possible to for 100+ columns, Is there any other way to create scheme for around 600+ columns.
Upvotes: 1
Views: 731
Reputation: 7207
val columns = (1 to 600).map(i => s"Column_$i").map(cname => StructField(cname, StringType))
val schemaWithSixHundredsColumns = StructType(columns)
val df = spark.createDataFrame(new java.util.ArrayList[Row](), schemaWithSixHundredsColumns)
Upvotes: 3