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

🎉 New Destination: S3-Glue #18695

Merged
merged 18 commits into from
Nov 17, 2022
Merged

🎉 New Destination: S3-Glue #18695

merged 18 commits into from
Nov 17, 2022

Conversation

itaseskii
Copy link
Contributor

@itaseskii itaseskii commented Oct 31, 2022

What

Integrating the S3 destination connector with AWS Glue.

How

Describe the solution

Recommended reading order

  1. x.java
  2. y.python

🚨 User Impact 🚨

Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.

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/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
  • If new credentials are required for use in CI, add them to GSM. 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
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command 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

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@github-actions github-actions bot added the area/connectors Connector related issues label Oct 31, 2022
@itaseskii itaseskii changed the title Draft: Destination-s3-glue Destination-s3-glue Oct 31, 2022
@itaseskii itaseskii marked this pull request as draft October 31, 2022 14:42
@marcosmarxm
Copy link
Member

@itaseskii please request my review when this is ready!

@itaseskii
Copy link
Contributor Author

@itaseskii please request my review when this is ready!

Will do! We are planning to test this tomorrow on a live aws environment and if everything works as expected I will request a review.

}
}
case "object" -> {
//TODO (itaseski) should we take into account nested objects and generate nested structs i.e struct<col_name : struct<col_name : string>>
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately structs only support primitive data types. This means it will likely require some means of flattening nested records. Possibly by allowing a configurable separator (e.g. __).

However, now that I type this, that means that the actual data would need to be mutated to represent the flattened schema structure. Alternatively, anything that's nested deeper than 1 level would need to be treated as a string and parsed as JSON in the query engine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After all it seems that Glue does support nesting of complex types. I have fully reimplemented the schema generation algorithm to use recursion in order to include all the nested types in the schema

.withOutputFormat("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat")
.withSerdeInfo(
new SerDeInfo()
.withSerializationLibrary("org.openx.data.jsonserde.JsonSerDe")
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be mapped to the file type (e.g. JSON vs. Avro vs. Parquet) so that the query engine can use the proper library when processing the data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm aware of this. but I though that we agreed that in v1 we will support only JSON and I'm performing that check in order to decide whether to generate the schema in Glue or not.

this.objectMapper = new ObjectMapper();
}

//TODO (itaseski) can location change after table is created?
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good question. I would imagine the answer is yes? In practice I think it's a rare occurrence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have provided the ability to update the location through the input parameter so we are good to go.


UpdateTableRequest updateTableRequest = new UpdateTableRequest()
.withDatabaseName(databaseName)
//TODO (itaseski) do we need to send all table inputs or the ones that are going to be changed?
Copy link
Contributor

Choose a reason for hiding this comment

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

It should only be necessary to modify the schema of tables that are actually being modified. Existing table definitions will continue to operate as long as the underlying data is still present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'm only sending schema and location the only data that can change.

// TODO (itaseski) does the airbyte schema support integers as first class types or as airbyte_types?
case "integer" -> "int";
case "boolean" -> "boolean";
// TODO (itaseski) throw exception on unknown types or set as received?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine to keep them as-is (at least as a first pass)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kept as a default case which will send the type as received without performing any mapping on it.

@marcosmarxm
Copy link
Member

Hello! I'm going to be out of the office this Friday and won't be able to review your contribution again today, I return next Monday. So far, most contributions look solid and are almost done to be approved. As said in Chris' comment all contributions made before 2-November are eligible to receive the prize and have 2 weeks to merge the contributions. But I ensure next week we're going to have your contribution merged. If you have questions about the implementation you can send them in #hacktoberfest-2022 in Airbyte's Slack.

Sorry the inconvenience and see you again next week, thank you so much for your contribution!

@marcosmarxm
Copy link
Member

@itaseskii please change to ready and request my review when this the connector is ready to review.

@itaseskii itaseskii changed the title Destination-s3-glue 🎉 New Destination: S3-Glue Nov 14, 2022
@itaseskii itaseskii marked this pull request as ready for review November 14, 2022 15:15

import com.fasterxml.jackson.databind.JsonNode;

// TODO (itaseskii) allow config based implementation of different metastores i.e Hive, Nessie, etc.
Copy link
Contributor

Choose a reason for hiding this comment

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

If the intent is to support different metastores then it might make sense to change the name from s3_glue to s3_lakehouse or s3_metastore so that there isn't the hardcoded assumption that it only works with AWS Glue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fully agree with this and I was thinking the same thing but I would prefer if we rename it once we actually have another metastore implementation since that is not for certain...

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense 👍

@marcosmarxm
Copy link
Member

marcosmarxm commented Nov 16, 2022

/test connector=connectors/destination-s3

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

Build Passed

Test summary info:

All Passed

@marcosmarxm
Copy link
Member

marcosmarxm commented Nov 16, 2022

/test connector=connectors/destination-s3-glue

🕑 connectors/destination-s3-glue https://github.com/airbytehq/airbyte/actions/runs/3482999985
❌ connectors/destination-s3-glue https://github.com/airbytehq/airbyte/actions/runs/3482999985
🐛 https://gradle.com/s/ckjg4gzz5jxi6

Build Failed

Test summary info:

Could not find result summary

🕑 connectors/destination-s3-glue https://github.com/airbytehq/airbyte/actions/runs/3482999985
❌ connectors/destination-s3-glue https://github.com/airbytehq/airbyte/actions/runs/3482999985
🐛 https://gradle.com/s/zfz4vs4knziv4

Build Failed

Test summary info:

Could not find result summary

@marcosmarxm
Copy link
Member

marcosmarxm commented Nov 16, 2022

/test connector=connectors/destination-s3-glue

🕑 connectors/destination-s3-glue https://github.com/airbytehq/airbyte/actions/runs/3483483336
❌ connectors/destination-s3-glue https://github.com/airbytehq/airbyte/actions/runs/3483483336
🐛 https://gradle.com/s/mf27rrn44w2f4

Build Failed

Test summary info:

Could not find result summary

@itaseskii
Copy link
Contributor Author

Proof that the acceptance tests work on my machine 😅
Screenshot_20221116_235440

@marcosmarxm
Copy link
Member

marcosmarxm commented Nov 17, 2022

/test connector=connectors/destination-s3-glue

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

Build Passed

Test summary info:

All Passed

Copy link
Member

@marcosmarxm marcosmarxm left a comment

Choose a reason for hiding this comment

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

Thanks @itaseskii I think the connector is in a good first state!

@marcosmarxm
Copy link
Member

marcosmarxm commented Nov 17, 2022

/publish connector=connectors/destination-s3-glue

🕑 Publishing the following connectors:
connectors/destination-s3-glue
https://github.com/airbytehq/airbyte/actions/runs/3492281747


Connector Did it publish? Were definitions generated?
connectors/destination-s3-glue

if you have connectors that successfully published but failed definition generation, follow step 4 here ▶️

@RealChrisSean
Copy link

Hello @itaseskii can you please update your profile with your email?

If you prefer to DM me instead, please dm with the following:

  • Full name
  • Email
  • link to this PR
    Thanks!

akashkulk pushed a commit that referenced this pull request Dec 2, 2022
* destination-s3-glue

* reimplement schema generation to use recursion

* configure serialization library

* include data on update

* flatten data field

* improve location path

* generate s3-glue destination

* refactor s3-glue as separate connector

* add acceptance tests and cleanup

* check field presence

* override test image name

* add s3-glue readme

* format files

* add redpanda readme

* add s3 glue to source def

* auto-bump connector version

Co-authored-by: marcosmarxm <marcosmarxm@gmail.com>
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants