forked from JDASoftwareGroup/kartothek
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Cube index validation (JDASoftwareGroup#413)
The issue occured when updating a cube with multiple datasets, which also have different dimension columns. This fixes issue JDASoftwareGroup#413. The bug is caused by access of a mutated variable - namely `required_indices` via `table_indices` - in the loop. I rewrote the loop to circumvent this problem and added a unit test which verifies that the index validation is working as expected.
- Loading branch information
1 parent
4008de4
commit 7d93cfd
Showing
3 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from kartothek.core.cube.cube import Cube | ||
from kartothek.core.dataset import DatasetMetadata | ||
from kartothek.io.dask.common_cube import ensure_valid_cube_indices | ||
|
||
|
||
class FakeSeedTableMetadata: | ||
names = ["d1", "d2", "p", "i"] | ||
|
||
|
||
class FakeExtraTableMetadata: | ||
names = ["d1", "p", "i"] | ||
|
||
|
||
def test_cube_indices_are_validated(): | ||
source_metadata = DatasetMetadata.from_dict( | ||
{ | ||
"dataset_uuid": "source", | ||
"dataset_metadata_version": 4, | ||
"table_meta": {"table": FakeSeedTableMetadata()}, | ||
"partition_keys": ["p"], | ||
"indices": { | ||
"d1": {"1": ["part_1"]}, | ||
"d2": {"1": ["part_1"]}, | ||
"i": {"1": ["part_1"]}, | ||
}, | ||
} | ||
) | ||
extra_metadata = DatasetMetadata.from_dict( | ||
{ | ||
"dataset_uuid": "extra", | ||
"dataset_metadata_version": 4, | ||
"table_meta": {"table": FakeExtraTableMetadata()}, | ||
"partition_keys": ["p"], | ||
"indices": {"i": {"1": ["part_1"]}}, | ||
} | ||
) | ||
cube = Cube( | ||
dimension_columns=["d1", "d2"], | ||
partition_columns=["p"], | ||
uuid_prefix="cube", | ||
seed_dataset="source", | ||
index_columns=["i"], | ||
) | ||
|
||
validated_cube = ensure_valid_cube_indices( | ||
{"source": source_metadata, "extra": extra_metadata}, cube | ||
) | ||
|
||
assert validated_cube == cube |