Skip to content

Commit

Permalink
[BugFix] Fix some bug of light schema change (StarRocks#30485)
Browse files Browse the repository at this point in the history
This pr fixes some bugs:

This pr([Feature] Support light schema change of adding and dropping columns StarRocks#26246) supports light schema change and we add tablet schema in rowset meta. But in the course of multiple conflict resolution, the associated logic is lost. In addition, this pr change the location num of tablet_schema in RowsetMetaPB for better compatibility.
When we create a column iterator in segment, if we provide tablet schema in read options, we should use the given tablet schema in create column iterator.

Signed-off-by: zhangqiang <qiangzh95@gmail.com>
  • Loading branch information
sevev authored Sep 13, 2023
1 parent 5b047d8 commit 5e0649e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions be/src/storage/rowset/rowset_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ StatusOr<RowsetSharedPtr> RowsetWriter::build() {
} else {
_rowset_meta_pb->set_rowset_state(VISIBLE);
}
// we don't support light schema change for primary key table so far, skip it
if (_context.tablet_schema->keys_type() != KeysType::PRIMARY_KEYS) {
_context.tablet_schema->to_schema_pb(_rowset_meta_pb->mutable_tablet_schema());
}

auto rowset_meta = std::make_shared<RowsetMeta>(_rowset_meta_pb);
RowsetSharedPtr rowset;
RETURN_IF_ERROR(
Expand Down
1 change: 0 additions & 1 deletion be/src/storage/rowset/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ StatusOr<ChunkIteratorPtr> Segment::_new_iterator(const Schema& schema, const Se
}
if (!_column_readers.at(column_unique_id)->segment_zone_map_filter(pair.second)) {
// skip segment zonemap filter when this segment has column files link to it.
const TabletColumn& tablet_column = _tablet_schema->column(column_id);
if (tablet_column.is_key() || _use_segment_zone_map_filter(read_options)) {
read_options.stats->segment_stats_filtered += _column_readers.at(column_unique_id)->num_rows();
return Status::EndOfFile(strings::Substitute("End of file $0, empty iterator", _fname));
Expand Down
4 changes: 2 additions & 2 deletions gensrc/proto/olap_file.proto
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ message RowsetMetaPB {
optional int64 num_segments = 22;
// rowset id definition, it will replace required rowset id
optional string rowset_id = 23;
// tablet meta pb, for compaction
optional TabletSchemaPB tablet_schema = 24;
// to indicate whether the data between the segments overlap
optional SegmentsOverlapPB segments_overlap_pb = 51 [default = OVERLAP_UNKNOWN];
// every segment in a rowset has an unique uint32 id
Expand All @@ -168,6 +166,8 @@ message RowsetMetaPB {
optional int64 total_update_row_size = 58;
// true if it is generated by partial_schema_change
optional bool partial_schema_change = 59;
// tablet meta pb, for compaction
optional TabletSchemaPB tablet_schema = 60;
}

enum DataFileType {
Expand Down

0 comments on commit 5e0649e

Please sign in to comment.