yiguolei commented on code in PR #64484:
URL: https://github.com/apache/doris/pull/64484#discussion_r3410777520
##########
be/test/storage/tablet/tablet_meta_test.cpp:
##########
@@ -403,4 +405,98 @@ TEST(TabletMetaTest, TestDeleteBitmap) {
EXPECT_EQ(d.cardinality(), 500);
}
+TEST(TabletMetaTest, test_row_binlog_schema_binlog_col_idx) {
+ // 1. 创建 TCreateTabletReq
+ TCreateTabletReq request;
+ request.tablet_id = 10086;
+
+ // 手动构造基础 tablet_schema
+ TTabletSchema base_schema;
+ base_schema.keys_type = TKeysType::UNIQUE_KEYS;
+ base_schema.short_key_column_count = 1;
+
+ // 添加普通列 k1
+ TColumn k1_col;
+ k1_col.column_name = "k1";
+ TColumnType k1_type;
+ k1_type.type = TPrimitiveType::INT;
+ k1_col.column_type = k1_type;
+ k1_col.is_key = true;
+ k1_col.is_allow_null = false;
+ base_schema.columns.push_back(k1_col);
+
+ // 添加普通列 v1
+ TColumn v1_col;
+ v1_col.column_name = "v1";
+ TColumnType v1_type;
+ v1_type.type = TPrimitiveType::INT;
+ v1_col.column_type = v1_type;
+ v1_col.is_key = false;
+ v1_col.is_allow_null = true;
+ v1_col.aggregation_type = TAggregationType::NONE;
+ base_schema.columns.push_back(v1_col);
+
+ request.tablet_schema = base_schema;
+
+ // 启用 row binlog
+ testutil::enable_row_binlog(&request);
+
+ // 获取包含 binlog 列的完整 schema
+ TTabletSchema row_binlog_schema = request.row_binlog_schema;
+
+ // 动态查找 binlog 列的实际索引
+ int expected_lsn_idx = -1;
+ int expected_ts_idx = -1;
+ for (size_t i = 0; i < row_binlog_schema.columns.size(); ++i) {
+ if (row_binlog_schema.columns[i].column_name == BINLOG_LSN_COL) {
+ expected_lsn_idx = static_cast<int>(i);
+ }
+ if (row_binlog_schema.columns[i].column_name == BINLOG_TIMESTAMP_COL) {
+ expected_ts_idx = static_cast<int>(i);
+ }
+ }
+
+ // 确保找到了 binlog 列
+ ASSERT_NE(expected_lsn_idx, -1) << "Failed to find " << BINLOG_LSN_COL;
+ ASSERT_NE(expected_ts_idx, -1) << "Failed to find " <<
BINLOG_TIMESTAMP_COL;
+
+ // 设置 col_unique_id
+ for (size_t i = 0; i < row_binlog_schema.columns.size(); ++i) {
+ row_binlog_schema.columns[i].col_unique_id = static_cast<int32_t>(i);
+ }
+
+ // 创建 col_ordinal_to_unique_id 映射
+ std::unordered_map<uint32_t, uint32_t> col_ordinal_to_unique_id;
+ for (uint32_t i = 0; i < row_binlog_schema.columns.size(); ++i) {
+ col_ordinal_to_unique_id[i] = i;
+ }
+
+ // 构造 SchemaCreateOptions
Review Comment:
注释不要使用中文
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]