huaxingao commented on code in PR #17822:
URL: https://github.com/apache/iceberg/pull/17822#discussion_r4287185194


##########
format/spec.md:
##########
@@ -436,6 +437,8 @@ Two rows are the "same"---that is, the rows represent the 
same entity---if the i
 
 Identifier fields may be nested in structs but cannot be nested within maps or 
lists. Float, double, and optional fields cannot be used as identifier fields 
and a nested field cannot be used as an identifier field if it is nested in an 
optional struct, to avoid null values in identifiers.
 
+Identifier field IDs are not used in v4, where a [`primary-key` 
constraint](#constraints) expresses the same concept.

Review Comment:
   Good point. Changed to "must not be used".



##########
format/spec.md:
##########
@@ -655,6 +658,125 @@ Sorting floating-point numbers should produce the 
following behavior: `-NaN` < `
 
 A data or delete file is associated with a sort order by the sort order's id 
within [a manifest](#manifests). Therefore, the table must declare all the sort 
orders for lookup. A table could also be configured with a default sort order 
id, indicating how the new data should be sorted by default. Writers should use 
this default sort order to sort the data on write, but are not required to if 
the default order is prohibitively expensive, as it would be for streaming 
writes.
 
+### Constraints
+
+Constraints are added in v4 and are not supported in v3 or earlier.
+
+A **constraint** declares a condition that a table's rows are expected to 
satisfy. Its definition is stored in table metadata. Each snapshot contains the 
writer-reported status of each constraint that existed when the snapshot was 
created; see [Constraint Validation](#constraint-validation).
+
+Three constraint types are defined:
+
+* `check` -- every row must satisfy a predicate
+* `unique` -- the values of a set of fields must be distinct across the rows 
in which every field in the set is non-null; a row in which any field in the 
set is null is not compared, so more than one such row may exist
+* `primary-key` -- the values of a set of fields must be distinct across all 
rows and must not be null
+
+A constraint is stored separately from the table schema and must refer to 
fields by field ID. Constraints may evolve independently from the schema, being 
added, modified, or removed.
+
+#### Constraint Fields
+
+A constraint consists of the following fields:
+
+| Requirement | Field name                | Type      | Description |
+|-------------|---------------------------|-----------|-------------|
+| _required_ | **`constraint-id`**       | `int`     | ID of the constraint; 
unique within the table |

Review Comment:
   I'd like to keep `constraint-id`. Other objects name their own ID the same 
way: `schema-id`, `spec-id`, `order-id`, and `snapshot-id`. `type` and `name` 
are only used inside the constraint, so they don't need the prefix.



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