zeroshade commented on code in PR #1665:
URL: https://github.com/apache/iceberg-go/pull/1665#discussion_r3732111105
##########
table/sorting.go:
##########
@@ -191,9 +191,11 @@ func (s *SortField) UnmarshalJSON(b []byte) error {
return nil
}
+// Zero is valid: unbound sort orders carry client ordinal placeholder IDs that
+// start at 0. CheckCompatibility rejects IDs that don't resolve against a
schema.
func validateSortSourceID(id int) error {
- if id <= 0 {
- return fmt.Errorf("source ID must be positive: %d", id)
+ if id < 0 {
Review Comment:
This global relaxation also admits zero into historical sort orders. Only
the default order is compatibility-checked during metadata validation, so a
historical order with source ID zero can persist. **Suggested fix:** limit zero
to the unbound request path and structurally validate every persisted sort
order with positive source IDs.
##########
partitions.go:
##########
@@ -162,10 +162,13 @@ func (p *PartitionField) UnmarshalJSON(b []byte) error {
} else {
p.SourceIDs = []int{aux.SourceID}
}
+ // Positivity only holds for specs already bound to a schema. Decoding
also
+ // covers unbound specs from create-table and commit requests, whose
source
+ // IDs are client ordinal placeholders starting at 0, remapped by name
at
+ // bind time.
for _, sourceID := range p.SourceIDs {
- _, isVoid := p.Transform.(VoidTransform)
- if sourceID <= 0 && (!isVoid || hasSourceID || hasSourceIDs) {
- return fmt.Errorf("%w: partition source ID must be
positive: %d", ErrInvalidPartitionSpec, sourceID)
+ if sourceID < 0 {
Review Comment:
This decoder is also used for persisted default and historical partition
specs, so changing the global invariant admits source ID zero into stored
metadata; `checkPartitionSpecs` does not bind or validate those source IDs.
**Suggested fix:** accept temporary zero only in the unbound request path, then
require positive IDs for all bound/persisted specs while retaining the existing
source-less void tombstone exception.
--
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]