RussellSpitzer commented on code in PR #14040: URL: https://github.com/apache/iceberg/pull/14040#discussion_r2337211131
########## parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java: ########## @@ -1281,12 +1304,24 @@ public ReadBuilder withNameMapping(NameMapping newNameMapping) { @Override public ReadBuilder setRootType(Class<? extends StructLike> rootClass) { - throw new UnsupportedOperationException("Custom types are not yet supported"); + Preconditions.checkArgument( + this.internalReader != null, "Cannot set root type without using an Internal Reader"); + Preconditions.checkArgument( + this.readerFunc == null && this.readerFuncWithSchema == null, + "Setting root type is not compatible with setting a reader function"); + internalReader.setRootType(rootClass); Review Comment: The issues here are mostly centered around the "readerFunc" apis. We want to use "internalReader" to generate our reader func since it needs to be built based on InteralReader and BaseParquetReader. So we need some marker to let Parquet.java know it should be using that class to build the reader func. The previous code just set the reader func immediately upon using the InternalData pathway but that meant we would basically have to assume that if you call Root or CustomClass that we are able to replace that readerFunc with one built from internal data. I felt like this was a bit more straightforward. Ie Previously User calls InternalData read parquet InternalData calls Parquet.read(...).withReaderFunct(() -> InternalReader.create()) Which gives us back ``` ReadBuilder { readerFunc = Lambda$FromInternalData } ``` Then when you call set custom data we would have to do this ``` setRootType() { // Assume readerFunc Lambda was created by InternalReader so reassign it readerFunc = () ->> InternalReader.create(..., customClassMap) } ``` Or we could mess up the actual assignment logic where we check if these functions are set, and reset there or reset with an internal reader there. I'm not sure any of these are really great solutions though. ``` if (customClasses & readerFunc not set or "use Internal reader flag set")) { readerFunc = InternalReader.create(..., customClassMap) } ``` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org