Skip to content

feat(connector): add DynamoDB sink - #16670

Merged
xxhZs merged 13 commits into
mainfrom
jinser/sink-DynamoDB
Jun 4, 2024
Merged

xxhZs merged 13 commits into
mainfrom
jinser/sink-DynamoDB

Conversation

@jetjinser

@jetjinser jetjinser commented May 9, 2024 •

Copy link
Copy Markdown
Contributor

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

What's changed and what's your intention?

1:1 mapping DynamoDB table sink.

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

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

new sink:

CREATE TABLE IF NOT EXISTS movies (
    year integer,
    title varchar,
    description varchar,
    primary key (year, title)
);

CREATE SINK
  dyn_sink
FROM
  movies
WITH
(
  connector = 'dynamodb',
  table = 'Movies',
  primary_key = 'year,title',
  endpoint = 'http://localhost:8000',
  region = 'us',
  access_key = 'ac',
  secret_key = 'sk'
);

@jetjinser jetjinser added type/feature Type: New feature. user-facing-changes Contains changes that are visible to users labels May 9, 2024
@jetjinser
jetjinser marked this pull request as ready for review May 10, 2024 17:14
@jetjinser
jetjinser requested a review from a team as a code owner May 10, 2024 17:14
Comment thread src/connector/src/sink/dynamodb.rs Outdated
Comment on lines +291 to +292
| ScalarRefImpl::Struct(_)
| ScalarRefImpl::Jsonb(_)) => AttributeValue::S(string.to_text()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • struct may be better mapped to DynamoDB Map
  • jsonb can be mapped as string for now, and latter extended to a dynamic recursive one similar to #11699. It is your call whether the latter dynamic one shall be the default here instead. Just bringing the alternative option to attention.

@jetjinser jetjinser May 13, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • I'm not sure, the struct here must be named, since in create sink?
  • Does this mean providing an TimestampHandlingMode-like option for jsonb format to DynamoDB sink?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can consider struct as a list of named key values pairs, right?

struct <
  id varchar,
  name varchar
>
Map<String, Value> {
  "id": "123",
  "name": "jinser"
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think the current implementation is like this

@jetjinser
jetjinser requested a review from xiangjinwu May 13, 2024 11:15
@fuyufjh
fuyufjh requested review from fuyufjh, xxhZs and yuhao-su May 14, 2024 03:37
Comment thread src/connector/src/sink/dynamodb.rs Outdated
Comment thread src/connector/src/sink/dynamodb.rs
Comment thread src/connector/src/connector_common/common.rs Outdated
@jetjinser
jetjinser requested review from fuyufjh and yuhao-su May 16, 2024 10:53
@lmatz

lmatz commented May 20, 2024

Copy link
Copy Markdown
Contributor

DynamoDB can be deployed locally via docker image: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html
worth adding an integration test

@jetjinser

Copy link
Copy Markdown
Contributor Author

DynamoDB can be deployed locally via docker image: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html worth adding an integration test

Should I add it to this PR? Or should I open another PR?

@jetjinser

Copy link
Copy Markdown
Contributor Author

@xiangjinwu @fuyufjh @yuhao-su I've made the changes, please take a review when you have time 😃

@lmatz

lmatz commented May 26, 2024

Copy link
Copy Markdown
Contributor

DynamoDB can be deployed locally via docker image: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html worth adding an integration test

Should I add it to this PR? Or should I open another PR?

Both are fine, up to you 😃

Comment thread src/connector/src/sink/dynamodb.rs Outdated
Comment thread src/connector/src/sink/dynamodb.rs Outdated
async fn write_chunk(&mut self) -> Result<()> {
if !self.request_items.is_empty() {
let table = self.table.clone();
let req_items = std::mem::take(&mut self.request_items)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it safe to use take here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There seems to be no problem, is there anything to worry about

@xxhZs
xxhZs requested a review from tabVersion May 29, 2024 09:36
@xxhZs
xxhZs force-pushed the jinser/sink-DynamoDB branch from 9a903db to 7e8f23c Compare June 4, 2024 03:33

@tabVersion tabVersion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

generally LGTM

Comment on lines +56 to +57
#[serde(flatten)]
pub aws_auth_props: AwsAuthProps,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does it enable IAM like auth?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes

@xxhZs
xxhZs enabled auto-merge June 4, 2024 03:54

@hzxa21 hzxa21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM for Cargo.lock

@xxhZs
xxhZs added this pull request to the merge queue Jun 4, 2024
Merged via the queue into main with commit a24fb0d Jun 4, 2024
@xxhZs
xxhZs deleted the jinser/sink-DynamoDB branch June 4, 2024 04:30
xiangjinwu pushed a commit that referenced this pull request Jun 11, 2024
Co-authored-by: xxhZs <1060434431@qq.com>
Co-authored-by: Xinhao Xu <84456268+xxhZs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature Type: New feature. user-facing-changes Contains changes that are visible to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants