use of io.trino.plugin.hive.HiveStorageFormat in project trino by trinodb.
the class HiveUtil method getInputFormat.
public static InputFormat<?, ?> getInputFormat(Configuration configuration, Properties schema, boolean symlinkTarget) {
String inputFormatName = getInputFormatName(schema);
try {
JobConf jobConf = toJobConf(configuration);
configureCompressionCodecs(jobConf);
Class<? extends InputFormat<?, ?>> inputFormatClass = getInputFormatClass(jobConf, inputFormatName);
if (symlinkTarget && inputFormatClass == SymlinkTextInputFormat.class) {
String serde = getDeserializerClassName(schema);
// per Hive spec (https://hive.apache.org/javadocs/r2.1.1/api/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.html)
if (serde.equals(TEXTFILE.getSerde())) {
inputFormatClass = getInputFormatClass(jobConf, TEXTFILE.getInputFormat());
return ReflectionUtils.newInstance(inputFormatClass, jobConf);
}
for (HiveStorageFormat format : HiveStorageFormat.values()) {
if (serde.equals(format.getSerde())) {
inputFormatClass = getInputFormatClass(jobConf, format.getInputFormat());
return ReflectionUtils.newInstance(inputFormatClass, jobConf);
}
}
throw new TrinoException(HIVE_UNSUPPORTED_FORMAT, "Unknown SerDe for SymlinkTextInputFormat: " + serde);
}
return ReflectionUtils.newInstance(inputFormatClass, jobConf);
} catch (ClassNotFoundException | RuntimeException e) {
throw new TrinoException(HIVE_UNSUPPORTED_FORMAT, "Unable to create input format " + inputFormatName, e);
}
}
Aggregations