[Fix](partial update) Fix core when doing partial update on tables with row column after schema change (#26632)

This commit is contained in:
bobhan1
2023-11-09 18:00:05 +08:00
committed by GitHub
parent 8bb6606662
commit eca747413d
6 changed files with 1319 additions and 11 deletions

View File

@ -554,8 +554,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;

View File

@ -2742,7 +2742,8 @@ Status Tablet::_get_segment_column_iterator(
}
// 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) {
@ -2755,13 +2756,12 @@ Status Tablet::fetch_value_through_row_column(RowsetSharedPtr input_rowset, uint
BetaRowsetSharedPtr rowset = std::static_pointer_cast<BetaRowset>(input_rowset);
CHECK(rowset);
const TabletSchemaSPtr tablet_schema = rowset->tablet_schema();
CHECK(tablet_schema->store_row_column());
CHECK(tablet_schema.store_row_column());
SegmentCacheHandle segment_cache_handle;
std::unique_ptr<segment_v2::ColumnIterator> column_iterator;
OlapReaderStatistics stats;
RETURN_IF_ERROR(_get_segment_column_iterator(rowset, segid,
tablet_schema->column(BeConsts::ROW_STORE_COL),
tablet_schema.column(BeConsts::ROW_STORE_COL),
&segment_cache_handle, &column_iterator, &stats));
// get and parse tuple row
vectorized::MutableColumnPtr column_ptr = vectorized::ColumnString::create();
@ -2774,7 +2774,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;
@ -3255,8 +3255,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;

View File

@ -438,7 +438,11 @@ public:
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);

View File

@ -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

View File

@ -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 """
@ -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} """