forked from meltano/sdk
-
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.
Merge branch 'main' into 2155-target-set-batch-size-rows
- Loading branch information
Showing
7 changed files
with
160 additions
and
132 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,74 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from singer_sdk.helpers._flattening import flatten_record | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"flattened_schema, max_level, expected", | ||
[ | ||
pytest.param( | ||
{ | ||
"properties": { | ||
"key_1": {"type": ["null", "integer"]}, | ||
"key_2__key_3": {"type": ["null", "string"]}, | ||
"key_2__key_4": {"type": ["null", "object"]}, | ||
} | ||
}, | ||
99, | ||
{ | ||
"key_1": 1, | ||
"key_2__key_3": "value", | ||
"key_2__key_4": '{"key_5": 1, "key_6": ["a", "b"]}', | ||
}, | ||
id="flattened schema limiting the max level", | ||
), | ||
pytest.param( | ||
{ | ||
"properties": { | ||
"key_1": {"type": ["null", "integer"]}, | ||
"key_2__key_3": {"type": ["null", "string"]}, | ||
"key_2__key_4__key_5": {"type": ["null", "integer"]}, | ||
"key_2__key_4__key_6": {"type": ["null", "array"]}, | ||
} | ||
}, | ||
99, | ||
{ | ||
"key_1": 1, | ||
"key_2__key_3": "value", | ||
"key_2__key_4__key_5": 1, | ||
"key_2__key_4__key_6": '["a", "b"]', | ||
}, | ||
id="flattened schema not limiting the max level", | ||
), | ||
pytest.param( | ||
{ | ||
"properties": { | ||
"key_1": {"type": ["null", "integer"]}, | ||
"key_2__key_3": {"type": ["null", "string"]}, | ||
"key_2__key_4__key_5": {"type": ["null", "integer"]}, | ||
"key_2__key_4__key_6": {"type": ["null", "array"]}, | ||
} | ||
}, | ||
1, | ||
{ | ||
"key_1": 1, | ||
"key_2__key_3": "value", | ||
"key_2__key_4": '{"key_5": 1, "key_6": ["a", "b"]}', | ||
}, | ||
id="max level limiting flattened schema", | ||
), | ||
], | ||
) | ||
def test_flatten_record(flattened_schema, max_level, expected): | ||
"""Test flatten_record to obey the max_level and flattened_schema parameters.""" | ||
record = { | ||
"key_1": 1, | ||
"key_2": {"key_3": "value", "key_4": {"key_5": 1, "key_6": ["a", "b"]}}, | ||
} | ||
|
||
result = flatten_record( | ||
record, max_level=max_level, flattened_schema=flattened_schema | ||
) | ||
assert expected == result |
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