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

feat(source): Avro with AWS Glue Schema Registry #17605

Merged
merged 7 commits into from
Jul 12, 2024

Conversation

xiangjinwu
Copy link
Contributor

@xiangjinwu xiangjinwu commented Jul 8, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Before this PR, there is a boolean use_schema_registry that differentiates usage of schema.location vs (confluent) schema.registry.

In this PR, we introduce AWS Glue schema registry with aws.glue.schema_arn option, and the boolean is deprecated in favor of enums.

  • Hint
    • Review with hide whitespace because if-else are updated to match.
    • The 2 largest change glue.slt and majority of glue_resolver.rs are for tests.
  • In catalog.proto, StreamSourceInfo still has use_schema_registry for backward compatibility.
  • In src/frontend/src/handler/create_source.rs and src/connector/src/parser/mod.rs, the boolean has been replaced by enum SchemaLocation.
  • In src/connector/src/parser/avro/parser.rs, the Option<Arc<ConfluentSchemaCache>> has been replaced by enum WriterSchemaCache.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

Added support for AWS Glue Schema Registry when using encode avro for sources:

encode avro (
  aws.glue.schema_arn = 'arn:aws:glue:ap-southeast-1:123456123456:schema/default-registry/MyEvent',
  // other aws auth options same as s3 / kinesis
  aws.region = '...',
  aws.credentials.access_key_id = '...',
  ...
)

When using IAM permission policies, the following actions shall be allowed:

  • glue:GetSchemaVersion

@xiangjinwu xiangjinwu force-pushed the feat-source-gluesr-avro-r1 branch from b1d0c39 to b67cf20 Compare July 10, 2024 08:44
@xiangjinwu xiangjinwu force-pushed the feat-source-gluesr-avro-r1 branch from 832c4e5 to a4797fd Compare July 10, 2024 09:59
@xiangjinwu xiangjinwu marked this pull request as ready for review July 10, 2024 09:59
@xiangjinwu xiangjinwu requested a review from a team as a code owner July 10, 2024 09:59
@xiangjinwu xiangjinwu requested review from MrCroxx, tabVersion and xxchan and removed request for MrCroxx July 10, 2024 09:59
Copy link
Member

@xxchan xxchan left a comment

Choose a reason for hiding this comment

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

Generally LGTM! The shape is good. Didn't check business logic carefully.

Comment on lines +386 to +392
if format_encode_options_to_consume
.remove(AWS_GLUE_SCHEMA_ARN_KEY)
.is_none()
{
// Legacy logic that assumes either `schema.location` or confluent `schema.registry`.
// The handling of newly added aws glue is centralized in `connector::parser`.
// TODO(xiangjinwu): move these option parsing to `connector::parser` as well.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we need to add logic to check AWS_GLUE_SCHEMA_ARN_KEY is not specified together with other 2.

Copy link
Contributor Author

@xiangjinwu xiangjinwu Jul 12, 2024

Choose a reason for hiding this comment

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

Just tested and when they are specified together:

NOTICE:  Get unknown format_encode_options for Plain Avro: schema.location

So it is already covered by the unknown options check, just not fatal. After the config parsing refactor #17675 we can try to make unknown options a fatal error.

Comment on lines +34 to +45
pub trait GlueSchemaCache {
/// Gets the a specific schema by id, which is used as *writer schema*.
async fn get_by_id(&self, schema_version_id: uuid::Uuid) -> ConnectorResult<Arc<Schema>>;
/// Gets the latest schema by arn, which is used as *reader schema*.
async fn get_by_name(&self, schema_arn: &str) -> ConnectorResult<Arc<Schema>>;
}

#[derive(Debug)]
pub enum GlueSchemaCacheImpl {
Real(RealGlueSchemaCache),
Mock(MockGlueSchemaCache),
}
Copy link
Member

Choose a reason for hiding this comment

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

This isn't a good style to me: the trait seems a little unnecessary to me, but anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unnecessary as a tool (generic) but it is a doc to make sure RealGlueSchemaCache and MockGlueSchemaCache have the same interface.

The unnecessary part is the enum, as we can simply Box<dyn GlueSchemaCache>. This aligns more with mocked interfaces in Java or Go, but in rust we always prefer static dispatch with enum rather than dynamic dispatch (?)

@xiangjinwu xiangjinwu added this pull request to the merge queue Jul 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 12, 2024
@xiangjinwu xiangjinwu added this pull request to the merge queue Jul 12, 2024
Merged via the queue into main with commit 5c52c7d Jul 12, 2024
35 of 36 checks passed
@xiangjinwu xiangjinwu deleted the feat-source-gluesr-avro-r1 branch July 12, 2024 12:32
@xiangjinwu xiangjinwu added the need-cherry-pick-release-1.10 Open a cherry-pick PR to branch release-1.10 after the current PR is merged label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-cherry-pick-release-1.10 Open a cherry-pick PR to branch release-1.10 after the current PR is merged type/feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants