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: change tracking enabled table support merge into #14900

Merged
merged 5 commits into from Mar 14, 2024

Conversation

zhyass
Copy link
Member

@zhyass zhyass commented Mar 11, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

mysql> create table t1(a int, b int);
Query OK, 0 rows affected (0.08 sec)

mysql> create table t2(a int, b int);
Query OK, 0 rows affected (0.06 sec)

mysql> insert into t2 values(2,2),(3,3),(4,4);
Query OK, 3 rows affected (0.09 sec)

mysql> insert into t1 values(1,1),(2,3),(3,3);
Query OK, 3 rows affected (0.09 sec)

mysql> create stream s1 on table t1 append_only = false;
Query OK, 0 rows affected (0.10 sec)

mysql> create stream s2 on table t1 append_only = true;
Query OK, 0 rows affected (0.10 sec)

mysql> set enable_experimental_merge_into = 1;
Query OK, 0 rows affected (0.01 sec)

mysql> merge into t1 using t2 on t1.a=t2.a when matched and t2.a=2 then update set t1.b=t2.b when matched
and t2.a=3 then delete when not matched then insert *;
+-------------------------+------------------------+------------------------+
| number of rows inserted | number of rows updated | number of rows deleted |
+-------------------------+------------------------+------------------------+
|                       1 |                      1 |                      1 |
+-------------------------+------------------------+------------------------+
1 row in set (0.37 sec)
Read 6 rows, 308.00 B in 0.268 sec., 22.35 rows/sec., 1.12 KiB/sec.

mysql> select * from s1 order by a,b;
+------+------+---------------+----------------------------------------+------------------+
| a    | b    | change$action | change$row_id                          | change$is_update |
+------+------+---------------+----------------------------------------+------------------+
|    2 |    2 | INSERT        | 9cf6e0ae54a642909aa32c393c5c9428000001 |                1 |
|    2 |    3 | DELETE        | 9cf6e0ae54a642909aa32c393c5c9428000001 |                1 |
|    3 |    3 | DELETE        | 9cf6e0ae54a642909aa32c393c5c9428000002 |                0 |
|    4 |    4 | INSERT        | b28fd41a8b824529833626c460125664000000 |                0 |
+------+------+---------------+----------------------------------------+------------------+
4 rows in set (0.33 sec)
Read 6 rows, 342.00 B in 0.140 sec., 42.9 rows/sec., 2.39 KiB/sec.

mysql> select * from s2 order by a,b;
+------+------+---------------+------------------+----------------------------------------+
| a    | b    | change$action | change$is_update | change$row_id                          |
+------+------+---------------+------------------+----------------------------------------+
|    4 |    4 | INSERT        |                0 | b28fd41a8b824529833626c460125664000000 |
+------+------+---------------+------------------+----------------------------------------+
1 row in set (0.20 sec)
Read 3 rows, 125.00 B in 0.089 sec., 33.61 rows/sec., 1.37 KiB/sec.
  • Fixes #[Link the issue here]

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Mar 11, 2024
@zhyass zhyass marked this pull request as draft March 11, 2024 03:48
@zhyass zhyass marked this pull request as ready for review March 11, 2024 06:25
@zhyass zhyass added the ci-cloud Build docker image for cloud test label Mar 11, 2024
Copy link
Contributor

Docker Image for PR

  • tag: pr-14900-a303a6e

note: this image tag is only available for internal use,
please check the internal doc for more details.

@JackTan25
Copy link
Collaborator

LGTM

@zhyass zhyass added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Mar 12, 2024
Copy link
Contributor

Docker Image for PR

  • tag: pr-14900-2263a56

note: this image tag is only available for internal use,
please check the internal doc for more details.

@zhyass zhyass marked this pull request as draft March 13, 2024 06:51
@zhyass zhyass marked this pull request as ready for review March 14, 2024 09:49
@zhyass zhyass force-pushed the feat_stream branch 2 times, most recently from c04276a to c38f585 Compare March 14, 2024 09:54
@zhyass zhyass added this pull request to the merge queue Mar 14, 2024
Merged via the queue into datafuselabs:main with commit 5f1541b Mar 14, 2024
72 checks passed
@zhyass zhyass deleted the feat_stream branch March 14, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-cloud Build docker image for cloud test pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants