Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SCALA

dataframe column json parser spark scala

import org.apache.spark.sql.functions.{lit, schema_of_json, from_json}
import collection.JavaConverters._

val schema = schema_of_json(lit(df.select($"jsonData").as[String].first))
df.withColumn("jsonData", from_json($"jsonData", schema, Map[String, String]().asJava))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dataframe #column #json #parser #spark #scala
ADD COMMENT
Topic
Name
8+2 =