-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathvacuum_multiple_tables.py
More file actions
40 lines (25 loc) · 942 Bytes
/
vacuum_multiple_tables.py
File metadata and controls
40 lines (25 loc) · 942 Bytes
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
# Databricks notebook source
# MAGIC %md
# MAGIC # Vacuum multiple tables
# MAGIC
# MAGIC With DiscoverX you can run maintenance operations like vacuum over multiple tables at once.
# MAGIC
# MAGIC You can use the wildcard `*` to match any string. Eg. `prod_*.*.*gold*` will match any table containing the word `gold` in a catalog that starts with `prod_`.
# COMMAND ----------
# MAGIC %pip install dbl-discoverx==0.0.9
# COMMAND ----------
dbutils.widgets.text("from_tables", "*.*.*")
from_tables = dbutils.widgets.get("from_tables")
# COMMAND ----------
from discoverx import DX
dx = DX()
# COMMAND ----------
# MAGIC %md
# MAGIC ## Explain the commands that will be executed
# COMMAND ----------
dx.from_tables(from_tables).with_sql("VACUUM {full_table_name}").explain()
# COMMAND ----------
# MAGIC %md
# MAGIC ## Run VACUUM
# COMMAND ----------
(dx.from_tables(from_tables).with_sql("VACUUM {full_table_name}").display())