use of com.epam.parso.ColumnFormat in project drill by apache.
the class SasBatchReader method buildSchema.
private TupleMetadata buildSchema() {
SchemaBuilder builder = new SchemaBuilder();
List<Column> columns = sasFileReader.getColumns();
for (Column column : columns) {
String columnName = column.getName();
String columnType = column.getType().getSimpleName();
ColumnFormat columnFormat = column.getFormat();
try {
MinorType type = null;
if (DateTimeConstants.TIME_FORMAT_STRINGS.contains(columnFormat.getName())) {
type = MinorType.TIME;
} else if (DateTimeConstants.DATE_FORMAT_STRINGS.containsKey(columnFormat.getName())) {
type = MinorType.DATE;
} else if (DateTimeConstants.DATETIME_FORMAT_STRINGS.containsKey(columnFormat.getName())) {
type = MinorType.TIMESTAMP;
} else {
type = getType(columnType);
}
builder.addNullable(columnName, type);
} catch (Exception e) {
throw UserException.dataReadError().message("Error with type of column " + columnName + "; Type: " + columnType).addContext(errorContext).build(logger);
}
}
return builder.buildSchema();
}
Aggregations