I would like my program to write output files either in csv or parquet format and the decision to use either of the format should be controlled via a configuration.
I could use something like this below.
// I would probably read opType via a JSON or XML.
val opType = "csv"
// Write output based on appropriate opType
optype match {
case "csv" =>
df.write.csv("/some/output/location")
case "parquet" =>
df.write.parquet("/some/output/location")
case _ =>
df.write.csv("/some/output/location/")
}
Question: Is there a better way to handle this scenario? Is there anyway I could use the string value of opType to call the appropriate function call whether parquet or csv ?
Any help or pointers are appreciated.