rdblue commented on a change in pull request #2877:
URL: https://github.com/apache/iceberg/pull/2877#discussion_r682919095
##########
File path: api/src/main/java/org/apache/iceberg/util/StructProjection.java
##########
@@ -82,8 +85,31 @@ private StructProjection(StructType structType, StructType
projection) {
dataField.type().asStructType(),
projectedField.type().asStructType());
break;
case MAP:
+ MapType projectedMap = projectedField.type().asMapType();
+ MapType originalMap = dataField.type().asMapType();
+
+ boolean keyProjectable = !projectedMap.keyType().isStructType()
||
+ projectedMap.keyType().equals(originalMap.keyType());
+ boolean valueProjectable =
!projectedMap.valueType().isStructType() ||
+ projectedMap.valueType().equals(originalMap.valueType());
+
+ Preconditions.checkArgument(keyProjectable && valueProjectable,
+ "Cannot perform a projection of a map unless key and value
types are primitive or a " +
+ "struct which is fully projected. Trying to project %s
out of %s", projectedField, dataField);
+ nestedProjections[pos] = null;
+ break;
case LIST:
- throw new IllegalArgumentException(String.format("Cannot project
list or map field: %s", projectedField));
+ ListType projectedList = projectedField.type().asListType();
+ ListType originalList = dataField.type().asListType();
+
+ boolean elementProjectable =
!projectedList.elementType().isStructType() ||
+
projectedList.elementType().equals(originalList.elementType());
+
+ Preconditions.checkArgument(elementProjectable,
+ "Cannot perform a projection of a list unless it's element
is a primitive or a struct which is " +
Review comment:
What about something shorter, like "Cannot project a partial list
element struct: %s from %s"?
--
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]