fix(sql): hide namespace exists sentinel property#1411
Conversation
1c58617 to
75fbfa4
Compare
tanmayrauth
left a comment
There was a problem hiding this comment.
Core change reads cleanly and the tests pass. One thing worth deciding before merge: this reserves exists on the read path (LoadNamespaceProperties) and the update path (UpdateNamespaceProperties), but CreateNamespace — untouched here — still inserts whatever the caller passes. So CreateNamespace(ns, {"exists": "false", ...}) persists a sentinel the new code then permanently hides on read and refuses to update or remove. Not asking you to change CreateNamespace in this PR necessarily, but it'd be good to confirm whether leaving that path unguarded is intended, since the three paths no longer agree on what "reserved" means. Two small inline notes below.
|
|
||
| for _, key := range removals { | ||
| if isReservedNamespaceProperty(key) { | ||
| return fmt.Errorf("%w: cannot remove reserved namespace property %q", iceberg.ErrInvalidArgument, namespaceExistsProperty) |
There was a problem hiding this comment.
Small one: the loop binds key but this formats namespaceExistsProperty. Same value today since only "exists" is reserved, but if the reserved set ever grows this will name the wrong key in the error — probably want key here.
| cat *sqlcat.Catalog | ||
| namespace table.Identifier | ||
| }{ | ||
| {s.getCatalogMemory(), table.Identifier{databaseName()}}, |
There was a problem hiding this comment.
Since this seeds {"comment": "baseline"}, no sentinel row is actually written, so the guard is only exercised at the argument layer. Could you add a case that creates a namespace with empty props (which does insert the exists=true row) and then asserts remove/update of exists is still rejected and the namespace loads empty? That covers the real-world path where the sentinel is present.
zeroshade
left a comment
There was a problem hiding this comment.
One latent bug in the removal-branch error message (inline), plus a small coverage gap: the new test always seeds the namespace with non-empty user props, so the exists sentinel row is never actually persisted. Consider adding a case that creates a namespace with nil/empty properties (which does write the sentinel) and asserts it's hidden by LoadNamespaceProperties and rejected on remove — that exercises the sentinel-present path.
|
|
||
| for _, key := range removals { | ||
| if isReservedNamespaceProperty(key) { | ||
| return fmt.Errorf("%w: cannot remove reserved namespace property %q", iceberg.ErrInvalidArgument, namespaceExistsProperty) |
There was a problem hiding this comment.
This formats the constant namespaceExistsProperty (always exists) instead of the loop variable key. They're identical today because isReservedNamespaceProperty only matches exists, but once the reserved set grows this will report the wrong property name for any reserved-key removal. Use key here.
75fbfa4 to
3098b1f
Compare
Summary
existsfromLoadNamespaceProperties;existswithErrInvalidProperty;Testing
go test ./catalog/sql