Skip to content

Commit 0579cae

Browse files
jacalataclaude
andcommitted
Sample: stop after Metadata API errors with no data; drop stale remote_type comment
Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent 8c002da commit 0579cae

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎samples/explore_databases_tables.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ def main():
8686
print_permissions(sample_database)
8787

8888
result = server.metadata.query(DATABASE_TABLES_QUERY, {"luid": sample_database.id})
89+
databases_data = (result.get("data") or {}).get("databases") or []
8990
if result.get("errors"):
9091
print(f"\nMetadata API returned errors: {result['errors']}")
91-
databases_data = (result.get("data") or {}).get("databases") or []
92+
if not databases_data:
93+
return
9294
table_refs = databases_data[0]["tables"] if databases_data else []
9395
print(f"\nThere are {len(table_refs)} tables in database {sample_database.name}: ")
9496
print([table_ref["name"] for table_ref in table_refs])
@@ -107,8 +109,7 @@ def main():
107109
server.tables.populate_columns(sample_table)
108110
print(f"\nColumns in table {sample_table.name}: ")
109111
for column in sample_table.columns:
110-
# ColumnItem.remote_type raises AttributeError when the server omits remoteType.
111-
print(f" {column.name} ({getattr(column, 'remote_type', None)})")
112+
print(f" {column.name} ({column.remote_type})")
112113

113114
if args.permissions:
114115
server.tables.populate_permissions(sample_table)

0 commit comments

Comments
 (0)