In the context of feature engineering using Spark ML, explain the process of handling categorical features and encoding them for use in machine learning models. Provide a code snippet demonstrating the encoding of categorical features using Spark ML transformers.