in paimon-format/src/main/java/org/apache/paimon/format/orc/reader/OrcSplitReaderUtil.java [35:97]
public static TypeDescription toOrcType(DataType type) {
type = type.copy(true);
switch (type.getTypeRoot()) {
case CHAR:
return TypeDescription.createChar().withMaxLength(((CharType) type).getLength());
case VARCHAR:
int len = ((VarCharType) type).getLength();
if (len == VarCharType.MAX_LENGTH) {
return TypeDescription.createString();
} else {
return TypeDescription.createVarchar().withMaxLength(len);
}
case BOOLEAN:
return TypeDescription.createBoolean();
case VARBINARY:
if (type.equals(DataTypes.BYTES())) {
return TypeDescription.createBinary();
} else {
throw new UnsupportedOperationException(
"Not support other binary type: " + type);
}
case DECIMAL:
DecimalType decimalType = (DecimalType) type;
return TypeDescription.createDecimal()
.withScale(decimalType.getScale())
.withPrecision(decimalType.getPrecision());
case TINYINT:
return TypeDescription.createByte();
case SMALLINT:
return TypeDescription.createShort();
case INTEGER:
case TIME_WITHOUT_TIME_ZONE:
return TypeDescription.createInt();
case BIGINT:
return TypeDescription.createLong();
case FLOAT:
return TypeDescription.createFloat();
case DOUBLE:
return TypeDescription.createDouble();
case DATE:
return TypeDescription.createDate();
case TIMESTAMP_WITHOUT_TIME_ZONE:
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
return TypeDescription.createTimestamp();
case ARRAY:
ArrayType arrayType = (ArrayType) type;
return TypeDescription.createList(toOrcType(arrayType.getElementType()));
case MAP:
MapType mapType = (MapType) type;
return TypeDescription.createMap(
toOrcType(mapType.getKeyType()), toOrcType(mapType.getValueType()));
case ROW:
RowType rowType = (RowType) type;
TypeDescription struct = TypeDescription.createStruct();
for (int i = 0; i < rowType.getFieldCount(); i++) {
struct.addField(
rowType.getFieldNames().get(i), toOrcType(rowType.getTypeAt(i)));
}
return struct;
default:
throw new UnsupportedOperationException("Unsupported type: " + type);
}
}