rambleraptor commented on code in PR #15795:
URL: https://github.com/apache/iceberg/pull/15795#discussion_r3358952949


##########
data/src/test/java/org/apache/iceberg/data/BaseFormatModelTests.java:
##########
@@ -130,6 +130,99 @@ protected boolean supportsBatchReads() {
 
   @TempDir private File tableDir;
 
+  protected boolean supportsTime() {
+    return true;
+  }
+
+  protected boolean supportsTimestampNano() {
+    return true;
+  }
+
+  protected boolean supportsVariant() {
+    return true;
+  }
+
+  protected boolean supportsUnknown() {
+    return true;
+  }
+
+  /**
+   * Returns the schema with columns whose types are unsupported by this 
engine removed. Engines may
+   * override to extend or replace filtering logic. The default implementation 
drops top-level
+   * columns whose types (recursively) contain TIME, TIMESTAMP_NANO, VARIANT, 
or UNKNOWN when the
+   * corresponding {@code supports*} method returns false.
+   */
+  protected Schema filterUnsupported(Schema schema) {
+    List<Types.NestedField> kept =
+        schema.columns().stream().filter(field -> 
isTypeSupported(field.type())).toList();
+    if (kept.size() == schema.columns().size()) {
+      return schema;
+    }
+    return new Schema(kept);
+  }
+
+  private boolean isTypeSupported(Type type) {
+    switch (type.typeId()) {
+      case TIME:
+        if (!supportsTime()) {
+          return false;
+        }
+        break;
+      case TIMESTAMP_NANO:
+        if (!supportsTimestampNano()) {
+          return false;
+        }
+        break;
+      case VARIANT:
+        if (!supportsVariant()) {
+          return false;
+        }
+        break;
+      case UNKNOWN:
+        if (!supportsUnknown()) {
+          return false;
+        }
+        break;
+      default:
+        break;
+    }
+
+    if (type.isStructType()) {
+      return type.asStructType().fields().stream().allMatch(f -> 
isTypeSupported(f.type()));
+    } else if (type.isListType()) {
+      return isTypeSupported(type.asListType().elementType());
+    } else if (type.isMapType()) {
+      Types.MapType mapType = type.asMapType();
+      return isTypeSupported(mapType.keyType()) && 
isTypeSupported(mapType.valueType());
+    }
+
+    return true;
+  }
+
+  private Schema acceptSchema(DataGenerator generator) {

Review Comment:
   How does `supportedSchema` sound?



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

Reply via email to