This is an automated email from the ASF dual-hosted git repository.
sivabalan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 5fb00ef506f [HUDI-7201] Schema Evolution: use target schema if source
is empty (#10288)
5fb00ef506f is described below
commit 5fb00ef506f3616c7c435973aebe1625d8374397
Author: Jon Vexler <[email protected]>
AuthorDate: Sun Dec 10 13:06:30 2023 -0500
[HUDI-7201] Schema Evolution: use target schema if source is empty (#10288)
---------
Co-authored-by: Jonathan Vexler <=>
---
.../apache/hudi/internal/schema/utils/AvroSchemaEvolutionUtils.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git
a/hudi-common/src/main/java/org/apache/hudi/internal/schema/utils/AvroSchemaEvolutionUtils.java
b/hudi-common/src/main/java/org/apache/hudi/internal/schema/utils/AvroSchemaEvolutionUtils.java
index 2fdd2f4c2db..35ca13820f2 100644
---
a/hudi-common/src/main/java/org/apache/hudi/internal/schema/utils/AvroSchemaEvolutionUtils.java
+++
b/hudi-common/src/main/java/org/apache/hudi/internal/schema/utils/AvroSchemaEvolutionUtils.java
@@ -140,10 +140,14 @@ public class AvroSchemaEvolutionUtils {
* @return schema (based off {@code source} one) that has nullability
constraints and datatypes reconciled
*/
public static Schema reconcileSchemaRequirements(Schema sourceSchema, Schema
targetSchema, Map<String, String> opts) {
- if (sourceSchema.getType() == Schema.Type.NULL ||
sourceSchema.getFields().isEmpty() || targetSchema.getFields().isEmpty()) {
+ if (targetSchema.getType() == Schema.Type.NULL ||
targetSchema.getFields().isEmpty()) {
return sourceSchema;
}
+ if (sourceSchema.getType() == Schema.Type.NULL ||
sourceSchema.getFields().isEmpty()) {
+ return targetSchema;
+ }
+
InternalSchema sourceInternalSchema = convert(sourceSchema);
InternalSchema targetInternalSchema = convert(targetSchema);