RussellSpitzer commented on a change in pull request #1744:
URL: https://github.com/apache/iceberg/pull/1744#discussion_r521725991



##########
File path: api/src/main/java/org/apache/iceberg/types/GetEmptyStructIds.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.types;
+
+import java.util.List;
+import java.util.Set;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+
+class GetEmptyStructIds extends TypeUtil.SchemaVisitor<Set<Integer>> {

Review comment:
       This Visitor is used to find the FieldIDs of any fields which must 
remain in the projection, but if they have no sub fields, should be just 
included as empty Structs.
   
   There are 3 Main cases of this
   1. The Struct is Empty
   2. The Sturct contains required MetadataColumns, these are not real so we 
cannot properly include their parents in the normal path. Currently the only 
one of these allowed is MetadataColumns.ROW_POSITION, see 
https://github.com/apache/iceberg/blob/074323214a8a580f85251d700f3754e2fb6e2758/core/src/main/java/org/apache/iceberg/avro/BuildAvroProjection.java#L98-L102
   
   3. The Struct contains Optional Columns which aren't part of the schema, 
these are a allowed by the same code block mentioned above, but if their 
parents are pruned out we will have an error when we attempt to add them back 
to the projection.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to