fabricks 3.0.17__py3-none-any.whl → 3.0.19__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/context/_types.py +6 -0
- fabricks/core/jobs/gold.py +15 -4
- fabricks/core/udfs.py +9 -8
- fabricks/utils/path.py +10 -0
- {fabricks-3.0.17.dist-info → fabricks-3.0.19.dist-info}/METADATA +1 -1
- {fabricks-3.0.17.dist-info → fabricks-3.0.19.dist-info}/RECORD +7 -7
- {fabricks-3.0.17.dist-info → fabricks-3.0.19.dist-info}/WHEEL +0 -0
fabricks/context/_types.py
CHANGED
|
@@ -17,6 +17,11 @@ class RuntimeTimeoutOptions(TypedDict):
|
|
|
17
17
|
post_run: int
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
class UDFOptions(TypedDict):
|
|
21
|
+
prefix: Optional[str]
|
|
22
|
+
schema: Optional[str]
|
|
23
|
+
|
|
24
|
+
|
|
20
25
|
class StepTimeoutOptions(TypedDict):
|
|
21
26
|
step: Optional[int]
|
|
22
27
|
job: Optional[int]
|
|
@@ -123,6 +128,7 @@ class Conf(TypedDict):
|
|
|
123
128
|
options: RuntimeOptions
|
|
124
129
|
path_options: RuntimePathOptions
|
|
125
130
|
extender_options: Optional[ExtenderOptions]
|
|
131
|
+
udf_options: Optional[UDFOptions]
|
|
126
132
|
spark_options: SparkOptions
|
|
127
133
|
bronze: Optional[List[Bronze]]
|
|
128
134
|
silver: Optional[List[Silver]]
|
fabricks/core/jobs/gold.py
CHANGED
|
@@ -10,7 +10,7 @@ from fabricks.cdc.nocdc import NoCDC
|
|
|
10
10
|
from fabricks.context.log import DEFAULT_LOGGER
|
|
11
11
|
from fabricks.core.jobs.base._types import JobDependency, TGold
|
|
12
12
|
from fabricks.core.jobs.base.job import BaseJob
|
|
13
|
-
from fabricks.core.udfs import is_registered, register_udf
|
|
13
|
+
from fabricks.core.udfs import is_registered, register_udf, udf_prefix
|
|
14
14
|
from fabricks.metastore.view import create_or_replace_global_temp_view
|
|
15
15
|
from fabricks.utils.path import Path
|
|
16
16
|
from fabricks.utils.sqlglot import fix, get_tables
|
|
@@ -90,8 +90,8 @@ class Gold(BaseJob):
|
|
|
90
90
|
|
|
91
91
|
else:
|
|
92
92
|
matches = []
|
|
93
|
-
if "
|
|
94
|
-
r = re.compile(
|
|
93
|
+
if f"{udf_prefix}" in self.sql:
|
|
94
|
+
r = re.compile(rf"(?<={udf_prefix})\w*(?=\()")
|
|
95
95
|
matches = re.findall(r, self.sql)
|
|
96
96
|
matches = set(matches)
|
|
97
97
|
matches = list(matches)
|
|
@@ -126,7 +126,18 @@ class Gold(BaseJob):
|
|
|
126
126
|
invokers = self.options.invokers.get_list("run")
|
|
127
127
|
assert len(invokers) <= 1, "at most one invoker allowed when notebook is true"
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
path = None
|
|
130
|
+
if invokers:
|
|
131
|
+
notebook = invokers[0].get("notebook")
|
|
132
|
+
if notebook:
|
|
133
|
+
from fabricks.context import PATH_RUNTIME
|
|
134
|
+
|
|
135
|
+
path = PATH_RUNTIME.joinpath(notebook)
|
|
136
|
+
|
|
137
|
+
if path is None:
|
|
138
|
+
path = self.paths.runtime
|
|
139
|
+
|
|
140
|
+
global_temp_view = self.invoke(path=path, schema_only=schema_only, **kwargs)
|
|
130
141
|
assert global_temp_view is not None, "global_temp_view not found"
|
|
131
142
|
|
|
132
143
|
df = self.spark.sql(f"select * from global_temp.{global_temp_view}")
|
fabricks/core/udfs.py
CHANGED
|
@@ -5,11 +5,14 @@ from typing import Callable, List, Optional
|
|
|
5
5
|
|
|
6
6
|
from pyspark.sql import SparkSession
|
|
7
7
|
|
|
8
|
-
from fabricks.context import CATALOG, IS_UNITY_CATALOG, PATH_UDFS, SPARK
|
|
8
|
+
from fabricks.context import CATALOG, CONF_RUNTIME, IS_UNITY_CATALOG, PATH_UDFS, SPARK
|
|
9
9
|
from fabricks.context.log import DEFAULT_LOGGER
|
|
10
10
|
|
|
11
11
|
UDFS: dict[str, Callable] = {}
|
|
12
12
|
|
|
13
|
+
udf_schema = CONF_RUNTIME.get("udf_options", {}).get("schema", "default")
|
|
14
|
+
udf_prefix = CONF_RUNTIME.get("udf_options", {}).get("prefix", "udf_")
|
|
15
|
+
|
|
13
16
|
|
|
14
17
|
def register_all_udfs(extension: Optional[str] = None, override: bool = False):
|
|
15
18
|
"""
|
|
@@ -47,12 +50,12 @@ def is_registered(udf: str, spark: Optional[SparkSession] = None) -> bool:
|
|
|
47
50
|
spark = SPARK
|
|
48
51
|
assert spark is not None
|
|
49
52
|
|
|
50
|
-
df = spark.sql("show user functions in
|
|
53
|
+
df = spark.sql(f"show user functions in {udf_schema}")
|
|
51
54
|
|
|
52
55
|
if CATALOG:
|
|
53
|
-
df = df.where(f"function == '{CATALOG}.
|
|
56
|
+
df = df.where(f"function == '{CATALOG}.{udf_schema}.{udf_prefix}{udf}'")
|
|
54
57
|
else:
|
|
55
|
-
df = df.where(f"function == 'spark_catalog.
|
|
58
|
+
df = df.where(f"function == 'spark_catalog.{udf_schema}.{udf_prefix}{udf}'")
|
|
56
59
|
|
|
57
60
|
return not df.isEmpty()
|
|
58
61
|
|
|
@@ -72,9 +75,9 @@ def register_udf(
|
|
|
72
75
|
|
|
73
76
|
if not is_registered(udf, spark) or override:
|
|
74
77
|
if override:
|
|
75
|
-
DEFAULT_LOGGER.debug(f"override udf {udf}")
|
|
78
|
+
DEFAULT_LOGGER.debug(f"override udf {udf}", extra={"label": "fabricks"})
|
|
76
79
|
else:
|
|
77
|
-
DEFAULT_LOGGER.debug(f"register udf {udf}")
|
|
80
|
+
DEFAULT_LOGGER.debug(f"register udf {udf}", extra={"label": "fabricks"})
|
|
78
81
|
|
|
79
82
|
if extension is None:
|
|
80
83
|
extension = get_extension(udf)
|
|
@@ -89,8 +92,6 @@ def register_udf(
|
|
|
89
92
|
elif extension == "py":
|
|
90
93
|
if not IS_UNITY_CATALOG:
|
|
91
94
|
assert path.exists(), f"udf not found ({path.string})"
|
|
92
|
-
else:
|
|
93
|
-
DEFAULT_LOGGER.debug(f"could not check if udf exists ({path.string})")
|
|
94
95
|
|
|
95
96
|
spec = importlib.util.spec_from_file_location(udf, path.string)
|
|
96
97
|
assert spec, f"no valid udf found ({path.string})"
|
fabricks/utils/path.py
CHANGED
|
@@ -246,3 +246,13 @@ class Path:
|
|
|
246
246
|
|
|
247
247
|
def __str__(self) -> str:
|
|
248
248
|
return self.string
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class GitPath(Path):
|
|
252
|
+
def __init__(self, path: Union[str, PathlibPath]):
|
|
253
|
+
super().__init__(path=path, assume_git=True)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
class FileSharePath(Path):
|
|
257
|
+
def __init__(self, path: Union[str, PathlibPath]):
|
|
258
|
+
super().__init__(path=path, assume_git=False)
|
|
@@ -68,7 +68,7 @@ fabricks/cdc/templates/queries/scd2.sql.jinja,sha256=Nn0wUs9N-_QviZqUKRWAFdD17RR
|
|
|
68
68
|
fabricks/cdc/templates/queries/nocdc/complete.sql.jinja,sha256=cVKKCSbiuuw1K7BOzfusX6KvzQNHU3YNUgoXgsu-c6k,267
|
|
69
69
|
fabricks/cdc/templates/queries/nocdc/update.sql.jinja,sha256=mjNUwGVhZ08yUkdv9sCTkqyW60p0YavtWTqvSUVrwjA,1283
|
|
70
70
|
fabricks/context/__init__.py,sha256=qfntJ9O6omzY_t6AhDP6Ndu9C5LMiVdWbo6ikhtoe7o,1446
|
|
71
|
-
fabricks/context/_types.py,sha256=
|
|
71
|
+
fabricks/context/_types.py,sha256=B3CvR_RR0wXCbBADh7Z9S8_7AXRRtvPCnFh7OyQJboI,2802
|
|
72
72
|
fabricks/context/config.py,sha256=EmLUnswuWfrncaNJMDjvdMg-1lD8aneKAY8IDna7VPE,4814
|
|
73
73
|
fabricks/context/helpers.py,sha256=igY8LwLIxzfOWKCg23XMsJoY7Bw0welpdNry2mKHjF0,1600
|
|
74
74
|
fabricks/context/log.py,sha256=CadrRf8iL6iXlGIGIhEIswa7wGqC-E-oLwWcGTyJ10s,2074
|
|
@@ -80,7 +80,7 @@ fabricks/core/__init__.py,sha256=LaqDi4xuyHAoLOvS44PQdZdRfq9SmVr7mB6BDHyxYpc,209
|
|
|
80
80
|
fabricks/core/extenders.py,sha256=oJzfv0hWxusnGmrjMwbrGyKfot8xzA4XtNquPWfFgPo,727
|
|
81
81
|
fabricks/core/job_schema.py,sha256=6-70oy0ZJd3V9AiXfc0Q8b8NVEynxQza_h7mB13uB-s,853
|
|
82
82
|
fabricks/core/masks.py,sha256=0ARgXE6stazRlfjE2v2sOdQWjAH2TbCOgtuD33BeZqE,1531
|
|
83
|
-
fabricks/core/udfs.py,sha256=
|
|
83
|
+
fabricks/core/udfs.py,sha256=nYG5MrTziDB3skZOCgpuxIOvLzs8I5vY8DC0Zdmkysk,3308
|
|
84
84
|
fabricks/core/views.py,sha256=52tekqeP0Xk5EPYO220YdfFbzItX6NnObROb-ye9COQ,1181
|
|
85
85
|
fabricks/core/dags/__init__.py,sha256=0DUKzVcXcROvxkN19P_kaOJ7da5BAM7Vt8EGQbp2KSY,240
|
|
86
86
|
fabricks/core/dags/base.py,sha256=tFj27SqeZUZ7pB_LOWkpdowZz5gj30JUANI4gWK3Pl8,3139
|
|
@@ -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=6YOhuMpCAuqfRtottikIemLQ-L62Av0ZXFcOb9uh4yE,14896
|
|
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
|
|
@@ -155,7 +155,7 @@ fabricks/utils/fdict.py,sha256=cdnvNBSXKJIDKSdhQGJA4CGv0qLn5IVYKQ111l7nM9I,7978
|
|
|
155
155
|
fabricks/utils/helpers.py,sha256=fKv6mpT-428xTSjdLfm7TnN1Xo9FadrSIY1qzYgWCzs,7909
|
|
156
156
|
fabricks/utils/log.py,sha256=LCQEM81PhdojiyLrtEzv1QM__bWbaEhGddyd0IqyGXM,7985
|
|
157
157
|
fabricks/utils/mermaid.py,sha256=XoiVxPaUJS4TC_ybA-e78qFzQkQ46uPf055JiiNDdSg,986
|
|
158
|
-
fabricks/utils/path.py,sha256=
|
|
158
|
+
fabricks/utils/path.py,sha256=H2jU2ixJ57eAd7Aq3Upln1wT9rJzy7od7AwdEnNvCgo,7082
|
|
159
159
|
fabricks/utils/pip.py,sha256=UHo7NTjFGJNghWBuuDow28xUkZYg2YrlbAP49IxZyXY,1522
|
|
160
160
|
fabricks/utils/pydantic.py,sha256=W0fiDLVMFrrInfQw2s5YPeSEvkN-4k864u3UyPoHaz4,2516
|
|
161
161
|
fabricks/utils/spark.py,sha256=QWVpbGwOvURIVBlR7ygt6NQ9MHUsIDvlquJ65iI8UBI,2007
|
|
@@ -171,6 +171,6 @@ fabricks/utils/schema/get_schema_for_type.py,sha256=5k-R6zCgUAtapQgxT4turcx1IQ-b
|
|
|
171
171
|
fabricks/utils/write/__init__.py,sha256=i0UnZenXj9Aq0b0_aU3s6882vg-Vu_AyKfQhl_dTp-g,200
|
|
172
172
|
fabricks/utils/write/delta.py,sha256=lTQ0CfUhcvn3xTCcT_Ns6PMDBsO5UEfa2S9XpJiLJ9c,1250
|
|
173
173
|
fabricks/utils/write/stream.py,sha256=wQBpAnQtYA6nl79sPKhVM6u5m-66suX7B6VQ6tW4TOs,622
|
|
174
|
-
fabricks-3.0.
|
|
175
|
-
fabricks-3.0.
|
|
176
|
-
fabricks-3.0.
|
|
174
|
+
fabricks-3.0.19.dist-info/METADATA,sha256=LVAn4EIa8k57SNEaZvYu7kFJ5LsQ6M64MpfYap63VYY,798
|
|
175
|
+
fabricks-3.0.19.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
176
|
+
fabricks-3.0.19.dist-info/RECORD,,
|
|
File without changes
|