From 8bf8310254f64ac46405142045834c3fc87f43b0 Mon Sep 17 00:00:00 2001 From: Adam Cain <69544224+adamcain-db@users.noreply.github.com> Date: Thu, 25 Aug 2022 01:36:06 -0700 Subject: [PATCH] Skip information_schema when purging catalog (#539) --- databricks_cli/unity_catalog/catalog_cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/databricks_cli/unity_catalog/catalog_cli.py b/databricks_cli/unity_catalog/catalog_cli.py index 57b756dc..8f3b49b2 100644 --- a/databricks_cli/unity_catalog/catalog_cli.py +++ b/databricks_cli/unity_catalog/catalog_cli.py @@ -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'])