Data preprocessing in Spark