shangxinli commented on code in PR #14040:
URL: https://github.com/apache/iceberg/pull/14040#discussion_r2373866109
##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetValueReaders.java:
##########
@@ -1132,6 +1144,46 @@ private TripleIterator<?>
firstNonNullColumn(List<TripleIterator<?>> columns) {
}
}
+ private static class StructLikeReader<T extends StructLike> extends
StructReader<T, T> {
+ private final Types.StructType struct;
+ private final DynConstructors.Ctor<T> ctor;
+
+ StructLikeReader(
+ List<ParquetValueReader<?>> readers, Types.StructType struct, Class<T>
structLikeClass) {
+ super(readers);
+ this.struct = struct;
+ this.ctor =
Review Comment:
DynConstructors.build() returns a constructor wrapper even if no matching
constructors are found. The failure only occurs later when
ctor.newInstance(struct) is called in newStructData() method (line 1167),
potentially causing confusing runtime errors instead of clear validation errors
during reader setup.
Can we do?
try {
this.ctor = DynConstructors.builder(StructLike.class)
.hiddenImpl(structLikeClass, Types.StructType.class)
.hiddenImpl(structLikeClass)
.build();
// Validate constructor works by testing instantiation
ctor.newInstance(struct);
} catch (Exception e) {
throw new IllegalArgumentException(
"Custom type " + structLikeClass.getName() +
" must have a constructor accepting Types.StructType or a no-args
constructor", e);
}
--
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]