-
Notifications
You must be signed in to change notification settings - Fork 409
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
Test: Refine dbgFuncCoprocessor #6088
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f7f6b3f
refine.
ywqzzy d2ca2f0
clean up.
ywqzzy 4510c30
split dbgfuncCoprocessor
ywqzzy 40909ab
refine.
ywqzzy fbf072c
refine.
ywqzzy 951a8f3
address comments
ywqzzy 915c5c4
u
ywqzzy 9934882
Merge branch 'master' of https://github.com/pingcap/tiflash into refi…
ywqzzy 173a78b
fix
ywqzzy 85f0ee3
Merge branch 'master' of https://github.com/pingcap/tiflash into refi…
ywqzzy d46d377
u
ywqzzy c6ab143
fix.
ywqzzy 19c3b3a
Merge branch 'master' into refine_dbgFuncCoprocessor
ywqzzy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2022 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <Columns/ColumnUtils.h> | ||
|
||
namespace DB | ||
{ | ||
bool columnEqual(const ColumnPtr & expected, const ColumnPtr & actual, String & unequal_msg) | ||
{ | ||
for (size_t i = 0, size = expected->size(); i < size; ++i) | ||
{ | ||
auto expected_field = (*expected)[i]; | ||
auto actual_field = (*actual)[i]; | ||
if (expected_field != actual_field) | ||
{ | ||
unequal_msg = fmt::format("Value {} mismatch {} vs {} ", i, expected_field.toString(), actual_field.toString()); | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} // namespace DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2022 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <Columns/IColumn.h> | ||
|
||
namespace DB | ||
{ | ||
bool columnEqual(const ColumnPtr & expected, const ColumnPtr & actual, String & unequal_msg); | ||
} // namespace DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,67 @@ | ||||||||||||
// Copyright 2022 PingCAP, Ltd. | ||||||||||||
// | ||||||||||||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||
// you may not use this file except in compliance with the License. | ||||||||||||
// You may obtain a copy of the License at | ||||||||||||
// | ||||||||||||
// http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||
// | ||||||||||||
// Unless required by applicable law or agreed to in writing, software | ||||||||||||
// distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||
// See the License for the specific language governing permissions and | ||||||||||||
// limitations under the License. | ||||||||||||
|
||||||||||||
#include <Core/BlockUtils.h> | ||||||||||||
|
||||||||||||
namespace DB | ||||||||||||
{ | ||||||||||||
bool blockEqual(const Block & expected, const Block & actual, String & unequal_msg) | ||||||||||||
{ | ||||||||||||
size_t rows_a = expected.rows(); | ||||||||||||
size_t rows_b = actual.rows(); | ||||||||||||
if (rows_a != rows_b) | ||||||||||||
{ | ||||||||||||
unequal_msg = fmt::format("Row counter are not equal: {} vs {} ", rows_a, rows_b); | ||||||||||||
return false; | ||||||||||||
} | ||||||||||||
ywqzzy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
|
||||||||||||
size_t size_a = expected.columns(); | ||||||||||||
size_t size_b = actual.columns(); | ||||||||||||
if (size_a != size_b) | ||||||||||||
{ | ||||||||||||
unequal_msg = fmt::format("Columns size are not equal: {} vs {} ", size_a, size_b); | ||||||||||||
return false; | ||||||||||||
} | ||||||||||||
JaySon-Huang marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
|
||||||||||||
for (size_t i = 0; i < size_a; ++i) | ||||||||||||
{ | ||||||||||||
bool equal = columnEqual(expected.getByPosition(i).column, actual.getByPosition(i).column, unequal_msg); | ||||||||||||
if (!equal) | ||||||||||||
{ | ||||||||||||
unequal_msg = fmt::format("{}th columns are not equal, details: {}", i, unequal_msg); | ||||||||||||
return false; | ||||||||||||
} | ||||||||||||
} | ||||||||||||
return true; | ||||||||||||
} | ||||||||||||
|
||||||||||||
String formatBlockData(const Block & block) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think tiflash/dbms/src/TestUtils/FunctionTestUtils.cpp Lines 445 to 449 in e2cde35
|
||||||||||||
{ | ||||||||||||
size_t rows = block.rows(); | ||||||||||||
FmtBuffer buf; | ||||||||||||
for (size_t i = 0; i < rows; ++i) | ||||||||||||
{ | ||||||||||||
buf.joinStr( | ||||||||||||
block.begin(), | ||||||||||||
block.end(), | ||||||||||||
[i](const auto & block, FmtBuffer & fb) { | ||||||||||||
auto column = block.column; | ||||||||||||
auto field = (*column)[i]; | ||||||||||||
fb.append(field.toString()); | ||||||||||||
}, | ||||||||||||
", "); | ||||||||||||
} | ||||||||||||
return buf.toString(); | ||||||||||||
} | ||||||||||||
} // namespace DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2022 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <Columns/ColumnUtils.h> | ||
#include <Core/Block.h> | ||
|
||
namespace DB | ||
{ | ||
bool blockEqual(const Block & expected, const Block & actual, String & unequal_msg); | ||
|
||
String formatBlockData(const Block & block); | ||
} // namespace DB |
75 changes: 75 additions & 0 deletions
75
dbms/src/DataStreams/UniqRawResReformatBlockOutputStream.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2022 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <AggregateFunctions/AggregateFunctionUniq.h> | ||
#include <DataStreams/IProfilingBlockInputStream.h> | ||
|
||
namespace DB | ||
{ | ||
class UniqRawResReformatBlockOutputStream : public IProfilingBlockInputStream | ||
{ | ||
public: | ||
explicit UniqRawResReformatBlockOutputStream(const BlockInputStreamPtr & in_) | ||
: in(in_) | ||
{} | ||
|
||
String getName() const override { return "UniqRawResReformat"; } | ||
|
||
Block getHeader() const override { return in->getHeader(); } | ||
|
||
protected: | ||
Block readImpl() override | ||
{ | ||
while (true) | ||
{ | ||
Block block = in->read(); | ||
if (!block) | ||
return block; | ||
|
||
size_t num_columns = block.columns(); | ||
MutableColumns columns(num_columns); | ||
for (size_t i = 0; i < num_columns; ++i) | ||
{ | ||
ColumnWithTypeAndName & ori_column = block.getByPosition(i); | ||
|
||
if (std::string::npos != ori_column.name.find_first_of(uniq_raw_res_name)) | ||
{ | ||
MutableColumnPtr mutable_holder = ori_column.column->cloneEmpty(); | ||
|
||
for (size_t j = 0; j < ori_column.column->size(); ++j) | ||
{ | ||
Field field; | ||
ori_column.column->get(j, field); | ||
|
||
auto & str_ref = field.safeGet<String>(); | ||
|
||
ReadBufferFromString in(str_ref); | ||
AggregateFunctionUniqUniquesHashSetDataForVariadicRawRes set; | ||
set.set.read(in); | ||
|
||
mutable_holder->insert(std::to_string(set.set.size())); | ||
} | ||
ori_column.column = std::move(mutable_holder); | ||
} | ||
} | ||
return block; | ||
} | ||
} | ||
|
||
private: | ||
BlockInputStreamPtr in; | ||
}; | ||
} // namespace DB |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has a "gtest-specified" version in
FunctionTestUtils.cpp
😂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will not modify the code, since dbgNaturalDag that use the utils is not used for now.