Repository navigation
PyDABs: keep empty nested objects, as YAML does - #7790
Open
Daniel114510 wants to merge 2 commits into
Open
Daniel114510 wants to merge 2 commits into
Daniel114510 wants to merge 2 commits into
Conversation
Python resources now emit a nested object that is set but empty, such as
StreamingMode() or ExternalTrigger(), as {} instead of dropping it like an
unset field. Unset fields and empty lists and maps are still omitted.
Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
|
Commit: Regression test reportSelected 2 changed tests (limit=20, 0 not selected) 4 tests: regression=0 unreleased=0 coverage=4 failing=0
|
Collaborator
✅ Integration test reportCommit: 575456c
Top 3 slowest tests (at least 2 minutes):
|
A Variable is also a dataclass, but it serializes to a non-empty string, so it no longer reaches the dataclass check. Also add the changelog fragment. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
Python resources now keep a nested object that is set but empty, such as
StreamingMode()orExternalTrigger(), and emit it as{}, as YAML does. Unset fields (None) and empty lists and maps are still omitted.Why
The Python serializer drops every empty value, so it can't tell an object that was set but has no fields from one that was never set. YAML keeps it. Where the empty object is itself the choice, a resource defined in Python comes out wrong:
streaming_mode=StreamingMode()for a materialized feature member in a materialization set, will drop thestreaming_modein the request sent to the service, which will be rejected. The same declaration in YAML deploys.ExternalTriggeror a data quality monitor'sSnapshotConfig, can't be expressed from Python at all.Only Python code that writes an empty object changes, and it now gets what the same
{}does in YAML. For example,continuous=Continuous()now makes a job continuous.Tests
acceptance/bundle/python/materialization_sets-support: empty streaming, table and external triggers, from YAML and Pythonacceptance/bundle/python/data_quality_monitors-support: golden now keepssnapshot: {}test_transform_to_json.py: empty, non-empty and unset nested dataclasses, and aVariablefieldtest_transform.py: empty object dict round tripbundle planof a Python-defined set plans its create withstreaming_mode: {}andtable_trigger: {}, as for the same set in YAML