-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolaris-clear.py
More file actions
40 lines (31 loc) · 1.07 KB
/
polaris-clear.py
File metadata and controls
40 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from pyiceberg.catalog import load_catalog
from utils.timer import Timer
from definitions import (
POLARIS_CATALOG_URL,
POLARIS_WAREHOUSE,
POLARIS_USER_CLIENT_ID,
POLARIS_USER_CLIENT_SECRET,
)
timer = Timer()
polaris_catalog = load_catalog(
"default",
type="rest",
uri=POLARIS_CATALOG_URL,
warehouse=POLARIS_WAREHOUSE, # Think of the warehouse as our workspace
scope="PRINCIPAL_ROLE:ALL",
credential=f"{POLARIS_USER_CLIENT_ID}:{POLARIS_USER_CLIENT_SECRET}",
)
timer.add("load_catalog")
namespaces = polaris_catalog.list_namespaces()
timer.add("list_namespaces")
for namespace in namespaces:
namespace_name, = namespace
tables = polaris_catalog.list_tables(namespace)
timer.add(f"list_tables in namespace {namespace_name}")
for table in tables:
table_namespace_name, table_name = table
polaris_catalog.drop_table(table)
timer.add(f"drop_table {table_name} in namespace {table_namespace_name}")
polaris_catalog.drop_namespace(namespace)
timer.add(f"drop_namespace {namespace_name}")
timer.display()