Skip to content
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

🎉 Source Mailchimp: updated Mailchimp schemas #7975

Merged
merged 11 commits into from
Dec 13, 2021

Conversation

VitaliiMaltsev
Copy link
Contributor

@VitaliiMaltsev VitaliiMaltsev commented Nov 15, 2021

What

According to Slack thread destination can not parse JSON schema with $ref

How

Destination S3 can parse $ref in schema if reference leads to a schema that is already in the repository(for source connector).
Updated and added Mailchimp schemas

Recommended reading order

  1. x.java
  2. y.python

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/SUMMARY.md
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

Connector Generator

  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


vmaltsev seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added the area/connectors Connector related issues label Nov 15, 2021
vmaltsev added 2 commits November 15, 2021 13:56
# Conflicts:
#	airbyte-config/init/src/main/resources/seed/source_specs.yaml
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 15, 2021 12:21 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Nov 15, 2021

/test connector=connectors/destination-s3

🕑 connectors/destination-s3 https://github.com/airbytehq/airbyte/actions/runs/1462128987
✅ connectors/destination-s3 https://github.com/airbytehq/airbyte/actions/runs/1462128987
No Python unittests run

@jrhizor jrhizor temporarily deployed to more-secrets November 15, 2021 12:27 Inactive
@VitaliiMaltsev VitaliiMaltsev changed the title 5030/destination s3 ref support 🎉 Destination S3 $ref support Nov 16, 2021
Comment on lines 209 to 212
final Schema singleFieldSchema = getSingleFieldType(combined
// avro schema allows only unique names of records in case of union
? fieldName.concat("_").concat(String.valueOf(definition.getIndex()))
: fieldName, type, definition.getValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

We can extract to separate method getCombinedFieldName(combined, fieldName, definition.getIndex()) for better reading

.flatMap(type -> {
final Schema singleFieldSchema = getSingleFieldType(combined
// avro schema allows only unique names of records in case of union
? fieldName.concat("_").concat(String.valueOf(definition.getIndex()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Under which circumstance will the names have conflict here? The stream calls distinct at the end, so any redundant types will be removed.

Is the change here related to $ref? Currently the COMBINED type is only used for processing combined restrictions, i.e. oneOf, allOf, and anyOf. I don't think it can or should be be used to handle $ref.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Under which circumstance will the names have conflict here? The stream calls distinct at the end, so any redundant types will be removed.

Is the change here related to $ref? Currently the COMBINED type is only used for processing combined restrictions, i.e. oneOf, allOf, and anyOf. I don't think it can or should be be used to handle $ref.

i find this behaviour when converting objects from this schema (Mailchimp)

{
  "type": "array",
  "title": "Segment Type",
  "description": "Segment match conditions. There are multiple possible types, see the [condition types documentation](https://mailchimp.com/developer/marketing/docs/alternative-schemas/#segment-condition-schemas).",
  "items": {
    "x-discriminator": {
      "type": "string",
      "propertyName": "condition_type"
    },
    "oneOf": [
      {
        "$ref": "aimSegment.json"
      },
      {
        "$ref": "automationSegment.json"
      },
      {
        "$ref": "campaignPollSegment.json"
      },
      {
        "$ref": "conversationSegment.json"
      },
      {
        "$ref": "dateSegment.json"
      },
      {
        "$ref": "emailClientSegment.json"
      },....

distinct call will not help in this case, it just decreases count of avro records in union, but anyway all records will have name "conditions.items" and that is not allowed in avro union

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure what the conditions.items is. It's not in any of the Mailchimp modified in this PR.

Following the above example for Mailchimp, what would be the final schema after running it through the converter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tuliren sorry for delay. This should be resolved in scope of #8574 so i will revert these changes from this PR and leave only updated schemas of Mailchimp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tuliren reverted changes from JsonToAvroSchemaConverter. Please advice if anything else should be implemented in scope of this task

@VitaliiMaltsev VitaliiMaltsev marked this pull request as ready for review November 22, 2021 11:30
Copy link
Contributor

@tuliren tuliren left a comment

Choose a reason for hiding this comment

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

Destination S3 can parse $ref in schema if reference leads to a schema that is already in the repository.

Oh, I did not realize this. Actually where is the code that is handing $ref when the schema is in the repo?

Can you add some test cases in type_conversion_test_cases.json andjson_conversion_test_cases.json?

@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 1, 2021

Destination S3 can parse $ref in schema if reference leads to a schema that is already in the repository.

Oh, I did not realize this. Actually where is the code that is handing $ref when the schema is in the repo?

Can you add some test cases in type_conversion_test_cases.json andjson_conversion_test_cases.json?

@tuliren sorry for the misunderstanding. Destination by itself cannot parse fields with $ref, I meant that json schema is transmitted without $ref when sync, if such fields are found in the source

Example: Source Facebook Marketing (ads_insights stream) ---> Destination S3
Field actions transmitted to destination as appropriate ObjectNode not $ref
ads_insights

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 6, 2021 13:52 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 11, 2021 20:54 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 11, 2021 20:56 Inactive
Copy link
Contributor

@tuliren tuliren left a comment

Choose a reason for hiding this comment

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

Cool. Don't forget to update the PR title.

@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 13, 2021

/test connector=connectors/source-mailchimp

🕑 connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1572050438
✅ connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1572050438
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        76      8    89%
	 source_acceptance_test/conftest.py                     109    109     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              235     95    60%
	 source_acceptance_test/tests/test_full_refresh.py       38     27    29%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  54     24    56%
	 source_acceptance_test/utils/compare.py                 62     25    60%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py     115     14    88%
	 ------------------------------------------------------------------------
	 TOTAL                                                  946    442    53%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                   Stmts   Miss  Cover
	 ----------------------------------------------------------
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------/actions-runner/_work/airbyte/airbyte/airbyte-integrations/connectors/source-mailchimp/.venv/lib/python3.8/site-packages/coverage/control.py:768: CoverageWarning: No data was collected. (no-data-collected)
	 source_mailchimp/__init__.py               2      2     0%
	   self._warn("No data was collected.", slug="no-data-collected")
	 source_mailchimp/models/__init__.py        1      1     0%
	 source_mailchimp/models/mailchimp.py       7      7     0%
	 source_mailchimp/source.py                26     26     0%
	 source_mailchimp/streams.py              103    103     0%
	 ----------------------------------------------------------
	 TOTAL                                    139    139     0%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                   Stmts   Miss  Cover
	 ----------------------------------------------------------
	 source_mailchimp/__init__.py               2      0   100%
	 source_mailchimp/models/__init__.py        1      1     0%
	 source_mailchimp/models/mailchimp.py       7      7     0%
	 source_mailchimp/source.py                26      9    65%
	 source_mailchimp/streams.py              103     61    41%
	 ----------------------------------------------------------
	 TOTAL                                    139     78    44%

@jrhizor jrhizor temporarily deployed to more-secrets December 13, 2021 08:56 Inactive
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Dec 13, 2021
@VitaliiMaltsev VitaliiMaltsev changed the title 🎉 Destination S3 $ref support 🎉 Source Mailchimp: updated Mailchimp schemas Dec 13, 2021
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 13, 2021 09:16 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 13, 2021

/publish connector=connectors/source-mailchimp

🕑 connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1572141158
✅ connectors/source-mailchimp https://github.com/airbytehq/airbyte/actions/runs/1572141158

@jrhizor jrhizor temporarily deployed to more-secrets December 13, 2021 09:19 Inactive
@VitaliiMaltsev VitaliiMaltsev merged commit faa4d9a into master Dec 13, 2021
@VitaliiMaltsev VitaliiMaltsev deleted the 5030/destination-s3-ref-support branch December 13, 2021 09:36
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
* create mailchimp schemas

* remove star import

* refactoring

* resolve merge conflicts

* update mailchimp cdk version

* revert changes from JsonToAvroSchemaConverter

* revert changes from JsonToAvroSchemaConverter

* bump Source Mailchimp

Co-authored-by: vmaltsev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Json / Avro schema converter should support $ref and remote URLs
5 participants