This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 21d993033 fix(cli): report missing table, not namespace, in describe 
(#2424)
21d993033 is described below

commit 21d99303341c44b243821a23e74c0b03728657d0
Author: Shruthi <[email protected]>
AuthorDate: Wed Nov 4 09:29:39 2026 -0800

    fix(cli): report missing table, not namespace, in describe (#2424)
    
    Signed-off-by: Shruthi Yaramada <[email protected]>
    Co-authored-by: Shruthi Yaramada <[email protected]>
---
 cmd/iceberg/describe_test.go | 64 ++++++++++++++++++++++++++++++++++++++++++++
 cmd/iceberg/main.go          |  6 +++--
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/cmd/iceberg/describe_test.go b/cmd/iceberg/describe_test.go
new file mode 100644
index 000000000..2c397a396
--- /dev/null
+++ b/cmd/iceberg/describe_test.go
@@ -0,0 +1,64 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package main
+
+import (
+       "context"
+       "testing"
+
+       "github.com/apache/iceberg-go"
+       "github.com/apache/iceberg-go/catalog"
+       "github.com/apache/iceberg-go/table"
+       "github.com/stretchr/testify/assert"
+)
+
+type mockCatalogForDescribe struct {
+       mockCatalogForDrop
+
+       nsErr  error
+       tblErr error
+}
+
+func (m *mockCatalogForDescribe) LoadNamespaceProperties(ctx context.Context, 
namespace table.Identifier) (iceberg.Properties, error) {
+       return nil, m.nsErr
+}
+
+func (m *mockCatalogForDescribe) LoadTable(ctx context.Context, identifier 
table.Identifier) (*table.Table, error) {
+       return nil, m.tblErr
+}
+
+func TestDescribeMissingTableReportsNoSuchTable(t *testing.T) {
+       const id = "demo.test"
+
+       // Neither namespace "demo.test" nor table "test" exists.
+       cat := &mockCatalogForDescribe{
+               nsErr:  catalog.ErrNoSuchNamespace,
+               tblErr: catalog.ErrNoSuchTable,
+       }
+       var out errCapture
+
+       exitCode := captureBranchTagExit(func() {
+               describe(context.Background(), &out, cat, id, "any")
+       })
+
+       assert.Equal(t, 1, exitCode)
+       // The table lookup failed, so report a missing table
+       assert.ErrorIs(t, out.lastErr, catalog.ErrNoSuchTable)
+       assert.NotErrorIs(t, out.lastErr, catalog.ErrNoSuchNamespace)
+       assert.ErrorContains(t, out.lastErr, id)
+}
diff --git a/cmd/iceberg/main.go b/cmd/iceberg/main.go
index ad1b5406f..a66fd1e4d 100644
--- a/cmd/iceberg/main.go
+++ b/cmd/iceberg/main.go
@@ -850,8 +850,10 @@ func describe(ctx context.Context, output Output, cat 
catalog.Catalog, id string
        }
 
        if !isNS && !isTbl {
-               output.Error(fmt.Errorf("%w: table or namespace does not exist: 
%s",
-                       catalog.ErrNoSuchNamespace, ident))
+               // Only reachable for "any" with a multi-part identifier, so the
+               // table lookup is the last one that failed.
+               output.Error(fmt.Errorf("%w: no table or namespace named %s",
+                       catalog.ErrNoSuchTable, strings.Join(ident, ".")))
                osExit(1)
        }
 }

Reply via email to