in parquet-column/src/main/java/org/apache/parquet/schema/MessageTypeParser.java [167:241]
private static void addPrimitiveType(
Tokenizer st, PrimitiveTypeName type, Repetition r, Types.GroupBuilder<?> builder) {
PrimitiveBuilder<?> childBuilder = builder.primitive(type, r);
String t;
if (type == PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) {
t = st.nextToken();
// Read type length if the type is fixed_len_byte_array.
if (!t.equalsIgnoreCase("(")) {
throw new IllegalArgumentException("expecting (length) for field of type fixed_len_byte_array");
}
childBuilder.length(Integer.parseInt(st.nextToken()));
check(st.nextToken(), ")", "type length ended by )", st);
}
String name = st.nextToken();
// Read annotation, if any.
t = st.nextToken();
OriginalType originalType = null;
if (t.equalsIgnoreCase("(")) {
t = st.nextToken();
if (isLogicalType(t)) {
LogicalTypeAnnotation.LogicalTypeToken logicalType = LogicalTypeAnnotation.LogicalTypeToken.valueOf(t);
t = st.nextToken();
List<String> tokens = new ArrayList<>();
if ("(".equals(t)) {
while (!")".equals(t)) {
if (!(",".equals(t) || "(".equals(t) || ")".equals(t))) {
tokens.add(t);
}
t = st.nextToken();
}
t = st.nextToken();
}
LogicalTypeAnnotation logicalTypeAnnotation = logicalType.fromString(tokens);
childBuilder.as(logicalTypeAnnotation);
} else {
// Try to parse as old logical type, called OriginalType
originalType = OriginalType.valueOf(t);
childBuilder.as(originalType);
if (OriginalType.DECIMAL == originalType) {
t = st.nextToken();
// parse precision and scale
if (t.equalsIgnoreCase("(")) {
childBuilder.precision(Integer.parseInt(st.nextToken()));
t = st.nextToken();
if (t.equalsIgnoreCase(",")) {
childBuilder.scale(Integer.parseInt(st.nextToken()));
t = st.nextToken();
}
check(t, ")", "decimal type ended by )", st);
t = st.nextToken();
}
} else {
t = st.nextToken();
}
}
check(t, ")", "logical type ended by )", st);
t = st.nextToken();
}
if (t.equals("=")) {
childBuilder.id(Integer.parseInt(st.nextToken()));
t = st.nextToken();
}
check(t, ";", "field ended by ';'", st);
try {
childBuilder.named(name);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"problem reading type: type = " + type + ", name = " + name + ", original type = " + originalType,
e);
}
}