This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new fc50351563c [Enhancement] (schema) add column type check #28718 
(#29176)
fc50351563c is described below

commit fc50351563c022f3a44205c2520c9874e3db0a0a
Author: Luwei <[email protected]>
AuthorDate: Thu Dec 28 17:11:33 2023 +0800

    [Enhancement] (schema) add column type check #28718 (#29176)
---
 be/src/common/config.cpp                      |  2 ++
 be/src/common/config.h                        |  2 ++
 be/src/olap/rowset/segment_v2/column_reader.h |  2 ++
 be/src/olap/rowset/segment_v2/segment.cpp     | 10 ++++++++++
 4 files changed, 16 insertions(+)

diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index 055fd13b46e..ee7df5d96db 100644
--- a/be/src/common/config.cpp
+++ b/be/src/common/config.cpp
@@ -1113,6 +1113,8 @@ DEFINE_Bool(enable_snapshot_action, "false");
 
 DEFINE_mInt32(s3_writer_buffer_allocation_timeout_second, "60");
 
+DEFINE_mBool(enable_column_type_check, "true");
+
 // clang-format off
 #ifdef BE_TEST
 // test s3
diff --git a/be/src/common/config.h b/be/src/common/config.h
index 7d4eaffda64..c865c3b72b2 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -1171,6 +1171,8 @@ DECLARE_Bool(enable_snapshot_action);
 // The timeout config for S3 write buffer allocation
 DECLARE_mInt32(s3_writer_buffer_allocation_timeout_second);
 
+DECLARE_mBool(enable_column_type_check);
+
 #ifdef BE_TEST
 // test s3
 DECLARE_String(test_s3_resource);
diff --git a/be/src/olap/rowset/segment_v2/column_reader.h 
b/be/src/olap/rowset/segment_v2/column_reader.h
index 7964555adeb..492463a8ff0 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.h
+++ b/be/src/olap/rowset/segment_v2/column_reader.h
@@ -180,6 +180,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);
diff --git a/be/src/olap/rowset/segment_v2/segment.cpp 
b/be/src/olap/rowset/segment_v2/segment.cpp
index 483a8e81949..3f167112ebb 100644
--- a/be/src/olap/rowset/segment_v2/segment.cpp
+++ b/be/src/olap/rowset/segment_v2/segment.cpp
@@ -387,6 +387,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();
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to