Skip to content

Commit

Permalink
fix(ingest): fix serde for empty dicts in unions with null
Browse files Browse the repository at this point in the history
The code changes in acryldata/avro_gen#16, but tests are written here.
  • Loading branch information
hsheth2 committed Dec 13, 2022
1 parent 43f95d2 commit 2f95c97
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions metadata-ingestion/scripts/install_editable_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

set -euxo pipefail

pip install -e 'git+https://github.com/hsheth2/avro_gen#egg=avro-gen3'
pip install -e 'git+https://github.com/hsheth2/PyHive#egg=acryl-pyhive[hive]'
pip install -e 'git+https://github.com/acryldata/avro_gen#egg=avro-gen3'
pip install -e 'git+https://github.com/acryldata/PyHive#egg=acryl-pyhive[hive]'
pip install -e '.[dev]'
2 changes: 1 addition & 1 deletion metadata-ingestion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_long_description():
"entrypoints",
"docker",
"expandvars>=0.6.5",
"avro-gen3==0.7.7",
"avro-gen3==0.7.8",
# "avro-gen3 @ git+https://github.com/acryldata/avro_gen@master#egg=avro-gen3",
"avro>=1.10.2,<1.11",
"python-dateutil>=2.8.0",
Expand Down
20 changes: 20 additions & 0 deletions metadata-ingestion/tests/unit/serde/test_serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,23 @@ def test_reserved_keywords() -> None:

filter3 = models.FilterClass.from_obj(filter2.to_obj())
assert filter2 == filter3


def test_read_empty_dict() -> None:
original = '{"type": "SUCCESS", "nativeResults": {}}'

model = models.AssertionResultClass.from_obj(json.loads(original))
assert model.nativeResults == {}
assert model == models.AssertionResultClass(
type=models.AssertionResultTypeClass.SUCCESS, nativeResults={}
)


def test_write_optional_empty_dict() -> None:
model = models.AssertionResultClass(
type=models.AssertionResultTypeClass.SUCCESS, nativeResults={}
)
assert model.nativeResults == {}

out = json.dumps(model.to_obj())
assert out == '{"type": "SUCCESS", "nativeResults": {}}'

0 comments on commit 2f95c97

Please sign in to comment.