fabricks 3.0.5.2__py3-none-any.whl → 3.0.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fabricks/api/__init__.py +2 -0
- fabricks/api/context.py +1 -2
- fabricks/api/deploy.py +3 -0
- fabricks/api/job_schema.py +2 -2
- fabricks/api/masks.py +3 -0
- fabricks/api/notebooks/initialize.py +2 -2
- fabricks/api/notebooks/process.py +2 -2
- fabricks/api/notebooks/run.py +2 -2
- fabricks/api/notebooks/schedule.py +75 -0
- fabricks/api/notebooks/terminate.py +2 -2
- fabricks/api/schedules.py +2 -16
- fabricks/cdc/__init__.py +2 -2
- fabricks/cdc/base/__init__.py +2 -2
- fabricks/cdc/base/_types.py +9 -2
- fabricks/cdc/base/configurator.py +86 -41
- fabricks/cdc/base/generator.py +44 -35
- fabricks/cdc/base/merger.py +16 -14
- fabricks/cdc/base/processor.py +232 -144
- fabricks/cdc/nocdc.py +8 -7
- fabricks/cdc/templates/{query → ctes}/base.sql.jinja +7 -6
- fabricks/cdc/templates/ctes/current.sql.jinja +28 -0
- fabricks/cdc/templates/ctes/deduplicate_hash.sql.jinja +32 -0
- fabricks/cdc/templates/ctes/deduplicate_key.sql.jinja +31 -0
- fabricks/cdc/templates/{query → ctes}/rectify.sql.jinja +4 -22
- fabricks/cdc/templates/ctes/slice.sql.jinja +1 -0
- fabricks/cdc/templates/filter.sql.jinja +4 -4
- fabricks/cdc/templates/macros/bactick.sql.jinja +1 -0
- fabricks/cdc/templates/macros/hash.sql.jinja +18 -0
- fabricks/cdc/templates/merge.sql.jinja +3 -2
- fabricks/cdc/templates/merges/nocdc.sql.jinja +41 -0
- fabricks/cdc/templates/queries/context.sql.jinja +186 -0
- fabricks/cdc/templates/{query/nocdc.sql.jinja → queries/nocdc/complete.sql.jinja} +1 -1
- fabricks/cdc/templates/queries/nocdc/update.sql.jinja +35 -0
- fabricks/cdc/templates/{query → queries}/scd1.sql.jinja +2 -28
- fabricks/cdc/templates/{query → queries}/scd2.sql.jinja +29 -48
- fabricks/cdc/templates/query.sql.jinja +15 -11
- fabricks/context/__init__.py +18 -4
- fabricks/context/_types.py +2 -0
- fabricks/context/config/__init__.py +92 -0
- fabricks/context/config/utils.py +53 -0
- fabricks/context/log.py +8 -2
- fabricks/context/runtime.py +87 -263
- fabricks/context/secret.py +1 -1
- fabricks/context/spark_session.py +1 -1
- fabricks/context/utils.py +80 -0
- fabricks/core/dags/generator.py +6 -7
- fabricks/core/dags/log.py +2 -15
- fabricks/core/dags/processor.py +11 -11
- fabricks/core/dags/utils.py +15 -1
- fabricks/core/{scripts/job_schema.py → job_schema.py} +4 -0
- fabricks/core/jobs/base/_types.py +64 -22
- fabricks/core/jobs/base/checker.py +13 -12
- fabricks/core/jobs/base/configurator.py +41 -67
- fabricks/core/jobs/base/generator.py +55 -24
- fabricks/core/jobs/base/invoker.py +54 -30
- fabricks/core/jobs/base/processor.py +43 -26
- fabricks/core/jobs/bronze.py +45 -38
- fabricks/core/jobs/get_jobs.py +2 -2
- fabricks/core/jobs/get_schedule.py +10 -0
- fabricks/core/jobs/get_schedules.py +32 -0
- fabricks/core/jobs/gold.py +61 -48
- fabricks/core/jobs/silver.py +39 -40
- fabricks/core/masks.py +52 -0
- fabricks/core/parsers/base.py +2 -2
- fabricks/core/schedules/__init__.py +14 -0
- fabricks/core/schedules/diagrams.py +46 -0
- fabricks/core/schedules/get_schedule.py +5 -0
- fabricks/core/schedules/get_schedules.py +9 -0
- fabricks/core/schedules/run.py +3 -0
- fabricks/core/schedules/views.py +61 -0
- fabricks/core/steps/base.py +110 -72
- fabricks/core/udfs.py +12 -23
- fabricks/core/views.py +20 -13
- fabricks/deploy/__init__.py +97 -0
- fabricks/deploy/masks.py +8 -0
- fabricks/deploy/notebooks.py +71 -0
- fabricks/deploy/schedules.py +8 -0
- fabricks/{core/deploy → deploy}/tables.py +16 -13
- fabricks/{core/deploy → deploy}/udfs.py +3 -1
- fabricks/deploy/utils.py +36 -0
- fabricks/{core/deploy → deploy}/views.py +5 -9
- fabricks/metastore/database.py +3 -3
- fabricks/metastore/dbobject.py +4 -4
- fabricks/metastore/table.py +157 -88
- fabricks/metastore/view.py +13 -6
- fabricks/utils/_types.py +6 -0
- fabricks/utils/azure_table.py +4 -3
- fabricks/utils/helpers.py +141 -11
- fabricks/utils/log.py +29 -18
- fabricks/utils/read/_types.py +1 -1
- fabricks/utils/schema/get_schema_for_type.py +6 -0
- fabricks/utils/write/delta.py +3 -3
- {fabricks-3.0.5.2.dist-info → fabricks-3.0.7.dist-info}/METADATA +2 -1
- fabricks-3.0.7.dist-info/RECORD +175 -0
- fabricks/api/notebooks/add_fabricks.py +0 -13
- fabricks/api/notebooks/optimize.py +0 -29
- fabricks/api/notebooks/vacuum.py +0 -29
- fabricks/cdc/templates/query/context.sql.jinja +0 -101
- fabricks/cdc/templates/query/current.sql.jinja +0 -32
- fabricks/cdc/templates/query/deduplicate_hash.sql.jinja +0 -21
- fabricks/cdc/templates/query/deduplicate_key.sql.jinja +0 -14
- fabricks/cdc/templates/query/hash.sql.jinja +0 -1
- fabricks/cdc/templates/query/slice.sql.jinja +0 -14
- fabricks/config/__init__.py +0 -0
- fabricks/config/base.py +0 -8
- fabricks/config/fabricks/__init__.py +0 -26
- fabricks/config/fabricks/base.py +0 -90
- fabricks/config/fabricks/environment.py +0 -9
- fabricks/config/fabricks/pyproject.py +0 -47
- fabricks/config/jobs/__init__.py +0 -6
- fabricks/config/jobs/base.py +0 -101
- fabricks/config/jobs/bronze.py +0 -38
- fabricks/config/jobs/gold.py +0 -27
- fabricks/config/jobs/silver.py +0 -22
- fabricks/config/runtime.py +0 -67
- fabricks/config/steps/__init__.py +0 -6
- fabricks/config/steps/base.py +0 -50
- fabricks/config/steps/bronze.py +0 -7
- fabricks/config/steps/gold.py +0 -14
- fabricks/config/steps/silver.py +0 -15
- fabricks/core/deploy/__init__.py +0 -17
- fabricks/core/schedules.py +0 -142
- fabricks/core/scripts/__init__.py +0 -9
- fabricks/core/scripts/armageddon.py +0 -87
- fabricks/core/scripts/stats.py +0 -51
- fabricks/core/scripts/steps.py +0 -26
- fabricks-3.0.5.2.dist-info/RECORD +0 -177
- /fabricks/cdc/templates/{filter → filters}/final.sql.jinja +0 -0
- /fabricks/cdc/templates/{filter → filters}/latest.sql.jinja +0 -0
- /fabricks/cdc/templates/{filter → filters}/update.sql.jinja +0 -0
- /fabricks/cdc/templates/{merge → merges}/scd1.sql.jinja +0 -0
- /fabricks/cdc/templates/{merge → merges}/scd2.sql.jinja +0 -0
- /fabricks/cdc/templates/{query → queries}/__init__.py +0 -0
- /fabricks/cdc/templates/{query → queries}/final.sql.jinja +0 -0
- /fabricks/core/{utils.py → parsers/utils.py} +0 -0
- /fabricks/core/{scripts → schedules}/generate.py +0 -0
- /fabricks/core/{scripts → schedules}/process.py +0 -0
- /fabricks/core/{scripts → schedules}/terminate.py +0 -0
- {fabricks-3.0.5.2.dist-info → fabricks-3.0.7.dist-info}/WHEEL +0 -0
|
@@ -7,7 +7,7 @@ from fabricks.metastore.table import Table
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def deploy_tables(drop: bool = False):
|
|
10
|
-
DEFAULT_LOGGER.info("
|
|
10
|
+
DEFAULT_LOGGER.info("create or replace fabricks (default) tables")
|
|
11
11
|
|
|
12
12
|
create_table_log(drop)
|
|
13
13
|
create_table_dummy(drop)
|
|
@@ -64,16 +64,19 @@ def create_table_log(drop: bool = False):
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
def create_table_dummy(drop: bool = False):
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"""
|
|
70
|
-
select
|
|
71
|
-
1 as __key,
|
|
72
|
-
md5('1') as __hash,
|
|
73
|
-
cast('1900-01-01' as timestamp) as __valid_from,
|
|
74
|
-
cast('9999-12-31' as timestamp) as __valid_to
|
|
75
|
-
"""
|
|
76
|
-
)
|
|
67
|
+
cdc = NoCDC("fabricks", "dummy")
|
|
68
|
+
|
|
77
69
|
if drop:
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
cdc.drop()
|
|
71
|
+
|
|
72
|
+
if not cdc.table.exists():
|
|
73
|
+
df = SPARK.sql(
|
|
74
|
+
"""
|
|
75
|
+
select
|
|
76
|
+
1 as __key,
|
|
77
|
+
md5('1') as __hash,
|
|
78
|
+
cast('1900-01-01' as timestamp) as __valid_from,
|
|
79
|
+
cast('9999-12-31' as timestamp) as __valid_to
|
|
80
|
+
"""
|
|
81
|
+
)
|
|
82
|
+
cdc.overwrite(df)
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
from fabricks.context import SPARK
|
|
2
2
|
from fabricks.context.log import DEFAULT_LOGGER
|
|
3
|
+
from fabricks.core.udfs import register_all_udfs
|
|
3
4
|
from fabricks.utils.sqlglot import fix as fix_sql
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
def deploy_udfs():
|
|
7
|
-
DEFAULT_LOGGER.info("
|
|
8
|
+
DEFAULT_LOGGER.info("create or replace udfs")
|
|
8
9
|
|
|
10
|
+
register_all_udfs(extension="sql")
|
|
9
11
|
create_or_replace_udf_job_id()
|
|
10
12
|
|
|
11
13
|
|
fabricks/deploy/utils.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def print_atomic_bomb(nowait: bool = False):
|
|
5
|
+
def print_and_wait(message: str):
|
|
6
|
+
if not nowait:
|
|
7
|
+
time.sleep(0.5)
|
|
8
|
+
print(message)
|
|
9
|
+
|
|
10
|
+
print("")
|
|
11
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠤⠴⠾⠋⠉⠛⢾⡏⠙⠿⠦⠤⢤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
12
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡤⢶⣿⠉⢀⣀⡠⠆⠀⠀⠀⠀⠀⠀⠀⢤⣀⣀⠈⢹⣦⢤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
13
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠁⢋⡙⠁⠀⡝⠀⠀⠀⠀⣀⡸⠋⠁⠀⠀⠹⡀⠀⠈⠈⠆⢹⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
14
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣿⣁⡡⣴⡏⠀⠀⠀⢀⠀⢧⣀⠄⠀⠀⠀⣀⣰⠆⢀⠁⠀⠀⢈⣶⡤⣀⢹⣦⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
15
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⣠⢴⠟⢁⡝⠀⠁⠀⠃⠉⠀⠀⠘⣯⠀⡀⠾⣤⣄⣠⢤⠾⠄⠀⣸⠖⠀⠀⠈⠀⠃⠀⠀⠹⡄⠙⣶⢤⡀⠀⠀⠀⠀⠀ ")
|
|
16
|
+
print_and_wait(" ⠀⠀⠀⣠⠾⡇⠈⣀⡞⠀⠀⠀⠀⡀⠀⢀⣠⣄⣇⠀⣳⠴⠃⠀⠀⠀⠣⢴⠉⣰⣇⣀⣀⠀⠀⡄⠀⠀⠀⢹⣄⡘⠈⡷⣦⠀⠀⠀⠀ ")
|
|
17
|
+
print_and_wait(" ⢠⠞⠉⢻⡄⠀⠀⠈⠙⠀⠀⠀⠀⠙⣶⣏⣤⣤⠟⠉⠁⠀⠀⠀⠀⠀⠀⠀⠉⠙⢦⣱⣌⣷⠊⠀⠀⠀⠀⠈⠁⠀⠀⠀⡝⠉⠻⣄⠀ ")
|
|
18
|
+
print_and_wait(" ⠛⢀⡠⢼⡇⠀⠀⢀⡄⠀⢀⣀⡽⠚⠁⠀⠀⠀⢠⡀⢠⣀⠠⣔⢁⡀⠀⣄⠀⡄⠀⠀⠀⠈⠑⠺⣄⡀⠀⠠⡀⠀⠀⢠⡧⠄⠀⠘⢧ ")
|
|
19
|
+
print_and_wait(" ⡶⠋⠀⠀⠈⣠⣈⣩⠗⠒⠋⠀⠀⠀⠀⣀⣠⣆⡼⣷⣞⠛⠻⡉⠉⡟⠒⡛⣶⠧⣀⣀⣀⠀⠀⠀⠀⠈⠓⠺⢏⣉⣠⠋⠀⠀⠀⢢⣸ ")
|
|
20
|
+
print_and_wait(" ⠇⠐⠤⠤⠖⠁⣿⣀⣀⠀⠀⠀⠀⠀⠉⠁⠈⠉⠙⠛⢿⣷⡄⢣⡼⠀⣾⣿⠧⠒⠓⠚⠛⠉⠀⠀⠀⠀⠀⢀⣀⣾⡉⠓⠤⡤⠄⠸⢿ ")
|
|
21
|
+
print_and_wait(" ⣆⣤⠀⠀⠠⠀⠈⠓⠈⠓⠤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣿⢸⠀⢸⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⢀⡤⠒⠁⠰⠃⠀⠠⠀⠀⢀⣀⠞ ")
|
|
22
|
+
print_and_wait(" ⠀⠉⠓⢲⣄⡈⢀⣠⠀⠀⠀⡸⠶⠂⠀⠀⢀⠀⠀⠤⠞⢻⡇⠀⠀⢘⡟⠑⠤⠄⠀⢀⠀⠀⠐⠲⢿⡀⠀⠀⢤⣀⢈⣀⡴⠖⠋⠀⠀ ")
|
|
23
|
+
print_and_wait(" ⠀⠀⠀⠀⠈⠉⠉⠙⠓⠒⣾⣁⣀⣴⠀⣀⠙⢧⠂⢀⣆⣀⣷⣤⣀⣾⣇⣀⡆⠀⢢⠛⢁⠀⢰⣀⣀⣹⠒⠒⠛⠉⠉⠉⠀⠀⠀⠀⠀ ")
|
|
24
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠁⠈⠉⠉⠛⠉⠙⠉⠀⠀⣿⡟⣿⣿⠀⠀⠈⠉⠉⠙⠋⠉⠉⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
25
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⢻⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
26
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⠁⠀⢹⡛⣟⡶⢤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
27
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⠛⢯⣽⡟⢿⣿⠛⠿⠳⠞⠻⣿⠻⣆⢽⠟⣶⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
28
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛⠃⠲⠯⠴⣦⣼⣷⣤⣤⣶⣤⣩⡧⠽⠷⠐⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
29
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⡇⠀⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
30
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣄⡀⢀⣀⣠⡾⡿⢡⢐⠻⣿⣄⣀⡀⠀⣀⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
31
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⢴⡏⠁⠀⠝⠉⣡⠟⣰⠃⢸⣿⠀⣷⠙⢧⡉⠻⡅⠀⠙⡷⢤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
32
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⡟⠀⠈⣿⢄⡴⠞⠻⣄⣰⣡⠤⣞⣸⡤⢬⣧⣀⡿⠛⠦⣤⣶⡃⠀⢹⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ")
|
|
33
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠀⢀⣴⣶⡿⠃⠉⢺⠁⠙⠒⠀⠀⣠⡉⠀⠉⠚⠉⠉⠑⠈⠀⠈⣧⠀⠀⠒⠋⠀⡹⠋⠀⢻⡶⠶⡄⠀⠀⠀⠀⠀⠀⠀ ")
|
|
34
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⣠⣾⣿⣇⠁⢈⡦⠀⡍⠋⠁⡀⠸⡋⠀⠀⠀⢘⠏⠉⡏⠀⠀⠀⢉⡷⠀⡌⠉⠋⡇⠠⣏⠈⢁⣦⣿⣦⠀⠀⠀⠀⠀⠀ ")
|
|
35
|
+
print_and_wait(" ⠀⠀⠀⠀⠀⠉⣁⠀⠉⠉⠉⠙⠛⠛⠒⠚⠳⠤⢼⣤⣠⠤⣮⣠⣤⣼⠦⢤⣤⣿⠤⠾⠓⠒⠛⢓⠛⠉⠉⠉⠀⠈⠉⠀⠀⠀⠀⠀⠀ ")
|
|
36
|
+
print("")
|
|
@@ -5,24 +5,20 @@ from fabricks.utils.sqlglot import fix as fix_sql
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def deploy_views():
|
|
8
|
-
DEFAULT_LOGGER.info("
|
|
8
|
+
DEFAULT_LOGGER.info("create or replace fabricks (default) views")
|
|
9
9
|
|
|
10
10
|
create_or_replace_jobs_view()
|
|
11
11
|
create_or_replace_tables_view()
|
|
12
12
|
create_or_replace_views_view()
|
|
13
|
-
|
|
14
13
|
create_or_replace_logs_pivot_view()
|
|
15
14
|
create_or_replace_last_schedule_view()
|
|
16
15
|
create_or_replace_last_status_view()
|
|
17
16
|
create_or_replace_previous_schedule_view()
|
|
18
|
-
|
|
19
17
|
create_or_replace_schedules_view()
|
|
20
|
-
|
|
21
18
|
create_or_replace_dependencies_view()
|
|
22
19
|
create_or_replace_dependencies_flat_view()
|
|
23
20
|
create_or_replace_dependencies_unpivot_view()
|
|
24
21
|
create_or_replace_dependencies_circular_view()
|
|
25
|
-
|
|
26
22
|
create_or_replace_jobs_to_be_updated_view()
|
|
27
23
|
|
|
28
24
|
|
|
@@ -73,7 +69,7 @@ def create_or_replace_jobs_view():
|
|
|
73
69
|
dmls.append(dml)
|
|
74
70
|
|
|
75
71
|
except Exception:
|
|
76
|
-
DEFAULT_LOGGER.
|
|
72
|
+
DEFAULT_LOGGER.debug(f"could not find fabricks.{table}")
|
|
77
73
|
|
|
78
74
|
sql = f"""create or replace view fabricks.jobs with schema evolution as {" union all ".join(dmls)}"""
|
|
79
75
|
sql = fix_sql(sql)
|
|
@@ -100,7 +96,7 @@ def create_or_replace_tables_view():
|
|
|
100
96
|
dmls.append(dml)
|
|
101
97
|
|
|
102
98
|
except Exception:
|
|
103
|
-
DEFAULT_LOGGER.
|
|
99
|
+
DEFAULT_LOGGER.debug(f"could not find fabricks.{step}_tables")
|
|
104
100
|
|
|
105
101
|
sql = f"""create or replace view fabricks.tables with schema evolution as {" union all ".join(dmls)}"""
|
|
106
102
|
sql = fix_sql(sql)
|
|
@@ -127,7 +123,7 @@ def create_or_replace_views_view():
|
|
|
127
123
|
dmls.append(dml)
|
|
128
124
|
|
|
129
125
|
except Exception:
|
|
130
|
-
DEFAULT_LOGGER.
|
|
126
|
+
DEFAULT_LOGGER.debug(f"could not find fabricks.{step}_views")
|
|
131
127
|
|
|
132
128
|
sql = f"""create or replace view fabricks.views with schema evolution as {" union all ".join(dmls)}"""
|
|
133
129
|
sql = fix_sql(sql)
|
|
@@ -157,7 +153,7 @@ def create_or_replace_dependencies_view():
|
|
|
157
153
|
dmls.append(dml)
|
|
158
154
|
|
|
159
155
|
except Exception:
|
|
160
|
-
DEFAULT_LOGGER.
|
|
156
|
+
DEFAULT_LOGGER.debug(f"could not find fabricks.{step}_dependencies")
|
|
161
157
|
|
|
162
158
|
sql = f"""create or replace view fabricks.dependencies with schema evolution as {" union all ".join(dmls)}"""
|
|
163
159
|
sql = fix_sql(sql)
|
fabricks/metastore/database.py
CHANGED
|
@@ -33,17 +33,17 @@ class Database:
|
|
|
33
33
|
return self.storage.joinpath("delta")
|
|
34
34
|
|
|
35
35
|
def create(self):
|
|
36
|
-
DEFAULT_LOGGER.info("
|
|
36
|
+
DEFAULT_LOGGER.info("create database", extra={"label": self})
|
|
37
37
|
self.spark.sql(f"create database if not exists {self.name};")
|
|
38
38
|
|
|
39
39
|
def drop(self, rm: Optional[bool] = True):
|
|
40
40
|
if self.exists():
|
|
41
|
-
DEFAULT_LOGGER.warning("
|
|
41
|
+
DEFAULT_LOGGER.warning("drop database", extra={"label": self})
|
|
42
42
|
self.spark.sql(f"drop database if exists {self.name} cascade;")
|
|
43
43
|
|
|
44
44
|
if rm:
|
|
45
45
|
if self.delta_path.exists():
|
|
46
|
-
DEFAULT_LOGGER.debug("
|
|
46
|
+
DEFAULT_LOGGER.debug("remove delta files", extra={"label": self})
|
|
47
47
|
self.delta_path.rm()
|
|
48
48
|
|
|
49
49
|
def exists(self) -> bool:
|
fabricks/metastore/dbobject.py
CHANGED
|
@@ -29,7 +29,7 @@ class DbObject:
|
|
|
29
29
|
return f"{self.database.name}.{self.name}"
|
|
30
30
|
|
|
31
31
|
@property
|
|
32
|
-
def
|
|
32
|
+
def registered(self) -> bool:
|
|
33
33
|
try:
|
|
34
34
|
df = self.spark.sql(f"show tables in {self.database}").where(f"tableName == '{self.name}'")
|
|
35
35
|
return not df.isEmpty()
|
|
@@ -51,15 +51,15 @@ class DbObject:
|
|
|
51
51
|
if self.is_view:
|
|
52
52
|
return False
|
|
53
53
|
else:
|
|
54
|
-
return self.
|
|
54
|
+
return self.registered
|
|
55
55
|
|
|
56
56
|
def drop(self):
|
|
57
57
|
if self.is_view:
|
|
58
|
-
DEFAULT_LOGGER.warning("drop view from metastore", extra={"
|
|
58
|
+
DEFAULT_LOGGER.warning("drop view from metastore", extra={"label": self})
|
|
59
59
|
self.spark.sql(f"drop view if exists {self}")
|
|
60
60
|
|
|
61
61
|
elif self.is_table:
|
|
62
|
-
DEFAULT_LOGGER.warning("drop table from metastore", extra={"
|
|
62
|
+
DEFAULT_LOGGER.warning("drop table from metastore", extra={"label": self})
|
|
63
63
|
self.spark.sql(f"drop table if exists {self}")
|
|
64
64
|
|
|
65
65
|
def __str__(self):
|