-
Notifications
You must be signed in to change notification settings - Fork 506
fix: relax JSON normalizer type validation #3906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rooperuu
wants to merge
5
commits into
dlt-hub:devel
Choose a base branch
from
rooperuu:fix/json-normalizer-validation
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+8
−4
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7eb3e3e
call normalizer class methods using actual type
rooperuu 09284f3
pass max_nesting config to any relational normalizer subtype
rooperuu caf15b9
use subclass check in ensure_this_normalizer
rooperuu d114fe9
revert back to ensure_this_normalizer in import_normalizers
rooperuu 5c4e085
remove unnecessary assertions in source methods
rooperuu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -394,25 +394,31 @@ def name(self) -> str: | |
| @property | ||
| def max_table_nesting(self) -> int: | ||
| """A schema hint that sets the maximum depth of nested table above which the remaining nodes are loaded as structs or JSON.""" | ||
| return RelationalNormalizer.get_normalizer_config(self._schema).get("max_nesting") | ||
| data_normalizer = self._schema.data_item_normalizer | ||
| assert isinstance(data_normalizer, RelationalNormalizer) | ||
| return data_normalizer.get_normalizer_config(self._schema).get("max_nesting") | ||
|
|
||
| @max_table_nesting.setter | ||
| def max_table_nesting(self, value: int) -> None: | ||
| data_normalizer = self._schema.data_item_normalizer | ||
| assert isinstance(data_normalizer, RelationalNormalizer) | ||
| if value is None: | ||
| # this also check the normalizer type | ||
| config = RelationalNormalizer.get_normalizer_config(self._schema) | ||
| config = data_normalizer.get_normalizer_config(self._schema) | ||
| config.pop("max_nesting", None) | ||
| else: | ||
| RelationalNormalizer.update_normalizer_config(self._schema, {"max_nesting": value}) | ||
| data_normalizer.update_normalizer_config(self._schema, {"max_nesting": value}) | ||
|
|
||
| @property | ||
| def root_key(self) -> Optional[bool]: | ||
| """Enables merging on all resources by propagating root foreign key to nested tables. | ||
| This option is most useful if you plan to change write disposition of a resource to disable/enable merge. | ||
|
|
||
| """ | ||
| data_normalizer = self._schema.data_item_normalizer | ||
| assert isinstance(data_normalizer, RelationalNormalizer) | ||
| # this also check the normalizer type | ||
| config = RelationalNormalizer.get_normalizer_config(self._schema) | ||
| config = data_normalizer.get_normalizer_config(self._schema) | ||
| is_root_key = config.get("root_key_propagation") | ||
| if is_root_key is None: | ||
| # if not found get legacy value | ||
|
|
@@ -424,12 +430,14 @@ def root_key(self) -> Optional[bool]: | |
|
|
||
| @root_key.setter | ||
| def root_key(self, value: bool) -> None: | ||
| data_normalizer = self._schema.data_item_normalizer | ||
| assert isinstance(data_normalizer, RelationalNormalizer) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need this assertion if we correctly validate in |
||
| # this also check the normalizer type | ||
| config = RelationalNormalizer.get_normalizer_config(self._schema) | ||
| config = data_normalizer.get_normalizer_config(self._schema) | ||
| if value is None: | ||
| value = self._get_root_key_legacy(config) | ||
| if value is not None: | ||
| RelationalNormalizer.update_normalizer_config( | ||
| data_normalizer.update_normalizer_config( | ||
| self._schema, | ||
| {"root_key_propagation": value}, | ||
| ) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should keep the
ensure_this_normalizercheck.