You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "fallintoplace (via GitHub)" <gi...@apache.org> on 2026/08/13 14:44:25 UTC

[PR] perf(table): decode metadata updates in one pass [iceberg-go]

fallintoplace opened a new pull request, #1822:
URL: https://github.com/apache/iceberg-go/pull/1822

   ## Summary
   
   - Reuse one raw field map for update action dispatch and required field validation.
   - Keep legacy property field normalization working.
   - Avoid repeated JSON object decoding for every update.
   - Adds canonical and legacy update benchmarks.
   
   ## Benchmark
   
   - About 24 percent faster for 1,000 canonical updates.
   - About 11 percent fewer allocations for the same case.
   
   ## Tests
   
   - go test ./...
   - go vet .


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] perf(table): decode metadata updates in one pass [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #1822:
URL: https://github.com/apache/iceberg-go/pull/1822#issuecomment-5334087146

   just need to fix the linting issue


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] perf(table): decode metadata updates in one pass [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #1822:
URL: https://github.com/apache/iceberg-go/pull/1822#issuecomment-5319839131

   Since this is a draft, i'll hold off on further review until it's marked ready


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] perf(table): decode metadata updates in one pass [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #1822:
URL: https://github.com/apache/iceberg-go/pull/1822


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] perf(table): decode metadata updates in one pass [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #1822:
URL: https://github.com/apache/iceberg-go/pull/1822#discussion_r3807738959


##########
table/updates.go:
##########
@@ -221,12 +245,32 @@ func (u *Updates) UnmarshalJSON(data []byte) error {
 		default:
 			return fmt.Errorf("%w: unknown update action: %s", iceberg.ErrInvalidArgument, base.ActionName)
 		}
-		normalized, err := normalizeLegacyPropertyFields(base.ActionName, raw)
-		if err != nil {
-			return err
+		if normalizeLegacyPropertyFields(base.ActionName, object) {
+			var actionWire struct {

Review Comment:
   **Major:** This raw discriminator check is reached only after successful action dispatch and only for legacy property normalization, so exact duplicate-key type errors still disappear on earlier exits. For both `{"action":123,"action":"unknown"}` and `{"action":123,"action":null}`, the merge base returns `*json.UnmarshalTypeError`; this head instead returns “unknown update action” or the missing/null-action `ErrInvalidArgument` because the map decode collapsed the earlier number before execution reaches here. Please validate the original discriminator semantics before the null and unknown-action exits, and extend the regression test across valid, unknown, and null final values.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] perf(table): decode metadata updates in one pass [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #1822:
URL: https://github.com/apache/iceberg-go/pull/1822#discussion_r3799472688


##########
table/updates.go:
##########
@@ -158,17 +153,20 @@ func (u *Updates) UnmarshalJSON(data []byte) error {
 		updates = make(Updates, 0, len(rawUpdates))
 	}
 	for _, raw := range rawUpdates {
-		var baseWire struct {
-			Action *string `json:"action"`
-		}
-		if err := json.Unmarshal(raw, &baseWire); err != nil {
+		var object map[string]json.RawMessage
+		if err := json.Unmarshal(raw, &object); err != nil {
 			return err
 		}
-		if baseWire.Action == nil {
+		actionValue, ok := object["action"]

Review Comment:
   Could we keep action dispatch aligned with the final tagged-struct decode? This exact map lookup no longer accepts case-insensitive action keys that `encoding/json` previously accepted. More seriously, for `{"action":"set-location","ACTION":"unknown","location":"s3://bucket/table"}`, this lookup dispatches to `setLocationUpdate`, but the later `json.Unmarshal(raw, upd)` applies case-insensitive struct matching and overwrites the embedded `ActionName` with `"unknown"`. The result is a concrete set-location update whose `Action()` reports `unknown`; the merge base rejects that payload as an unknown action. Please use identical action-key semantics for dispatch and final decode, with regression tests for mixed-case and duplicate case-variant keys.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] perf(table): decode metadata updates in one pass [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #1822:
URL: https://github.com/apache/iceberg-go/pull/1822#discussion_r3807499859


##########
table/updates.go:
##########
@@ -158,17 +154,45 @@ func (u *Updates) UnmarshalJSON(data []byte) error {
 		updates = make(Updates, 0, len(rawUpdates))
 	}
 	for _, raw := range rawUpdates {
-		var baseWire struct {
-			Action *string `json:"action"`
-		}
-		if err := json.Unmarshal(raw, &baseWire); err != nil {
+		var object map[string]json.RawMessage
+		if err := json.Unmarshal(raw, &object); err != nil {
 			return err
 		}
-		if baseWire.Action == nil {
-			return fmt.Errorf("%w: update requires field %q", iceberg.ErrInvalidArgument, "action")
+
+		actionValue, exactAction := object["action"]
+		actionFieldCount := 0
+		caseVariantAction := false
+		for field := range object {
+			if strings.EqualFold(field, "action") {
+				actionFieldCount++
+				if field != "action" {
+					caseVariantAction = true
+				}
+			}
 		}
 
-		base := baseUpdate{ActionName: *baseWire.Action}
+		var action string
+		if exactAction && !caseVariantAction {

Review Comment:
   **Major: exact duplicate `action` keys can still erase an `encoding/json` type error.** By this fast path, decoding into `object` has already collapsed duplicate exact keys. For `[{"action":123,"action":"set-properties","updated":{"k":"v"}}]`, the merge base returns `*json.UnmarshalTypeError`, but the current code selects the final string, legacy-normalizes and re-marshals the map, then succeeds because the earlier invalid number is gone. Please preserve the discriminator's original decode error before any map round-trip and add this payload as a regression test.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org