dlt-utils-lib 1.3.0__tar.gz → 1.3.1__tar.gz
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.
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/PKG-INFO +1 -1
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils/main_cdc_utils.py +13 -6
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils_lib.egg-info/PKG-INFO +1 -1
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/tests/test_main_cdc_utils.py +48 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils/__init__.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils/dlt_autoloader_recovery_configuration.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils/dlt_metadata_receiver.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils/dlt_table_properties.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils/dlt_transformations.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils/main_json_utils.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils_lib.egg-info/SOURCES.txt +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils_lib.egg-info/dependency_links.txt +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils_lib.egg-info/requires.txt +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils_lib.egg-info/top_level.txt +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/setup.cfg +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/setup.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/tests/__init__.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/tests/conftest.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/tests/test_autoloader_recovery_configuration.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/tests/test_main_json_utils.py +0 -0
- {dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/tests/test_transformation_module.py +0 -0
|
@@ -39,22 +39,29 @@ def _pick_latest_source_file(spark, files_path: str) -> Optional[str]:
|
|
|
39
39
|
def base_cdc_replication_process(dlt,
|
|
40
40
|
spark,
|
|
41
41
|
cdc_tables_map: list,
|
|
42
|
-
bronze_directory: str,
|
|
43
|
-
bucket_name: str,
|
|
42
|
+
bronze_directory: Optional[str] = None,
|
|
43
|
+
bucket_name: Optional[str] = None,
|
|
44
44
|
time_diff_history_cdc_timestamp: int = 30,
|
|
45
45
|
bronze_schema: Optional[str] = None,
|
|
46
46
|
silver_schema: Optional[str] = None,
|
|
47
|
-
use_managed_file_events: bool = False
|
|
47
|
+
use_managed_file_events: bool = False,
|
|
48
|
+
volume_source_path: Optional[str] = None):
|
|
49
|
+
if volume_source_path is None and (not bronze_directory or not bucket_name):
|
|
50
|
+
raise ValueError("Provide volume_source_path or both bucket_name and bronze_directory")
|
|
51
|
+
|
|
48
52
|
# parse list with tables for replication
|
|
49
53
|
for table in cdc_tables_map:
|
|
50
54
|
source_table_name = table['source_table_name']
|
|
51
|
-
source_schema = table['source_schema']
|
|
52
55
|
file_format = table['format']
|
|
53
56
|
keys = table['keys']
|
|
54
57
|
exclude_columns = table['exclude_columns']
|
|
55
58
|
enable_truncate = table['enable_truncate']
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
# The volume path already includes the source schema.
|
|
60
|
+
if volume_source_path is not None:
|
|
61
|
+
bronze_table_path = f"{volume_source_path.rstrip('/')}/{source_table_name}/"
|
|
62
|
+
else:
|
|
63
|
+
source_schema = table['source_schema']
|
|
64
|
+
bronze_table_path = f"{bucket_name}/{bronze_directory}/{source_schema}/{source_table_name}/"
|
|
58
65
|
|
|
59
66
|
# Optional parameters
|
|
60
67
|
default_value_for_removed_col = table.get('default_value_for_removed_col', {})
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
1
3
|
import dlt_utils.main_cdc_utils as main_cdc_utils
|
|
2
4
|
|
|
3
5
|
|
|
@@ -259,3 +261,49 @@ def test_create_bronze_table_definition_falls_back_to_directory_when_listing_emp
|
|
|
259
261
|
)
|
|
260
262
|
|
|
261
263
|
assert load_paths == [directory]
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@pytest.mark.parametrize("source_options, expected", [
|
|
267
|
+
({"bucket_name": "s3://bucket", "bronze_directory": "dms_bronze"},
|
|
268
|
+
"s3://bucket/dms_bronze/bifrost/customer/"),
|
|
269
|
+
({"volume_source_path": "/Volumes/artemis_prod/stage/dms_raw/"},
|
|
270
|
+
"/Volumes/artemis_prod/stage/dms_raw/customer/"),
|
|
271
|
+
({"volume_source_path": "/Volumes/artemis_prod/stage/dms_raw",
|
|
272
|
+
"bucket_name": "s3://bucket", "bronze_directory": "dms_bronze"},
|
|
273
|
+
"/Volumes/artemis_prod/stage/dms_raw/customer/"),
|
|
274
|
+
])
|
|
275
|
+
def test_base_cdc_source_paths(monkeypatch, source_options, expected):
|
|
276
|
+
captured = []
|
|
277
|
+
monkeypatch.setattr(main_cdc_utils, "create_bronze_table_definition", lambda **kw: captured.append(kw))
|
|
278
|
+
monkeypatch.setattr(main_cdc_utils, "silver_streaming_process", lambda **kw: None)
|
|
279
|
+
table = _build_cdc_table()
|
|
280
|
+
if "volume_source_path" in source_options:
|
|
281
|
+
del table["source_schema"]
|
|
282
|
+
main_cdc_utils.base_cdc_replication_process(
|
|
283
|
+
dlt=object(), spark=object(), cdc_tables_map=[table],
|
|
284
|
+
**source_options,
|
|
285
|
+
)
|
|
286
|
+
assert captured[0]["files_path"] == expected
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
@pytest.mark.parametrize("source_options", [
|
|
290
|
+
{},
|
|
291
|
+
{"bucket_name": "s3://bucket"},
|
|
292
|
+
{"bronze_directory": "dms_bronze"},
|
|
293
|
+
])
|
|
294
|
+
def test_base_cdc_requires_complete_source_configuration(source_options):
|
|
295
|
+
with pytest.raises(ValueError, match="Provide volume_source_path or both bucket_name and bronze_directory"):
|
|
296
|
+
main_cdc_utils.base_cdc_replication_process(
|
|
297
|
+
dlt=object(), spark=object(), cdc_tables_map=[_build_cdc_table()],
|
|
298
|
+
**source_options,
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def test_base_cdc_s3_requires_source_schema():
|
|
303
|
+
table = _build_cdc_table()
|
|
304
|
+
del table["source_schema"]
|
|
305
|
+
with pytest.raises(KeyError, match="source_schema"):
|
|
306
|
+
main_cdc_utils.base_cdc_replication_process(
|
|
307
|
+
dlt=object(), spark=object(), cdc_tables_map=[table],
|
|
308
|
+
bucket_name="s3://bucket", bronze_directory="dms_bronze",
|
|
309
|
+
)
|
|
File without changes
|
{dlt_utils_lib-1.3.0 → dlt_utils_lib-1.3.1}/dlt_utils/dlt_autoloader_recovery_configuration.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|