rdblue commented on a change in pull request #2952:
URL: https://github.com/apache/iceberg/pull/2952#discussion_r693533961
##########
File path: api/src/main/java/org/apache/iceberg/types/TypeUtil.java
##########
@@ -42,6 +42,45 @@
private TypeUtil() {
}
+ /**
+ * Project extracts particular fields from a schema. Unlike
+ * {@link TypeUtil#select(Schema, Set)}, project will pick out only
+ * the fields enumerated, this means no sub fields will be selected
+ * unless they are explicitly requested.
+ * @param schema to project fields from
+ * @param fieldIds list of explicit fields to extract
+ * @return the schema with all fields fields not selected removed
+ */
+ public static Schema project(Schema schema, Set<Integer> fieldIds) {
+ Preconditions.checkNotNull(schema, "Schema cannot be null");
+
+ Types.StructType result = project(schema.asStruct(), fieldIds);
+ if (Objects.equals(schema.asStruct(), result)) {
Review comment:
Minor: If schema is non-null from the check above, then
`schema.asStruct()` must also be non-null. So you should be able to use
`equals` instead if you want.
--
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]