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(sink): kafka upsert sink with schema #12113

Merged
merged 23 commits into from
Oct 19, 2023
Merged

feat(sink): kafka upsert sink with schema #12113

merged 23 commits into from
Oct 19, 2023

Conversation

wugouzi
Copy link
Contributor

@wugouzi wugouzi commented Sep 6, 2023

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

What's changed and what's your intention?

Add an option schemas.enable for kafka upsert sink to output with schema that is supported by kafka connect's jsonconverter.
Syntax:

create sink si_kafka_upsert_schema from t_kafka with (
    connector = 'kafka',
    properties.bootstrap.server = '127.0.0.1:29092',
    topic = 'test-rw-sink-upsert-schema',
    primary_key = 'id'
) format upsert encode json (
    schemas.enable = true
);

Details:

  • Effectively, this can be used with kafka, kinesis and pulsar. But most of the cases it is used with kafka.
  • It does not apply to avro or protobuf but only json. Furthermore, it is mutual exclusive with usage of schema registry containing json schema (io.confluent.connect.json.JsonSchemaConverter) and should not be confused with it. This option mimics the behavior of org.apache.kafka.connect.json.JsonConverter instead.
  • It only supports upsert for now and defaults to false when unspecified. It will be extended to be available in debezium and defaults to true.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • 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.

@wugouzi wugouzi requested a review from tabVersion September 6, 2023 05:35
@codecov
Copy link

codecov bot commented Sep 6, 2023

Codecov Report

Merging #12113 (c9fc80e) into main (fcc2469) will increase coverage by 0.01%.
Report is 41 commits behind head on main.
The diff coverage is 86.69%.

@@            Coverage Diff             @@
##             main   #12113      +/-   ##
==========================================
+ Coverage   69.18%   69.20%   +0.01%     
==========================================
  Files        1489     1489              
  Lines      245832   246057     +225     
==========================================
+ Hits       170083   170281     +198     
- Misses      75749    75776      +27     
Flag Coverage Δ
rust 69.20% <86.69%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/connector/src/sink/encoder/mod.rs 71.79% <0.00%> (-1.89%) ⬇️
src/connector/src/sink/encoder/json.rs 88.21% <93.95%> (+3.57%) ⬆️
src/connector/src/sink/formatter/mod.rs 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@xiangjinwu
Copy link
Contributor

xiangjinwu commented Sep 19, 2023

Sorry for the huge conflict due to the refactor. Just to share some thoughts: it looks like this change

  • only applies to json but not proto or avro
  • could be extended from upsert to append-only as well

Given these, after the refactor, this change may be done in JsonEncoder rather than UpsertFormatter.

@neverchanje neverchanje added the user-facing-changes Contains changes that are visible to users label Oct 16, 2023
@Rossil2012 Rossil2012 requested a review from xiangjinwu October 17, 2023 07:03
src/connector/src/sink/encoder/json.rs Outdated Show resolved Hide resolved
src/connector/src/sink/encoder/mod.rs Outdated Show resolved Hide resolved
src/connector/src/sink/formatter/mod.rs Outdated Show resolved Hide resolved
@Rossil2012 Rossil2012 requested a review from xiangjinwu October 17, 2023 09:23
@Rossil2012
Copy link
Contributor

updated @xiangjinwu

e2e_test/sink/kafka/create_sink.slt Outdated Show resolved Hide resolved
src/connector/src/sink/encoder/json.rs Outdated Show resolved Hide resolved
src/connector/src/sink/encoder/json.rs Outdated Show resolved Hide resolved
@Rossil2012 Rossil2012 requested a review from xiangjinwu October 17, 2023 10:30
Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

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

Please also fix the test

src/connector/src/sink/encoder/json.rs Outdated Show resolved Hide resolved
src/connector/src/sink/encoder/mod.rs Show resolved Hide resolved
src/connector/src/sink/encoder/json.rs Outdated Show resolved Hide resolved
src/connector/src/sink/formatter/mod.rs Outdated Show resolved Hide resolved
src/connector/src/sink/encoder/json.rs Outdated Show resolved Hide resolved
src/connector/src/sink/encoder/json.rs Outdated Show resolved Hide resolved
src/connector/src/sink/encoder/json.rs Outdated Show resolved Hide resolved
src/connector/src/sink/formatter/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

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

@tabVersion to check if your comments are resolved

@tabVersion
Copy link
Contributor

@tabVersion to check if your comments are resolved

LGTM

@tabVersion tabVersion added this pull request to the merge queue Oct 19, 2023
Merged via the queue into main with commit 495ab39 Oct 19, 2023
6 of 7 checks passed
@tabVersion tabVersion deleted the qiao/schema_option branch October 19, 2023 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants