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

change the data processing order in changelog #449

Conversation

lizhou1111
Copy link
Contributor

change the data processing order in changelog.
For example:

drop stream if exists test_kv;
create stream if not exists test_kv(id int, value int) primary key id settings mode='changelog_kv';
select count_distinct(value) from test_kv;
insert into test_kv(id, value, _tp_delta) values(2, 1, 1)(2, 1, -1)(3, 2, 1)(3, 2, -1);

The output will be 2, it should be 0.Because a piece of data is inserted and then deleted, there should be no data.The sum_distinct will encountered the same problem

The previous processing strategy was to divide two chunks according to the delta value. The data with a delta value of -1 is placed in the first chunk, and the data with a delta value of 1 is placed in the second chunk(take the example above, it will be [(2, 1, -1), (3, 2, -1),(2, 1, 1), (3, 2, 1)]). Therefore, the data with a delta value of -1 will be placed in the first chunk. will be processed first, which is inconsistent with the order of data input.

The current strategy is putting consecutive data with the same _tp_delta value in a chunk.
If the input chunk delta flags are [1, 1, 1, -1, -1, 1, 1, 1].We will split into 3 chunks:[[1, 1, 1], [-1, -1], [1, 1, 1]].
This not only ensures that the order of data processing is consistent with the input, but also ensures that the _tp_delta values in the same chunk are the same.

this closes #448

@lizhou1111 lizhou1111 self-assigned this Dec 27, 2023
@lizhou1111 lizhou1111 force-pushed the enhancement/issue-448-change-the-data-processing-order-in-changelog branch from 40d1747 to 5b05488 Compare December 27, 2023 05:47
@lizhou1111 lizhou1111 merged commit f8de5ea into develop Dec 27, 2023
21 checks passed
@lizhou1111 lizhou1111 deleted the enhancement/issue-448-change-the-data-processing-order-in-changelog branch December 27, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

change the data processing order in changelog
2 participants