Userwhite commented on code in PR #65076: URL: https://github.com/apache/doris/pull/65076#discussion_r3527713329
########## be/test/storage/segment/row_binlog_source_data_writer_test.cpp: ########## @@ -0,0 +1,120 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 <gtest/gtest.h> + +#include <memory> +#include <string> +#include <vector> + +#include "core/field.h" +#include "core/value/decimalv2_value.h" +#include "storage/binlog.h" +#include "storage/iterator/olap_data_convertor.h" +#include "storage/segment/row_binlog_segment_writer.h" +#include "storage/tablet/tablet_schema.h" + +namespace doris::segment_v2 { + +namespace { + +TabletColumn create_column(int32_t unique_id, const std::string& name, FieldType type, bool is_key, + bool visible) { Review Comment: How about merge the code into row_binlog_segment_writer_test? ########## fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java: ########## @@ -2425,7 +2425,15 @@ public List<Column> generateTableRowBinlogSchema() { boolean needHistoricalValue = getBinlogConfig().getNeedHistoricalValue(); List<Column> beforeColumns = new ArrayList<>(); - for (Column column : getBaseSchema(false)) { + boolean seenHiddenNonKeyColumn = false; Review Comment: Why do we need to disable cases with hidden columns? Can't we just skip them in the Binlog schema? ########## regression-test/suites/row_binlog_p0/test_row_binlog_hidden_column_schema.groovy: ########## @@ -0,0 +1,72 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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. + +suite("test_row_binlog_hidden_column_schema", "nonConcurrent") { + if (isCloudMode()) { + return + } + + sql "DROP TABLE IF EXISTS test_mow_seq_hidden_column_row_binlog FORCE" + + sql """ + CREATE TABLE test_mow_seq_hidden_column_row_binlog ( + k1 INT, + v1 INT + ) + UNIQUE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true", + "light_schema_change" = "true", + "binlog.enable" = "true", + "binlog.format" = "ROW", + "binlog.need_historical_value" = "true" + ) + """ + + sql """ALTER TABLE test_mow_seq_hidden_column_row_binlog + ENABLE FEATURE "SEQUENCE_LOAD" + WITH PROPERTIES ("function_column.sequence_type" = "int")""" + + sql """ Review Comment: It should be contained in row_binlog_basic groovy now. ########## be/src/storage/segment/row_binlog_segment_writer.cpp: ########## @@ -430,48 +438,76 @@ Status RowBinlogSegmentWriter::_fill_before_columns(size_t num_rows) { Status RowBinlogSourceDataWriter::init() { _olap_data_convertor = std::make_unique<OlapBlockDataConvertor>(); - // _normal_column_ids: the columns which we need to write into binlog from source block if (UNLIKELY(_opt.source.tablet_schema == nullptr)) { return Status::InternalError("row binlog writer missing source_tablet_schema"); } - for (uint32_t i = 0; i < _opt.source.tablet_schema->num_visible_columns(); i++) { - _normal_column_ids.emplace_back(i); + + const auto& source_schema = _opt.source.tablet_schema; + // Row-binlog normal columns are a source-schema prefix: visible columns plus hidden key columns. + // Hidden non-key columns are only allowed after this prefix and are not written to row-binlog. + _normal_column_count = 0; + bool seen_hidden_non_key_column = false; + for (uint32_t cid = 0; cid < source_schema->num_columns(); ++cid) { + const auto& column = source_schema->column(cid); + if (!column.visible() && !column.is_key()) { Review Comment: why not allowed? for example, the table may have multi hidden column -- 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]
