How many max columns does case class support in scala 2.10


#1

How many columns does case class support in scala 2.10

what if we have more than 50 columns , how to deal with all columns to convert to DF


Prepare for certifications on our state of the art labs which have Hadoop, Spark, Kafka, Hive and other Big Data technologies

  • Click here for signing up for our state of the art 13 node Hadoop and Spark Cluster


#2

Not more than 22 columns since the Tuples can’t be not more than 22 in scala 2.10 Version.
One way is go for typical Scala class& Object and refer it spark.sparkContext().textFile().map()

or use structField

But it appears that Scala 2.11 allows the following
case class gt50columns(var col1:String=null,
var col2:String=null,
var col3:String=null,
var col4:String=null,
var col5:String=null,
var col6:String=null,
var col7:String=null,
var col8:String=null,
var col9:String=null,
var col10:String=null,
var col11:String=null,
var col12:String=null,
var col13:String=null,
var col14:String=null,
var col15:String=null,
var col16:String=null,
var col17:String=null,
var col18:String=null,
var col19:String=null,
var col20:String=null,
var col21:String=null,
var col22:String=null,
var col23:String=null,
var col24:String=null,
var col25:String=null,
var col26:String=null,
var col27:String=null,
var col28:String=null,
var col29:String=null,
var col30:String=null,
var col31:String=null,
var col32:String=null,
var col33:String=null,
var col34:String=null,
var col35:String=null,
var col36:String=null,
var col37:String=null,
var col38:String=null,
var col39:String=null,
var col40:String=null,
var col41:String=null,
var col42:String=null,
var col43:String=null,
var col44:String=null,
var col45:String=null,
var col46:String=null,
var col47:String=null,
var col48:String=null,
var col49:String=null,
var col50:String=null,
var col51:String=null,
var col52:String=null,
var col53:String=null,
var col54:String=null,
var col55:String=null,
var col56:String=null,
var col57:String=null,
var col58:String=null,
var col59:String=null,
var col60:String=null,
var col61:String=null,
var col62:String=null,
var col63:String=null,
var col64:String=null,
var col65:String=null,
var col66:String=null,
var col67:String=null,
var col68:String=null,
var col69:String=null,
var col70:String=null,
var col71:String=null,
var col72:String=null,
var col73:String=null,
var col74:String=null,
var col75:String=null,
var col76:String=null,
var col77:String=null,
var col78:String=null,
var col79:String=null,
var col80:String=null
)
scala> val x = new gt50columns()
x: gt50columns = gt50columns(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null)

scala> val y = new gt50columns(“Hello”,“How”,“Are”,“You”)
y: gt50columns = gt50columns(Hello,How,Are,You,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null)


#3

Thank You for the response