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

🐛 Destination S3: avro and parquet formats have issues with JsonToAvroSchemaConverter #8574

Merged
merged 32 commits into from
Dec 21, 2021

Conversation

VitaliiMaltsev
Copy link
Contributor

@VitaliiMaltsev VitaliiMaltsev commented Dec 7, 2021

What

Sync failed for Github Source (stream commits)
Logs:

�[35mdestination�[0m - 2021-11-26 13:17:54 INFO () DefaultAirbyteStreamFactory(lambda$create$0):61 - 2021-11-26 13:17:54 �[33mWARN�[m i.a.i.b.FailureTrackingAirbyteMessageConsumer(close):58 - {} - Airbyte message consumer: failed.
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - Exception in thread "main" org.apache.avro.SchemaParseException: Can't redefine: author
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$Names.put(Schema.java:1542)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$NamedSchema.writeNameRef(Schema.java:805)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:967)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$UnionSchema.toJson(Schema.java:1234)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$RecordSchema.fieldsToJson(Schema.java:995)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:979)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$UnionSchema.toJson(Schema.java:1234)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$RecordSchema.fieldsToJson(Schema.java:995)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:979)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema.toString(Schema.java:419)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at org.apache.avro.Schema.toString(Schema.java:391)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at io.airbyte.integrations.destination.s3.writer.ProductionWriterFactory.create(ProductionWriterFactory.java:42)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at io.airbyte.integrations.destination.s3.S3Consumer.startTracked(S3Consumer.java:53)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at io.airbyte.integrations.base.FailureTrackingAirbyteMessageConsumer.start(FailureTrackingAirbyteMessageConsumer.java:34)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at io.airbyte.integrations.base.IntegrationRunner.consumeWriteStream(IntegrationRunner.java:142)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at io.airbyte.integrations.base.IntegrationRunner.run(IntegrationRunner.java:128)
�[35mdestination�[0m - 2021-11-26 13:17:54 ERROR () LineGobbler(voidCall):82 - 	at io.airbyte.integrations.destination.s3.S3Destination.main(S3Destination.java:29)
2021-11-26 13:17:54 INFO () DefaultReplicationWorker(run):141 - Destination thread complete.
2021-11-26 13:17:54 ERROR () DefaultReplicationWorker(run):145 - Sync worker failed.

How

According to Apache Avro documentation https://avro.apache.org/docs/current/spec.html#names
A schema or protocol may not contain multiple definitions of a fullname.
Added namespace to avro records

Recommended reading order

  1. x.java
  2. y.python

🚨 User Impact 🚨

There should not be any user impact in scope of Airbyte streams processing. This PR only add unique namespace into avro schemas for record types, previous namespace value for avro records was null. Only one potential impact is for further processing avro/parquet files outside of airbyte, cause earlier fullname of avro records was consist from name, with these changes would be consits from namespace.name

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.

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 7, 2021 09:48 Inactive
@CLAassistant
Copy link

CLAassistant commented Dec 7, 2021

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ alexandr-shegeda
❌ vmaltsev


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 Dec 7, 2021
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Dec 7, 2021
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 7, 2021 09:58 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 7, 2021

/test connector=connectors/destination-s3

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

@jrhizor jrhizor temporarily deployed to more-secrets December 7, 2021 10:14 Inactive
…pace

# Conflicts:
#	docs/integrations/destinations/s3.md
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 7, 2021 10:39 Inactive
Copy link
Contributor

@alexandr-shegeda alexandr-shegeda left a comment

Choose a reason for hiding this comment

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

LGTM

@alexandr-shegeda alexandr-shegeda marked this pull request as ready for review December 7, 2021 11:52
Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

@VitaliiMaltsev could you describe the user impact? Is this causing a breaking change for users?

@@ -26,4 +30,12 @@ private String checkFirsCharInStreamName(final String name) {
}
}

public String resovleNamespace(String fieldName, List<String> recordFieldNames) {
Copy link
Contributor

@sherifnada sherifnada Dec 8, 2021

Choose a reason for hiding this comment

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

typo: resolve

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

Also, can you add a test case to DAT to catch this in the future for all destinations?

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 8, 2021 09:32 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

@VitaliiMaltsev could you describe the user impact? Is this causing a breaking change for users?

@sherifnada updated user impact section

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 8, 2021 10:03 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

Also, can you add a test case to DAT to catch this in the future for all destinations?

Please advise which test case do you mean for all destinations? This PR makes changes only to the conversion of the Json schema to the Avro schema in the JsonToAvroSchemaConverter class, since the avro schema, according to the documentation, does not allow having records with the same names. JsonToAvroSchemaConverter is only used for Destination S3 and GCS. JsonToAvroSchemaConverter class is covered by unit tests with in the JsonToAvroConverterTest class (test case "schema_with_the_same_object_names")

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 21, 2021 14:23 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 21, 2021

/test connector=connectors/destination-s3

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

@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 21, 2021

/test connector=connectors/destination-gcs

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

@jrhizor jrhizor temporarily deployed to more-secrets December 21, 2021 14:30 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets December 21, 2021 14:30 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets December 21, 2021 14:31 Inactive
…port-namespace' into vmaltsev/8242-destination-s3-support-namespace

# Conflicts:
#	airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/avro/JsonToAvroSchemaConverter.java
@alexandr-shegeda alexandr-shegeda temporarily deployed to more-secrets December 21, 2021 14:59 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 21, 2021

/test connector=connectors/destination-bigquery-denormalized

🕑 connectors/destination-bigquery-denormalized https://github.com/airbytehq/airbyte/actions/runs/1607351786
✅ connectors/destination-bigquery-denormalized https://github.com/airbytehq/airbyte/actions/runs/1607351786
No Python unittests run

@jrhizor jrhizor temporarily deployed to more-secrets December 21, 2021 15:03 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 21, 2021

/publish connector=connectors/destination-s3

🕑 connectors/destination-s3 https://github.com/airbytehq/airbyte/actions/runs/1607392144
✅ connectors/destination-s3 https://github.com/airbytehq/airbyte/actions/runs/1607392144

@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 21, 2021

/publish connector=connectors/destination-gcs

🕑 connectors/destination-gcs https://github.com/airbytehq/airbyte/actions/runs/1607394219
✅ connectors/destination-gcs https://github.com/airbytehq/airbyte/actions/runs/1607394219

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 21, 2021 15:11 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets December 21, 2021 15:12 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets December 21, 2021 15:12 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

Thanks a lot for the update.

Can you format the code before merging the PR? Some of the formats are off.

formatted

@VitaliiMaltsev
Copy link
Contributor Author

VitaliiMaltsev commented Dec 21, 2021

/publish connector=connectors/destination-bigquery-denormalized

🕑 connectors/destination-bigquery-denormalized https://github.com/airbytehq/airbyte/actions/runs/1607468923
✅ connectors/destination-bigquery-denormalized https://github.com/airbytehq/airbyte/actions/runs/1607468923

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants