Skip to content

Commit 3547e89

Browse files
committed
[test](be) Verify partial row binlog values
### What problem does this PR solve? Issue Number: close apache#65418 Related PR: apache#65076 Problem Summary: The row-binlog partial-update test only verified that the rowset could be built, so incorrect source-column filtering or row-binlog ordinal mapping could still pass. Read the generated row-binlog rowset back and verify the visible key, hidden key, updated value, missing nullable value, LSN, operation, and timestamp. Also align the test OP and timestamp nullability with the FE-generated row-binlog schema. ### Release note None ### Check List (For Author) - Test: Unit Test / Manual test - build-support/check-format.sh - git diff --check - ./run-be-ut.sh --run '--filter=GroupRowsetWriterTest.partialUpdateSkipsHiddenNonKeyColumns' -j20 was blocked before test execution because thirdparty/installed/lib64/libaws-cpp-sdk-identity-management.a is missing - Behavior changed: No - Does this need documentation: No
1 parent 0e45a73 commit 3547e89

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

‎be/test/olap/rowset/group_rowset_writer_test.cpp‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include "storage/binlog.h"
3939
#include "storage/olap_define.h"
4040
#include "storage/partial_update_info.h"
41+
#include "storage/rowset/rowset_reader.h"
42+
#include "storage/rowset/rowset_reader_context.h"
4143
#include "storage/storage_engine.h"
4244
#include "storage/tablet/tablet.h"
4345
#include "storage/tablet/tablet_manager.h"
@@ -90,6 +92,8 @@ class GroupRowsetWriterTest : public testing::Test {
9092
testutil::enable_row_binlog(&_request);
9193
_request.row_binlog_schema.columns.erase(_request.row_binlog_schema.columns.begin() + 5);
9294
_request.row_binlog_schema.columns.erase(_request.row_binlog_schema.columns.begin() + 2);
95+
_request.row_binlog_schema.columns[5].__set_is_allow_null(true);
96+
_request.row_binlog_schema.columns[6].__set_is_allow_null(true);
9397
auto profile = std::make_unique<RuntimeProfile>("GroupRowsetWriterTest");
9498
ASSERT_TRUE(engine_ptr->create_tablet(_request, profile.get()).ok());
9599
_tablet = engine_ptr->tablet_manager()->get_tablet(_request.tablet_id);
@@ -307,7 +311,37 @@ TEST_F(GroupRowsetWriterTest, partialUpdateSkipsHiddenNonKeyColumns) {
307311

308312
RowsetSharedPtr row_binlog_rowset;
309313
ASSERT_TRUE(row_binlog_writer->build(row_binlog_rowset).ok());
310-
EXPECT_EQ(1, row_binlog_rowset->num_segments());
314+
ASSERT_EQ(1, row_binlog_rowset->num_segments());
315+
316+
const auto& row_binlog_schema = _tablet->row_binlog_tablet_schema();
317+
ASSERT_EQ(7, row_binlog_schema->num_columns());
318+
std::vector<uint32_t> return_columns {0, 1, 2, 3, 4, 5, 6};
319+
RowsetReaderContext reader_context;
320+
reader_context.tablet_schema = row_binlog_schema;
321+
reader_context.need_ordered_result = false;
322+
reader_context.return_columns = &return_columns;
323+
324+
RowsetReaderSharedPtr rowset_reader;
325+
ASSERT_TRUE(row_binlog_rowset->create_reader(&rowset_reader).ok());
326+
ASSERT_TRUE(rowset_reader->init(&reader_context).ok());
327+
328+
Block output_block = row_binlog_schema->create_block();
329+
auto status = rowset_reader->next_batch(&output_block);
330+
ASSERT_TRUE(status.ok()) << status;
331+
ASSERT_EQ(1, output_block.rows());
332+
ASSERT_EQ(return_columns.size(), output_block.columns());
333+
334+
EXPECT_EQ(1, output_block.get_by_position(0).column->get_int(0));
335+
EXPECT_EQ(1001, output_block.get_by_position(1).column->get_int(0));
336+
EXPECT_EQ(20, output_block.get_by_position(2).column->get_int(0));
337+
EXPECT_TRUE(output_block.get_by_position(3).column->is_null_at(0));
338+
EXPECT_EQ(1000, output_block.get_by_position(4).column->get_int(0));
339+
EXPECT_EQ(ROW_BINLOG_APPEND, output_block.get_by_position(5).column->get_int(0));
340+
EXPECT_TRUE(output_block.get_by_position(6).column->is_null_at(0));
341+
342+
Block eof_block = row_binlog_schema->create_block();
343+
status = rowset_reader->next_batch(&eof_block);
344+
EXPECT_TRUE(status.is<END_OF_FILE>()) << status;
311345
}
312346

313347
} // namespace doris

0 commit comments

Comments
 (0)