rdblue commented on a change in pull request #4301:
URL: https://github.com/apache/iceberg/pull/4301#discussion_r824309140



##########
File path: format/spec.md
##########
@@ -193,10 +193,38 @@ Notes:
 
 For details on how to serialize a schema to JSON, see Appendix C.
 
+#### Default value
+Default values can be assigned to top-level columns or nested fields. Default 
values are used during schema evolution when adding a new column. The default 
value is used to read rows belonging to the files that lack the column or 
nested field prior to the schema evolution.

Review comment:
       It isn't close to option 1 because the write default can still freely 
change. The only thing we need to put behind `alloweIncompatibleChanges` is 
modifying the initial default.
   
   This is fine:
   
   ```java
   table.updateSchema()
       .addRequiredColumn("test", IntegerType.get(), 34) // sets the initial 
and write defaults to 34
       .setColumnDefault("test", 35) // sets the write default to 35
       .commit();
   ```
   
   This is what would expose the initial default and would be a bit confusing:
   
   ```java
   table.updateSchema()
       .addRequiredColumn("test", IntegerType.get(), 34) // sets the initial 
and write defaults to 34
       .commit();
   table.updateSchema()
       .allowIncompatibleChanges()
       .setInitialColumnDefault("test", 35) // sets the initial default to 35
       .commit();
   ```
   
   I think we could get away without adding `setInitialColumnDefault` because 
you can always go drop the column and re-add it if it really is a safe change. 
This is equivalent to the above:
   
   ```java
   table.updateSchema()
       .addRequiredColumn("test", IntegerType.get(), 34) // sets the initial 
and write defaults to 34
       .commit();
   table.updateSchema()
       .dropColumn("test")
       .commit();
   table.updateSchema()
       .addRequiredColumn("test", IntegerType.get(), 35) // sets the initial 
and write defaults to 35
       .commit();
   ```
   
   




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