haizhou-zhao commented on a change in pull request #4120: URL: https://github.com/apache/iceberg/pull/4120#discussion_r808266934
########## File path: core/src/main/java/org/apache/iceberg/avro/MissingIds.java ########## @@ -0,0 +1,80 @@ +/* + * 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.avro; + +import java.util.List; +import java.util.function.Supplier; +import org.apache.avro.Schema; + +/** + * Returns true once the first node is found with ID property missing. Reverse of {@link HasIds} + * <p> + * Note: To use {@link AvroSchemaUtil#toIceberg(Schema)} on an avro schema, the avro schema need to be either + * have IDs on every node or not have IDs at all. Invoke {@link AvroSchemaUtil#hasIds(Schema)} only proves + * that the schema has at least one ID, and not sufficient condition for invoking + * {@link AvroSchemaUtil#toIceberg(Schema)} on the schema. + */ +class MissingIds extends AvroCustomOrderSchemaVisitor<Boolean, Boolean> { + @Override + public Boolean record(Schema record, List<String> names, Iterable<Boolean> fields) { + for (Boolean field : fields) { + if (field) { + return true; Review comment: No prob, I can switch to use guava's `any`, if we don't see style differences between this class and `HasIds` as problem. I can also change things for `HasIds` as well if you think that's proper. -- 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]
