Need help on how to Compress file in Spark

Hi All,

I am having difficulty in applying compression technique.
val dataRDD = sc.textFile("/user/cloudera/sqoop_import/departments")
dataRDD.saveAsTextFile("/user/cloudera/compression/depatcomp",classOf[org.apache.hadoop.io.compress.SnappyCodec]);

I think I am doing something wrong. Please help me.