trushev commented on code in PR #7857:
URL: https://github.com/apache/hudi/pull/7857#discussion_r1098203988


##########
hudi-common/src/main/java/org/apache/hudi/avro/AvroSchemaUtils.java:
##########
@@ -72,6 +69,18 @@ public static boolean isSchemaCompatible(Schema prevSchema, 
Schema newSchema, bo
     return result.getType() == 
AvroSchemaCompatibility.SchemaCompatibilityType.COMPATIBLE;
   }
 
+  /**
+   * Check that each field in the prevSchema can be populated in the newSchema
+   * @param prevSchema prev schema.
+   * @param newSchema new schema
+   * @return true if prev schema is a projection of new schema.
+   */

Review Comment:
   @danny0405,  yes we need similar changes
   I tried the following flink job
   ```sql
   -- Step 1.
   create table tbl(
       `uuid` bigint,
       `name` string,
       `age` int null, -- column to be dropped
       `part` int
   ) partitioned by (`part`) with (
       'connector'='hudi',
       'path'='/tmp/tbl',
       'hoodie.avro.schema.validate'='false',
       'hoodie.datasource.write.schema.allow.auto.evolution.column.drop'='false'
   );
   insert into tbl values (1, 'Danny', 23, 10);
   drop table tbl;
   
   -- Step 2.
   create table tbl(
       `uuid` bigint,
       `name` string,
       `part` int
   ) partitioned by (`part`) with (
       'connector'='hudi',
       'path'='/tmp/tbl',
       'hoodie.avro.schema.validate'='false',
       'hoodie.datasource.write.schema.allow.auto.evolution.column.drop'='false'
   );
   insert into tbl values (2, 'Stephen', 10); -- failure expected
   select * from tbl;
   ```
   Expected behavior:
   ```
   Exception -- column dropping is not allowed
   ```
   Actual behavior:
   ```
   +----+-------+----------+-------+
   | op |  uuid |     name |  part |
   +----+-------+----------+-------+
   | +I |     1 |    Danny |    10 |
   | +I |     2 |  Stephen |    10 |
   +----+-------+----------+-------+
   
   ```
   
   



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

Reply via email to