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

fix the problem of multishard incorrect result on distinct #831

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/AggregateFunctions/Streaming/AggregateFunctionDistinct.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,18 @@ struct AggregateFunctionDistinctSingleNumericData
for (auto it = extra_data_since_last_finalize.begin(); it != extra_data_since_last_finalize.end();)
{
if (rhs.set.find(*it) != rhs.set.end())
it = extra_data_since_last_finalize.erase(it);
{
bool is_new_data = std::find(rhs.extra_data_since_last_finalize.begin(), rhs.extra_data_since_last_finalize.end(), *it)
!= rhs.extra_data_since_last_finalize.end();
if (is_new_data)
++it;
else
it = extra_data_since_last_finalize.erase(it);
}
else
{
++it;
}
}

/// Merge and deduplicate rhs' extra data
Expand Down Expand Up @@ -176,9 +185,18 @@ struct AggregateFunctionDistinctGenericData
for (auto next = extra_data_since_last_finalize.begin(); next != extra_data_since_last_finalize.end();)
{
if (rhs.set.find(*next) != rhs.set.end())
next = extra_data_since_last_finalize.erase(next);
{
bool is_new_data = std::find(rhs.extra_data_since_last_finalize.begin(), rhs.extra_data_since_last_finalize.end(), *next)
!= rhs.extra_data_since_last_finalize.end();
if (is_new_data)
++next;
else
next = extra_data_since_last_finalize.erase(next);
}
else
{
++next;
}
}

/// Merge and deduplicate rhs' extra data
Expand Down
8 changes: 4 additions & 4 deletions tests/stream/test_stream_smoke/0012_multishards7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -606,14 +606,14 @@ tests:
query_type: table
depends_on: '1366'
wait: 1
query: insert into test13_multishard_7(id, val) values(1, 30), (2, 40), (3, 60)
query: insert into test13_multishard_7(id, val) values(1, 40), (1, 30)

- client: python
query_type: table
kill: '1366'
kill_wait: 2
wait: 1
query: insert into test13_multishard_7(id, val) values(1, 30), (1, 40), (1, 60), (2, 40), (3, 40)
query: insert into test13_multishard_7(id, val) values(1, 30), (1, 50), (2, 50), (3, 50)

- client: python
query_type: table
Expand All @@ -624,5 +624,5 @@ tests:
expected_results:
- query_id: '1366'
expected_results:
- [130, 130]
- [130, 340]
- [70, 70]
- [120, 250]
Loading