aokolnychyi commented on a change in pull request #3763:
URL: https://github.com/apache/iceberg/pull/3763#discussion_r773297688
##########
File path: api/src/main/java/org/apache/iceberg/types/TypeUtil.java
##########
@@ -340,6 +340,42 @@ public static void validateWriteSchema(Schema tableSchema,
Schema writeSchema,
}
}
+ /**
+ * Validates whether the provided schema is compatible with the expected
schema.
+ *
+ * @param ctx the validation context used in the error message
+ * @param expectedSchema the expected schema
+ * @param actualSchema the actual schema
+ * @param checkNullability whether to check nullability
+ * @param checkOrdering whether to check field ordering
+ */
+ public static void validateSchema(String ctx, Schema expectedSchema, Schema
actualSchema,
+ Boolean checkNullability, Boolean
checkOrdering) {
+ List<String> errors;
+ if (checkNullability) {
+ errors = CheckCompatibility.writeCompatibilityErrors(expectedSchema,
actualSchema, checkOrdering);
+ } else {
+ errors = CheckCompatibility.typeCompatibilityErrors(expectedSchema,
actualSchema, checkOrdering);
+ }
+
+ if (!errors.isEmpty()) {
+ StringBuilder sb = new StringBuilder();
+ String header = String.format("Schema is not compatible with expected %s
schema:", ctx);
+ sb.append(header)
+ .append("\nexpected schema:")
Review comment:
Fixed.
--
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]