[Enhancement] (schema) add column type check (#28718)

This commit is contained in:
Luwei
2023-12-28 17:11:24 +08:00
committed by GitHub
parent 6323c17ad5
commit e610044bae
4 changed files with 15 additions and 0 deletions

View File

@ -1144,6 +1144,7 @@ DEFINE_Bool(enable_snapshot_action, "false");
DEFINE_mInt32(variant_max_merged_tablet_schema_size, "2048");
DEFINE_mBool(enable_column_type_check, "true");
// 128 MB
DEFINE_mInt64(local_exchange_buffer_mem_limit, "134217728");

View File

@ -1223,6 +1223,8 @@ DECLARE_mInt32(variant_max_merged_tablet_schema_size);
DECLARE_mInt64(local_exchange_buffer_mem_limit);
DECLARE_mBool(enable_column_type_check);
#ifdef BE_TEST
// test s3
DECLARE_String(test_s3_resource);

View File

@ -182,6 +182,8 @@ public:
void disable_index_meta_cache() { _use_index_page_cache = false; }
FieldType get_meta_type() { return _meta_type; }
private:
ColumnReader(const ColumnReaderOptions& opts, const ColumnMetaPB& meta, uint64_t num_rows,
io::FileReaderSPtr file_reader);

View File

@ -524,6 +524,16 @@ Status Segment::new_column_iterator(const TabletColumn& tablet_column,
ColumnIterator* it;
RETURN_IF_ERROR(_column_readers.at(tablet_column.unique_id())->new_iterator(&it));
iter->reset(it);
if (config::enable_column_type_check &&
tablet_column.type() != _column_readers.at(tablet_column.unique_id())->get_meta_type()) {
LOG(WARNING) << "different type between schema and column reader,"
<< " column schema name: " << tablet_column.name()
<< " column schema type: " << int(tablet_column.type())
<< " column reader meta type"
<< int(_column_readers.at(tablet_column.unique_id())->get_meta_type());
return Status::InternalError("different type between schema and column reader");
}
return Status::OK();
}