pvary commented on code in PR #17617:
URL: https://github.com/apache/iceberg/pull/17617#discussion_r3782771773
##########
data/src/test/java/org/apache/iceberg/data/BaseFormatModelTests.java:
##########
@@ -2224,6 +2228,23 @@ private static void assumeSupports(FileFormat
fileFormat, String feature) {
assumeThat(MISSING_FEATURES.getOrDefault(fileFormat, new String[]
{})).doesNotContain(feature);
}
+ private static boolean supportsGenerator(FileFormat fileFormat,
DataGenerator generator) {
+ return requiredFeatures(generator.schema().asStruct()).stream()
+ .allMatch(feature -> supportsFeature(fileFormat, feature));
+ }
+
+ private static Set<String> requiredFeatures(Type type) {
+ if (containsType(type, Type.TypeID.VARIANT)) {
+ return Set.of(FEATURE_VARIANT);
+ }
+
+ return Set.of();
+ }
+
+ private static boolean containsType(Type type, Type.TypeID typeId) {
+ return TypeUtil.find(type, nested -> nested.typeId() == typeId) != null;
+ }
Review Comment:
Could we simplify this?
```suggestion
private static boolean supportsGenerator(FileFormat fileFormat,
DataGenerator generator) {
boolean hasVariant =
TypeUtil.find(generator.schema(), type -> type.typeId() ==
Type.TypeID.VARIANT) != null;
return !hasVariant || supportsFeature(fileFormat, FEATURE_VARIANT);
}
```
--
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]