Skip to content

Commit

Permalink
Skip information_schema when purging catalog (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcain-db authored Aug 25, 2022
1 parent 2212a0b commit 8bf8310
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions databricks_cli/unity_catalog/catalog_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ def delete_catalog_cli(api_client, name, purge):
"""
if purge:
tables_response = UnityCatalogApi(api_client).list_table_summaries(name)
for t in tables_response.get('tables', []):
tables = tables_response.get('tables', [])
tables = filter(lambda t: t['full_name'].split('.')[1] != 'information_schema', tables)
for t in tables:
click.echo("Deleting table: %s" % (t['full_name']))
UnityCatalogApi(api_client).delete_table(t['full_name'])

schemas_response = UnityCatalogApi(api_client).list_schemas(name, None)
for s in schemas_response.get('schemas', []):
schemas = schemas_response.get('schemas', [])
schemas = filter(lambda s: s['name'] != 'information_schema', schemas)
for s in schemas:
click.echo("Purging schema: %s" % (s['full_name']))
UnityCatalogApi(api_client).delete_schema(s['full_name'])

Expand Down

0 comments on commit 8bf8310

Please sign in to comment.