-
Notifications
You must be signed in to change notification settings - Fork 411
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
Print content of columns for gtest #5243
Merged
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0f1029a
complete
xzhangxian1008 95cfb94
update
xzhangxian1008 9e8de2b
update
xzhangxian1008 7277852
merge
xzhangxian1008 304e4df
Merge branch 'master' into dev1
xzhangxian1008 5633cb0
update
xzhangxian1008 c426d28
update
xzhangxian1008 e5f8209
Merge branch 'master' into dev1
xzhangxian1008 e5a46e1
update
xzhangxian1008 dabae34
udpate
xzhangxian1008 0f622db
Merge branch 'master' into dev1
xzhangxian1008 1fc7443
add test
xzhangxian1008 1a8bf1a
Merge branch 'master' into dev1
xzhangxian1008 9bd3f39
add space
xzhangxian1008 2b9446a
update
xzhangxian1008 db56449
Merge branch 'master' into dev1
xzhangxian1008 feaa36e
Merge branch 'master' into dev1
ti-chi-bot 77ae901
Merge branch 'master' into dev1
ti-chi-bot 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 | ||||
---|---|---|---|---|---|---|
|
@@ -13,6 +13,7 @@ | |||||
// limitations under the License. | ||||||
|
||||||
#include <Columns/ColumnNullable.h> | ||||||
#include <Common/FmtUtils.h> | ||||||
#include <Core/ColumnNumbers.h> | ||||||
#include <Core/Row.h> | ||||||
#include <DataTypes/DataTypeNothing.h> | ||||||
|
@@ -120,6 +121,7 @@ ::testing::AssertionResult blockEqual( | |||||
{ | ||||||
const auto & expected_col = expected.getByPosition(i); | ||||||
const auto & actual_col = actual.getByPosition(i); | ||||||
|
||||||
auto cmp_res = columnEqual(expected_col, actual_col); | ||||||
if (!cmp_res) | ||||||
return cmp_res; | ||||||
|
@@ -375,9 +377,63 @@ ColumnWithTypeAndName toNullableDatetimeVec(String name, const std::vector<Strin | |||||
return {makeColumn<Nullable<MyDateTime>>(data_type, vec), data_type, name, 0}; | ||||||
} | ||||||
|
||||||
String getColumnsContent(const ColumnsWithTypeAndName & cols) | ||||||
{ | ||||||
if (cols.size() <= 0) | ||||||
return ""; | ||||||
return getColumnsContent(cols, 0, cols[0].column->size() - 1); | ||||||
} | ||||||
|
||||||
String getColumnsContent(const ColumnsWithTypeAndName & cols, size_t begin, size_t end) | ||||||
{ | ||||||
const size_t col_num = cols.size(); | ||||||
if (col_num <= 0) | ||||||
return ""; | ||||||
|
||||||
const size_t col_size = cols[0].column->size(); | ||||||
assert(begin <= end); | ||||||
assert(col_size > end); | ||||||
assert(col_size > begin); | ||||||
|
||||||
bool is_same = true; | ||||||
|
||||||
for (size_t i = 1; i < col_num; ++i) | ||||||
{ | ||||||
if (cols[i].column->size() != col_size) | ||||||
is_same = false; | ||||||
} | ||||||
|
||||||
assert(is_same); /// Ensure the sizes of columns in cols are the same | ||||||
|
||||||
std::vector<std::pair<size_t, String>> col_content; | ||||||
FmtBuffer fmt_buf; | ||||||
for (size_t i = 0; i < col_num; ++i) | ||||||
{ | ||||||
/// Push the column name | ||||||
fmt_buf.append(fmt::format("{}: (", cols[i].name)); | ||||||
for (size_t j = begin; j <= end; ++j) | ||||||
col_content.push_back(std::make_pair(j, (*cols[i].column)[j].toString())); | ||||||
|
||||||
/// Add content | ||||||
fmt_buf.joinStr( | ||||||
col_content.begin(), | ||||||
col_content.end(), | ||||||
[](const auto & content, FmtBuffer & fmt_buf) { | ||||||
fmt_buf.append(fmt::format("{}: {}", content.first, content.second)); | ||||||
}, | ||||||
","); | ||||||
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.
Suggested change
Maybe better? |
||||||
|
||||||
fmt_buf.append(")\n"); | ||||||
col_content.clear(); | ||||||
} | ||||||
|
||||||
return fmt_buf.toString(); | ||||||
} | ||||||
|
||||||
ColumnsWithTypeAndName createColumns(const ColumnsWithTypeAndName & cols) | ||||||
{ | ||||||
return cols; | ||||||
} | ||||||
|
||||||
} // namespace tests | ||||||
} // 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
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.
maybe add a unit test for the function?
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.
Done