fabricks 3.0.7__py3-none-any.whl → 3.0.9__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/cdc/templates/queries/nocdc/update.sql.jinja +1 -2
- fabricks/core/jobs/gold.py +3 -2
- fabricks/core/schedules/diagrams.py +3 -28
- fabricks/utils/mermaid.py +32 -0
- fabricks/utils/sqlglot.py +2 -1
- {fabricks-3.0.7.dist-info → fabricks-3.0.9.dist-info}/METADATA +1 -1
- {fabricks-3.0.7.dist-info → fabricks-3.0.9.dist-info}/RECORD +8 -7
- {fabricks-3.0.7.dist-info → fabricks-3.0.9.dist-info}/WHEEL +0 -0
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
{% for output in outputs %} c.`{{ output }}`, {% endfor %}
|
|
17
17
|
from __current c
|
|
18
18
|
left anti join
|
|
19
|
-
{{ parent_cdc }} s on s.__key == c.__key
|
|
20
|
-
{% if has_source %} and s.__source = c.__source {% endif %}
|
|
19
|
+
{{ parent_cdc }} s on s.__key == c.__key {% if has_source %} and s.__source = c.__source {% endif %}
|
|
21
20
|
{% endif %}
|
|
22
21
|
),
|
|
23
22
|
{% else %}
|
fabricks/core/jobs/gold.py
CHANGED
|
@@ -13,7 +13,7 @@ from fabricks.core.jobs.base.job import BaseJob
|
|
|
13
13
|
from fabricks.core.udfs import is_registered, register_udf
|
|
14
14
|
from fabricks.metastore.view import create_or_replace_global_temp_view
|
|
15
15
|
from fabricks.utils.path import Path
|
|
16
|
-
from fabricks.utils.sqlglot import get_tables
|
|
16
|
+
from fabricks.utils.sqlglot import fix, get_tables
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class Gold(BaseJob):
|
|
@@ -68,7 +68,8 @@ class Gold(BaseJob):
|
|
|
68
68
|
|
|
69
69
|
@property
|
|
70
70
|
def sql(self) -> str:
|
|
71
|
-
|
|
71
|
+
sql = self.paths.runtime.get_sql()
|
|
72
|
+
return fix(sql, keep_comments=False)
|
|
72
73
|
|
|
73
74
|
@deprecated("use sql instead")
|
|
74
75
|
def get_sql(self) -> str:
|
|
@@ -9,6 +9,8 @@ def get_dependencies(name: str) -> DataFrame:
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def get_mermaid_diagram(name: str) -> str:
|
|
12
|
+
from fabricks.utils.mermaid import get_mermaid_diagram as get_diagram
|
|
13
|
+
|
|
12
14
|
df = get_dependencies(name)
|
|
13
15
|
|
|
14
16
|
df = df.withColumnRenamed("ParentId", "parent_id")
|
|
@@ -16,31 +18,4 @@ def get_mermaid_diagram(name: str) -> str:
|
|
|
16
18
|
df = df.withColumnRenamed("JobId", "job_id")
|
|
17
19
|
df = df.withColumnRenamed("Job", "job")
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
out = "flowchart TD\n"
|
|
22
|
-
|
|
23
|
-
unique_nodes = set()
|
|
24
|
-
|
|
25
|
-
for row in dependencies:
|
|
26
|
-
parent_id = str(row["parent_id"])
|
|
27
|
-
parent_name = str(row["parent"])
|
|
28
|
-
child_id = str(row["job_id"])
|
|
29
|
-
child_name = str(row["job"])
|
|
30
|
-
|
|
31
|
-
if parent_id != "0" and parent_id is not None:
|
|
32
|
-
if parent_id not in unique_nodes:
|
|
33
|
-
out += f" {parent_id}[{parent_name}]\n"
|
|
34
|
-
unique_nodes.add(parent_id)
|
|
35
|
-
|
|
36
|
-
if child_id not in unique_nodes:
|
|
37
|
-
out += f" {child_id}[{child_name}]\n"
|
|
38
|
-
unique_nodes.add(child_id)
|
|
39
|
-
|
|
40
|
-
out += f" {parent_id} --> {child_id}\n"
|
|
41
|
-
else:
|
|
42
|
-
if child_id not in unique_nodes:
|
|
43
|
-
out += f" {child_id}[{child_name}]\n"
|
|
44
|
-
unique_nodes.add(child_id)
|
|
45
|
-
|
|
46
|
-
return out
|
|
21
|
+
return get_diagram(df)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from pyspark.sql import DataFrame
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_mermaid_diagram(df: DataFrame) -> str:
|
|
5
|
+
dependencies = df.select("parent_id", "parent", "job_id", "job").collect()
|
|
6
|
+
|
|
7
|
+
out = "flowchart TD\n"
|
|
8
|
+
|
|
9
|
+
unique_nodes = set()
|
|
10
|
+
|
|
11
|
+
for row in dependencies:
|
|
12
|
+
parent_id = str(row["parent_id"])
|
|
13
|
+
parent_name = str(row["parent"])
|
|
14
|
+
child_id = str(row["job_id"])
|
|
15
|
+
child_name = str(row["job"])
|
|
16
|
+
|
|
17
|
+
if parent_id != "0" and parent_id is not None:
|
|
18
|
+
if parent_id not in unique_nodes:
|
|
19
|
+
out += f" {parent_id}[{parent_name}]\n"
|
|
20
|
+
unique_nodes.add(parent_id)
|
|
21
|
+
|
|
22
|
+
if child_id not in unique_nodes:
|
|
23
|
+
out += f" {child_id}[{child_name}]\n"
|
|
24
|
+
unique_nodes.add(child_id)
|
|
25
|
+
|
|
26
|
+
out += f" {parent_id} --> {child_id}\n"
|
|
27
|
+
else:
|
|
28
|
+
if child_id not in unique_nodes:
|
|
29
|
+
out += f" {child_id}[{child_name}]\n"
|
|
30
|
+
unique_nodes.add(child_id)
|
|
31
|
+
|
|
32
|
+
return out
|
fabricks/utils/sqlglot.py
CHANGED
|
@@ -12,7 +12,7 @@ class Fabricks(Databricks):
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def fix(sql: str):
|
|
15
|
+
def fix(sql: str, keep_comments: bool = True):
|
|
16
16
|
sql = transpile(
|
|
17
17
|
sql,
|
|
18
18
|
"fabricks",
|
|
@@ -22,6 +22,7 @@ def fix(sql: str):
|
|
|
22
22
|
normalize_functions="lower",
|
|
23
23
|
leading_comma=True,
|
|
24
24
|
max_text_width=119,
|
|
25
|
+
comments=keep_comments
|
|
25
26
|
)[0]
|
|
26
27
|
return sql
|
|
27
28
|
|
|
@@ -66,7 +66,7 @@ fabricks/cdc/templates/queries/final.sql.jinja,sha256=vxH434CO5k8Ia7tugaH8LC1co7
|
|
|
66
66
|
fabricks/cdc/templates/queries/scd1.sql.jinja,sha256=siHULgKE3uRBGQYZFUR_eHNqFuGgO9xUCRVV2jnAXAI,3019
|
|
67
67
|
fabricks/cdc/templates/queries/scd2.sql.jinja,sha256=Nn0wUs9N-_QviZqUKRWAFdD17RR3EFBTMs9BpBu6z7E,3877
|
|
68
68
|
fabricks/cdc/templates/queries/nocdc/complete.sql.jinja,sha256=cVKKCSbiuuw1K7BOzfusX6KvzQNHU3YNUgoXgsu-c6k,267
|
|
69
|
-
fabricks/cdc/templates/queries/nocdc/update.sql.jinja,sha256=
|
|
69
|
+
fabricks/cdc/templates/queries/nocdc/update.sql.jinja,sha256=mjNUwGVhZ08yUkdv9sCTkqyW60p0YavtWTqvSUVrwjA,1283
|
|
70
70
|
fabricks/context/__init__.py,sha256=qfntJ9O6omzY_t6AhDP6Ndu9C5LMiVdWbo6ikhtoe7o,1446
|
|
71
71
|
fabricks/context/_types.py,sha256=FzQJ35vp0uc6pAq18bc-VHwMVEWtd0VDdm8xQmNr2Sg,2681
|
|
72
72
|
fabricks/context/log.py,sha256=CadrRf8iL6iXlGIGIhEIswa7wGqC-E-oLwWcGTyJ10s,2074
|
|
@@ -98,7 +98,7 @@ fabricks/core/jobs/get_job_id.py,sha256=6dLyzxGHlRvJZVJSwZkCk3iXzWkIhePC_6FhoP0g
|
|
|
98
98
|
fabricks/core/jobs/get_jobs.py,sha256=nJ-8DPFq1GyzWo9Mxlwq2dEeAqwg1jeQg-CHietAb1Q,3341
|
|
99
99
|
fabricks/core/jobs/get_schedule.py,sha256=46pJR5LWZfuxUtLBmtB-RP6ng_W-K-ahJmD29KNmcGw,259
|
|
100
100
|
fabricks/core/jobs/get_schedules.py,sha256=kryDUBrBrtAaMp8Ou5YqMOCOMKvg1GmbbOQBtiiRleM,794
|
|
101
|
-
fabricks/core/jobs/gold.py,sha256=
|
|
101
|
+
fabricks/core/jobs/gold.py,sha256=lwzUG-z0ACWUiR7EpDNbrrh7X7XwnixgrMoIptzK7uE,14552
|
|
102
102
|
fabricks/core/jobs/silver.py,sha256=kdrCBfh1jkhWJUFubGUV4kxan5eRUZl-LI-iSJxyJE4,13093
|
|
103
103
|
fabricks/core/jobs/base/__init__.py,sha256=_AdWtyL7yZG2TOZ9e8WyNPrOjmm6EDkI_TNym5cLDws,208
|
|
104
104
|
fabricks/core/jobs/base/_types.py,sha256=y66BtJlJskq7wGzn7te5XYjO-NEqeQGUC11kkbew8AU,8405
|
|
@@ -116,7 +116,7 @@ fabricks/core/parsers/decorator.py,sha256=kn_Mj-JLWTFaRiciZ3KavmSUcWFPY3ve-buMru
|
|
|
116
116
|
fabricks/core/parsers/get_parser.py,sha256=TTnVPwKqKpFu6jJJnXEuiEctWGtimk8w2p1jF2U7ibg,909
|
|
117
117
|
fabricks/core/parsers/utils.py,sha256=qdn2ElpqBgDsW55-tACWZaFOT0ebrBYg2fenqSgd6YI,2456
|
|
118
118
|
fabricks/core/schedules/__init__.py,sha256=bDjNMcm7itimAo4gun0W4W9bZKwZmWUjkMqAQIcqI2Y,431
|
|
119
|
-
fabricks/core/schedules/diagrams.py,sha256=
|
|
119
|
+
fabricks/core/schedules/diagrams.py,sha256=YA4T7Etl_UPfW-3IGFq5Xj9OlXZGQ27Aot6RVa3ZUgg,578
|
|
120
120
|
fabricks/core/schedules/generate.py,sha256=aKnAe7ZCafAczLa4ka9Er_oltOxgXyNoS63_OZEktcE,623
|
|
121
121
|
fabricks/core/schedules/get_schedule.py,sha256=PJcEq4enlsRJunS-MjXi-VFIczbeuBStP2giZ_-EaRc,116
|
|
122
122
|
fabricks/core/schedules/get_schedules.py,sha256=b6KSl-QmiNgih2l6dESB0va9yDVxaGOJ_ZB96Wc3NC8,174
|
|
@@ -154,11 +154,12 @@ fabricks/utils/console.py,sha256=X4lLgL_UxCjoFRx-ZRCwzdBveRGPKlFYZDi6vl7uevQ,101
|
|
|
154
154
|
fabricks/utils/fdict.py,sha256=cdnvNBSXKJIDKSdhQGJA4CGv0qLn5IVYKQ111l7nM9I,7978
|
|
155
155
|
fabricks/utils/helpers.py,sha256=h7SuOVpBP5qcgX1nM1suvkXG9BhiK5-257EBepCvrO8,7452
|
|
156
156
|
fabricks/utils/log.py,sha256=LCQEM81PhdojiyLrtEzv1QM__bWbaEhGddyd0IqyGXM,7985
|
|
157
|
+
fabricks/utils/mermaid.py,sha256=XoiVxPaUJS4TC_ybA-e78qFzQkQ46uPf055JiiNDdSg,986
|
|
157
158
|
fabricks/utils/path.py,sha256=Bs3PayWtg62-mrsDbvu8kh0VLZZhX7tU9YiyHFiYNhs,6698
|
|
158
159
|
fabricks/utils/pip.py,sha256=UHo7NTjFGJNghWBuuDow28xUkZYg2YrlbAP49IxZyXY,1522
|
|
159
160
|
fabricks/utils/pydantic.py,sha256=W0fiDLVMFrrInfQw2s5YPeSEvkN-4k864u3UyPoHaz4,2516
|
|
160
161
|
fabricks/utils/spark.py,sha256=QWVpbGwOvURIVBlR7ygt6NQ9MHUsIDvlquJ65iI8UBI,2007
|
|
161
|
-
fabricks/utils/sqlglot.py,sha256=
|
|
162
|
+
fabricks/utils/sqlglot.py,sha256=Wohw61ntA0J8eieQ5MYCMdDUMiN8S8do2V0dKlRM8Mg,1498
|
|
162
163
|
fabricks/utils/read/__init__.py,sha256=a_5l60m1AyzQUII170bfRRuXR_ynC3EwfysidRy44GE,272
|
|
163
164
|
fabricks/utils/read/_types.py,sha256=_YY0Yp8IPNYvcRFNa9WMcIl20cN93Cdcgh3jddypnuk,76
|
|
164
165
|
fabricks/utils/read/read.py,sha256=el6GvynJrCl2Ap_bM7xY750fSXjrr9xmp14P92h-40g,8401
|
|
@@ -170,6 +171,6 @@ fabricks/utils/schema/get_schema_for_type.py,sha256=5k-R6zCgUAtapQgxT4turcx1IQ-b
|
|
|
170
171
|
fabricks/utils/write/__init__.py,sha256=i0UnZenXj9Aq0b0_aU3s6882vg-Vu_AyKfQhl_dTp-g,200
|
|
171
172
|
fabricks/utils/write/delta.py,sha256=lTQ0CfUhcvn3xTCcT_Ns6PMDBsO5UEfa2S9XpJiLJ9c,1250
|
|
172
173
|
fabricks/utils/write/stream.py,sha256=wQBpAnQtYA6nl79sPKhVM6u5m-66suX7B6VQ6tW4TOs,622
|
|
173
|
-
fabricks-3.0.
|
|
174
|
-
fabricks-3.0.
|
|
175
|
-
fabricks-3.0.
|
|
174
|
+
fabricks-3.0.9.dist-info/METADATA,sha256=E5DsWLV3UwSrgce4HALc7E51JBKKcYrWTh9SpVvKIos,761
|
|
175
|
+
fabricks-3.0.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
176
|
+
fabricks-3.0.9.dist-info/RECORD,,
|
|
File without changes
|