Using this below code I'm able to compress and save it as .gz file
import spark.implicits._
val someDF = Seq(
(8, "bat"),
(64, "mouse"),
(-27, "horse")
).toDF("number", "word")
someDF.coalesce(1)
.write.format("com.databricks.spark.csv")
.option("header", "true")
.option("codec", "org.apache.hadoop.io.compress.GzipCodec")
.save("example.csv.gz")
Does spark provides an option to compress data with password protected ? I couldn't able to find in the spark documentation.