I have a Array of String {"StringType", IntegerType, "LongType", "StringType"} in scala.
And i need to covert each String to spark.sql.types object while iterating
for example:
StringType = spark.sql.types.StringType
IntegerType = spark.sql.types.IntegerType
LongType = spark.sql.types.LongType.
One solution is to create 1 to 1 HashMap of String and spark.sql.types and use it while iterating the array. Is there any other cleaner way to do this?
I would probably just use scala pattern matching. Like: