Skip to content

Commit 65ce3c2

Browse files
authored
fix: Add error message for wrong namespace/table in describe (#154)
1 parent b1484c7 commit 65ce3c2

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

  • ice-rest-catalog/src/test/resources/scenarios/basic-operations
  • ice/src/main/java/com/altinity/ice/cli/internal/cmd

ice-rest-catalog/src/test/resources/scenarios/basic-operations/run.sh.tmpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ echo "OK Scan verified ${TABLE_SORTED}"
121121
{{ICE_CLI}} --config {{CLI_CONFIG}} describe
122122
echo "OK Described catalog"
123123

124+
INVALID_NS="invalid_ns"
125+
{{ICE_CLI}} --config {{CLI_CONFIG}} describe $INVALID_NS > /tmp/basic_ops_describe_invalid_ns.txt 2>&1
126+
if ! grep -q "Namespace $INVALID_NS not found" /tmp/basic_ops_describe_invalid_ns.txt; then
127+
echo "FAIL: describe missing error message for invalid namespace"
128+
cat /tmp/basic_ops_describe_invalid_ns.txt
129+
exit 1
130+
fi
131+
echo "OK Describe reported invalid namespace"
132+
133+
INVALID_TABLE="${NAMESPACE_NAME}.invalid_table"
134+
{{ICE_CLI}} --config {{CLI_CONFIG}} describe $INVALID_TABLE > /tmp/basic_ops_describe_invalid_table.txt 2>&1
135+
if ! grep -q "Table $INVALID_TABLE not found" /tmp/basic_ops_describe_invalid_table.txt; then
136+
echo "FAIL: describe missing error message for invalid table"
137+
cat /tmp/basic_ops_describe_invalid_table.txt
138+
exit 1
139+
fi
140+
echo "OK Describe reported invalid table"
141+
124142
# Optional: --no-copy insert (like README: create-table + upload + insert --no-copy)
125143
# Upload to MinIO via AWS CLI if available so insert --no-copy can reference s3://
126144
# This section is best-effort: if it fails we skip rather than failing the whole test.

ice/src/main/java/com/altinity/ice/cli/internal/cmd/Describe.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
import org.apache.iceberg.rest.RESTCatalog;
3535
import org.apache.iceberg.types.Conversions;
3636
import org.apache.iceberg.types.Types;
37+
import org.slf4j.Logger;
38+
import org.slf4j.LoggerFactory;
3739

3840
public final class Describe {
3941

42+
private static final Logger logger = LoggerFactory.getLogger(Describe.class);
43+
4044
private Describe() {}
4145

4246
public enum Option {
@@ -66,10 +70,12 @@ public static void run(RESTCatalog catalog, String target, boolean json, Option.
6670

6771
List<Table> tablesMetadata = new ArrayList<>();
6872
List<Namespace> namespaces = catalog.listNamespaces();
73+
boolean foundNamespace = false;
6974
for (Namespace namespace : namespaces) {
7075
if (targetNamespace != null && !targetNamespace.equals(namespace.toString())) {
7176
continue;
7277
}
78+
foundNamespace = true;
7379
List<TableIdentifier> tables = catalog.listTables(namespace);
7480
for (TableIdentifier tableId : tables) {
7581
if (targetTable != null && !targetTable.equals(tableId.name())) {
@@ -98,6 +104,12 @@ public static void run(RESTCatalog catalog, String target, boolean json, Option.
98104
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
99105
String output = mapper.writeValueAsString(tablesMetadata);
100106
System.out.println(output);
107+
} else if (targetNamespace != null) {
108+
if (targetTable != null) {
109+
logger.warn("Table {}.{} not found", targetNamespace, targetTable);
110+
} else if (!foundNamespace) {
111+
logger.warn("Namespace {} not found", targetNamespace);
112+
}
101113
}
102114
}
103115

0 commit comments

Comments
 (0)