Skip to content

Feature/any of support#155

Merged
AlexanderMann merged 20 commits intodatamill-co:masterfrom
AlexanderMann:feature/anyOf-support
Jan 28, 2020
Merged

Feature/any of support#155
AlexanderMann merged 20 commits intodatamill-co:masterfrom
AlexanderMann:feature/anyOf-support

Conversation

@AlexanderMann
Copy link
Copy Markdown
Collaborator

Motivation

#14

This pr seeks to add full support for anyOf to Target-Postgres.

anyOf clauses are merged/simplified according to the following rules (these are recursive):

  • all literals are dedupped
  • all objects are merged into the same object schema, with sub-schemas being grouped as simplified anyOf schemas
  • all iterables' items schemas are merged as simplified anyOf schemas
  • all anyOfs are flattened to the topmost
  • if there is only a single element in an anyOf, that is denested
  • if any anyOfs are nullable, all are nullable

We also simplify "implicit" anyOfs. These are the literal schemas where the type field is overloaded with multiple types. ie, something like "type": ["string", "integer"]


def _comparator(self):
if not self._c:
self._c = json.dumps(self, sort_keys=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any performance hit here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but just once and only on schema messages (at least should be). The reason for having this is so that this doesn't get run all the time.


def test__anyOf__schema__stitch_date_times():
denested = error_check_denest(
{'properties': {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This is our primary test case

@AlexanderMann AlexanderMann merged commit 383196a into datamill-co:master Jan 28, 2020
@AlexanderMann AlexanderMann deleted the feature/anyOf-support branch January 28, 2020 15:54
@AlexanderMann AlexanderMann restored the feature/anyOf-support branch April 10, 2022 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants