Skip to content

Commit

Permalink
[Fix](partial update) Fix core when doing partial update on tables wi…
Browse files Browse the repository at this point in the history
…th row column after schema change #26632 (#26695)
  • Loading branch information
bobhan1 authored Nov 10, 2023
1 parent a4bf26a commit c3f80f1
Show file tree
Hide file tree
Showing 6 changed files with 1,319 additions and 11 deletions.
4 changes: 2 additions & 2 deletions be/src/olap/rowset/segment_v2/segment_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ Status SegmentWriter::fill_missing_columns(vectorized::MutableColumns& mutable_f
read_index[id_and_pos.pos] = read_idx++;
}
if (has_row_column) {
auto st = _tablet->fetch_value_through_row_column(rowset, seg_it.first, rids,
cids_missing, old_value_block);
auto st = _tablet->fetch_value_through_row_column(
rowset, *_tablet_schema, seg_it.first, rids, cids_missing, old_value_block);
if (!st.ok()) {
LOG(WARNING) << "failed to fetch value through row column";
return st;
Expand Down
14 changes: 7 additions & 7 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2686,15 +2686,15 @@ void Tablet::update_max_version_schema(const TabletSchemaSPtr& tablet_schema) {
}

// fetch value by row column
Status Tablet::fetch_value_through_row_column(RowsetSharedPtr input_rowset, uint32_t segid,
Status Tablet::fetch_value_through_row_column(RowsetSharedPtr input_rowset,
const TabletSchema& tablet_schema, uint32_t segid,
const std::vector<uint32_t>& rowids,
const std::vector<uint32_t>& cids,
vectorized::Block& block) {
// read row data
BetaRowsetSharedPtr rowset = std::static_pointer_cast<BetaRowset>(input_rowset);
CHECK(rowset);

const TabletSchemaSPtr tablet_schema = rowset->tablet_schema();
SegmentCacheHandle segment_cache;
RETURN_IF_ERROR(SegmentLoader::instance()->load_segments(rowset, &segment_cache, true));
// find segment
Expand All @@ -2713,10 +2713,10 @@ Status Tablet::fetch_value_through_row_column(RowsetSharedPtr input_rowset, uint
LOG_EVERY_N(INFO, 500) << "fetch_value_by_rowids, cost(us):" << watch.elapsed_time() / 1000
<< ", row_batch_size:" << rowids.size();
});
CHECK(tablet_schema->store_row_column());
CHECK(tablet_schema.store_row_column());
// create _source column
std::unique_ptr<segment_v2::ColumnIterator> column_iterator;
RETURN_IF_ERROR(segment->new_column_iterator(tablet_schema->column(BeConsts::ROW_STORE_COL),
RETURN_IF_ERROR(segment->new_column_iterator(tablet_schema.column(BeConsts::ROW_STORE_COL),
&column_iterator));
segment_v2::ColumnIteratorOptions opt;
OlapReaderStatistics stats;
Expand All @@ -2735,7 +2735,7 @@ Status Tablet::fetch_value_through_row_column(RowsetSharedPtr input_rowset, uint
std::vector<std::string> default_values;
default_values.resize(cids.size());
for (int i = 0; i < cids.size(); ++i) {
const TabletColumn& column = tablet_schema->column(cids[i]);
const TabletColumn& column = tablet_schema.column(cids[i]);
vectorized::DataTypePtr type =
vectorized::DataTypeFactory::instance().create_data_type(column);
col_uid_to_idx[column.unique_id()] = i;
Expand Down Expand Up @@ -3253,8 +3253,8 @@ Status Tablet::read_columns_by_plan(TabletSchemaSPtr tablet_schema,
(*read_index)[id_and_pos.pos] = read_idx++;
}
if (has_row_column) {
auto st = fetch_value_through_row_column(rowset_iter->second, seg_it.first, rids,
cids_to_read, block);
auto st = fetch_value_through_row_column(rowset_iter->second, *tablet_schema,
seg_it.first, rids, cids_to_read, block);
if (!st.ok()) {
LOG(WARNING) << "failed to fetch value through row column";
return st;
Expand Down
6 changes: 5 additions & 1 deletion be/src/olap/tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,11 @@ class Tablet : public BaseTablet {
const TabletColumn& tablet_column,
vectorized::MutableColumnPtr& dst);

Status fetch_value_through_row_column(RowsetSharedPtr input_rowset, uint32_t segid,
// We use the TabletSchema from the caller because the TabletSchema in the rowset'meta
// may be outdated due to schema change. Also note that the the cids should indicate the indexes
// of the columns in the TabletSchema passed in.
Status fetch_value_through_row_column(RowsetSharedPtr input_rowset,
const TabletSchema& tablet_schema, uint32_t segid,
const std::vector<uint32_t>& rowids,
const std::vector<uint32_t>& cids,
vectorized::Block& block);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql1 --
1 0 0 0 0 0 0 0 0 0

-- !sql2 --
1 1 1 0 0 0 0 0 0 0 0

-- !sql3 --
1 1 1 0 0 0 0 0 0 0 10

-- !sql4 --
1 0 0 0 0 0 0 0 0 0

-- !sql5 --
1 1 1 0 0 0 0 0 0

-- !sql6 --
1 2 1 0 0 0 0 1 0

-- !sql7 --
1 0 0 0 0 0 0 0 0 0

-- !sql8 --
1 1 1.0 0 0 0 0 0 0 0

-- !sql9 --
1

-- !sql10 --
1 0 0 0 0 0 0 0 0 0

-- !sql11 --
1 1 1 0 0 0 0 0 0 0

-- !sql12 --
1 0 0 0 0 0 0 0 0 0

-- !sql13 --
1 1 1 0 0 0 0 0 0 0

-- !sql14 --
1 0 0 0 0 0 0 0 0 0

-- !sql15 --
1 1 1 0 0 0 0 0 0 0 0

-- !sql16 --
1 1 1 0 0 0 0 0 0 0 10

-- !sql17 --
1 0 0 0 0 0 0 0 0 0

-- !sql18 --
1 1 1 0 0 0 0 0 0

-- !sql19 --
1 0 0 0 0 0 0 0 0 0

-- !sql20 --
1 1 1.0 0 0 0 0 0 0 0

-- !sql21 --
1

-- !sql23 --
1 0 0 0 0 0 0 0 0 0

-- !sql24 --
1 1 1 0 0 0 0 0 0 0

-- !sql25 --
1 0 0 0 0 0 0 0 0 0

-- !sql26 --
1 1 1 0 0 0 0 0 0 0

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
// under the License.

suite("test_partial_update_schema_change", "p0") {
// test add value column

/* ============================================== light schema change cases: ============================================== */

// test add value column
def tableName = "test_partial_update_light_schema_change_add_column"
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
Expand Down Expand Up @@ -618,6 +621,8 @@ suite("test_partial_update_schema_change", "p0") {

sql """ DROP TABLE IF EXISTS ${tableName} """

/* ============================================== schema change cases: ============================================== */

// test add value column
tableName = "test_partial_update_schema_change_add_column"
sql """ DROP TABLE IF EXISTS ${tableName} """
Expand Down
Loading

0 comments on commit c3f80f1

Please sign in to comment.