in src/main/java/com/uber/uberscriptquery/util/SparkUtils.java [41:55]
public static Dataset<Row> loadFile(String inputFormat, String inputPath, SparkSession spark) {
if (inputFormat == null || inputFormat.isEmpty() || inputFormat.equalsIgnoreCase("text")) {
return spark.read().text(inputPath);
} else if (inputFormat.equalsIgnoreCase("parquet")) {
return spark.read().parquet(inputPath);
} else if (inputFormat.equalsIgnoreCase("csv")) {
return spark.read().option("header", "false").csv(inputPath);
} else if (inputFormat.equalsIgnoreCase("csv_with_header")) {
return spark.read().option("header", "true").csv(inputPath);
} else if (inputFormat.equalsIgnoreCase("json")) {
return spark.read().json(inputPath);
} else {
throw new RuntimeException(String.format("Unsupported inputFormat: %s, %s", inputFormat, inputPath));
}
}