Skip to content

Commit

Permalink
[Enhancement] (schema) add column type check (#28718)
Browse files Browse the repository at this point in the history
  • Loading branch information
luwei16 authored Dec 28, 2023
1 parent 6323c17 commit e610044
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 2 additions & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/rowset/segment_v2/column_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ class ColumnReader {

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);
Expand Down
10 changes: 10 additions & 0 deletions be/src/olap/rowset/segment_v2/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit e610044

Please sign in to comment.