Skip to content

Instantly share code, notes, and snippets.

@BigAN
Created October 25, 2018 11:44
Show Gist options
  • Save BigAN/d7dc55596b20f310f5643de9d33d0d0f to your computer and use it in GitHub Desktop.
Save BigAN/d7dc55596b20f310f5643de9d33d0d0f to your computer and use it in GitHub Desktop.
3
down vote
accepted
This is what you could do, split the string with pipe and explode the data using spark function
import org.apache.spark.sql.functions._
import spark.implicits._
val df = Seq(("a1", "b1", "c1|c2|c3|c4")).toDF("A", "B", "C")
df.withColumn("C", explode(split($"C", "\\|"))).show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment