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): Optimizing ClickHouse Upsert #12259

Merged
merged 11 commits into from
Oct 25, 2023
Merged

Conversation

xxhZs
Copy link
Contributor

@xxhZs xxhZs commented Sep 13, 2023

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

What's changed and what's your intention?

#11967
In this PR, We adopt different sink support methods for different ClickHouse engines. For all ClickHouse engines, we support 'append-only,' where only for ReplacingMergeTree, we do not insert duplicate data. Additionally, for CollapsingMergeTree and VersionedCollapsingMergeTree, we support 'upsert,' where 'rw' will transform 'delete' into 'insert sign=1' form. We also provide support for the 'decimal' format.

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

We only support upsert with clickhouse' CollapsingMergeTree and VersionedCollapsingMergeTree

@xxhZs xxhZs changed the title Feat(sink): Optimizing ClickHouse Upsert feat(sink): Optimizing ClickHouse Upsert Sep 13, 2023
@xxhZs xxhZs marked this pull request as ready for review September 19, 2023 05:23
@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Merging #12259 (13d2ba9) into main (3e89c83) will decrease coverage by 0.09%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main   #12259      +/-   ##
==========================================
- Coverage   68.64%   68.56%   -0.09%     
==========================================
  Files        1496     1496              
  Lines      251405   251440      +35     
==========================================
- Hits       172588   172388     -200     
- Misses      78817    79052     +235     
Flag Coverage Δ
rust 68.56% <0.00%> (-0.09%) ⬇️

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

Files Coverage Δ
src/connector/src/sink/clickhouse.rs 0.00% <0.00%> (ø)

... and 21 files with indirect coverage changes

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

@xxhZs xxhZs requested review from wenym1 and hzxa21 September 26, 2023 04:27
src/connector/src/common.rs Outdated Show resolved Hide resolved
@xxhZs xxhZs requested a review from wenym1 October 7, 2023 07:31
Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

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

Rest LGTM

src/connector/src/sink/clickhouse.rs Outdated Show resolved Hide resolved
src/connector/src/sink/clickhouse.rs Outdated Show resolved Hide resolved
src/connector/src/sink/clickhouse.rs Outdated Show resolved Hide resolved
src/connector/src/sink/clickhouse.rs Outdated Show resolved Hide resolved
@xxhZs xxhZs requested a review from wenym1 October 24, 2023 07:47
Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

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

Rest LGTM. Thanks for the PR!

src/connector/src/sink/clickhouse.rs Outdated Show resolved Hide resolved
#[allow(clippy::enum_variant_names)]
#[derive(Debug)]
enum ClickHouseEngine {
MergeTree,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can all these engines be supported? Or just some of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, here we support all of them. CollapsingMergeTree and CollapsingMergeTree support upsert, while others only support append-only. Among these, only ReplacingMergeTree can guarantee that the same primary key is inserted only once.

src/connector/src/sink/clickhouse.rs Outdated Show resolved Hide resolved
@xxhZs xxhZs enabled auto-merge October 25, 2023 04:52
@xxhZs xxhZs force-pushed the xxh/clickhouse_sink_upsert2 branch from 9c6be25 to 13d2ba9 Compare October 25, 2023 05:40
@gitguardian
Copy link

gitguardian bot commented Oct 25, 2023

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id Secret Commit Filename
7648795 Generic CLI Secret 13d2ba9 integration_tests/iceberg-cdc/run_test.sh View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@xxhZs xxhZs added this pull request to the merge queue Oct 25, 2023
Merged via the queue into main with commit 2d428b1 Oct 25, 2023
6 of 7 checks passed
@xxhZs xxhZs deleted the xxh/clickhouse_sink_upsert2 branch October 25, 2023 06:05
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.

2 participants