So In Spark you can you OneHotEncoderEstimator to one-hot encode a column like this
OneHotEncoderEstimator
import org.apache.spark.ml.feature.OneHotEncoderEstimator va