rdblue commented on code in PR #12139: URL: https://github.com/apache/iceberg/pull/12139#discussion_r1936492645
########## parquet/src/main/java/org/apache/iceberg/parquet/ParquetVariantVisitor.java: ########## @@ -0,0 +1,287 @@ +/* + * + * * Licensed to the Apache Software Foundation (ASF) under one + * * or more contributor license agreements. See the NOTICE file + * * distributed with this work for additional information + * * regarding copyright ownership. The ASF licenses this file + * * to you under the Apache License, Version 2.0 (the + * * "License"); you may not use this file except in compliance + * * with the License. You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, + * * software distributed under the License is distributed on an + * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * * KIND, either express or implied. See the License for the + * * specific language governing permissions and limitations + * * under the License. + * + */ +package org.apache.iceberg.parquet; + +import java.util.List; +import org.apache.commons.compress.utils.Lists; +import org.apache.parquet.Preconditions; +import org.apache.parquet.schema.GroupType; +import org.apache.parquet.schema.LogicalTypeAnnotation.ListLogicalTypeAnnotation; +import org.apache.parquet.schema.PrimitiveType; +import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName; +import org.apache.parquet.schema.Type; + +public abstract class ParquetVariantVisitor<R> { + static final String METADATA = "metadata"; + static final String VALUE = "value"; + static final String TYPED_VALUE = "typed_value"; + + /** + * Handles the root variant column group. + * + * <p>The value and typed_value results are combined by calling {@link #value}. + * + * <pre> + * group v (VARIANT) { <-- metadata result and combined value and typed_value result + * required binary metadata; + * optional binary value; + * optional ... typed_value; + * } + * </pre> + */ + public R variant(GroupType variant, R metadataResult, R valueResult) { + return null; + } + + /** + * Handles a serialized variant metadata column. + * + * <pre> + * group v (VARIANT) { + * required binary metadata; <-- this column + * optional binary value; + * optional ... typed_value; + * } + * </pre> + */ + public R metadata(PrimitiveType metadata) { + return null; + } + + /** + * Handles a serialized variant value column. + * + * <pre> + * group variant_value_pair { + * optional binary value; <-- this column + * optional ... typed_value; + * } + * </pre> + */ + public R serialized(PrimitiveType value) { + return null; + } + + /** + * Handles a shredded primitive typed_value column. + * + * <pre> + * group variant_value_pair { + * optional binary value; + * optional int32 typed_value; <-- this column when it is any primitive + * } + * </pre> + */ + public R primitive(PrimitiveType primitive) { + return null; + } + + /** + * Handles a variant value result and typed_value result pair. + * + * <p>The value and typed_value pair may be nested in an object field, array element, or in the + * root group of a variant. + * + * <p>This method is also called when the typed_value field is missing. + * + * <pre> + * group variant_value_pair { <-- value result and typed_value result + * optional binary value; + * optional ... typed_value; + * } + * </pre> + */ + public R value(GroupType value, R valueResult, R typedResult) { + return null; + } + + /** + * Handles a shredded object value result and a list of field value results. + * + * <p>Each field's value and typed_value results are combined by calling {@link #value}. + * + * <pre> + * group variant_value_pair { <-- value result and typed_value field results + * optional binary value; + * optional group typed_value { + * required group a { + * optional binary value; + * optional binary typed_value (UTF8); + * } + * ... + * } + * } + * </pre> + */ + public R object(GroupType object, R valueResult, List<R> fieldResults) { Review Comment: The `value`, `object`, and `array` visitor methods are all used for a `value` / `typed_value` pair, depending on the structure of typed value (a shredded value, shredded array, or shredded object). -- 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