FrankChen021 commented on code in PR #19769:
URL: https://github.com/apache/druid/pull/19769#discussion_r3657343590
##########
processing/src/main/java/org/apache/druid/segment/column/Types.java:
##########
@@ -57,14 +58,16 @@ public static <T extends TypeSignature<?>> T
fromString(TypeFactory<T> typeFacto
case "COMPLEX":
return typeFactory.ofComplex(null);
default:
- // we do not convert to uppercase here, because complex type name must
be preserved in original casing
- // array could be converted, but are not for no particular reason
other than less spooky magic
- if (typeString.startsWith(ARRAY_PREFIX)) {
+ // Prefix matching is case-insensitive, consistent with the scalar
handling above, but the type parameter is
+ // taken from the original string: complex type names are
case-sensitive registry keys which must be preserved
+ // in their original casing (array element types recurse through this
method, so any casing works for them).
+ // A parameterized type without the closing bracket is malformed, not
a truncated parameter name.
+ if (upperTypeString.startsWith(ARRAY_PREFIX) &&
upperTypeString.endsWith(">")) {
T elementType = fromString(typeFactory,
typeString.substring(ARRAY_PREFIX.length(), typeString.length() - 1));
Preconditions.checkNotNull(elementType, "Array element type must not
be null");
return typeFactory.ofArray(elementType);
}
- if (typeString.startsWith(COMPLEX_PREFIX)) {
+ if (upperTypeString.startsWith(COMPLEX_PREFIX) &&
upperTypeString.endsWith(">")) {
Review Comment:
[P1] Reject malformed declared types instead of returning null
The new closing-bracket guards make declarations such as `COMPLEX<json` and
`ARRAY<LONG` fall through to `null`. Catalog consumers treat `null` as an
undeclared type and default it to `STRING`, so a malformed schema can pass
validation and ingest with the wrong physical type. Throw or validate declared
types before this fallback.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]