github-actions[bot] commented on code in PR #62648:
URL: https://github.com/apache/doris/pull/62648#discussion_r3111241468
##########
be/src/storage/segment/column_reader.cpp:
##########
@@ -2564,4 +2566,100 @@ Status RowIdColumnIteratorV2::read_by_rowids(const
rowid_t* rowids, const size_t
return Status::OK();
}
+// Helper: unwrap ColumnNullable if present, return the inner column.
+// Sets *is_nullable = true if the outer column is nullable.
+static const IColumn& unwrap_nullable(const IColumn& col, bool* is_nullable) {
+ if (const auto* nullable = check_and_get_column<ColumnNullable>(col)) {
+ *is_nullable = true;
+ return nullable->get_nested_column();
+ }
+ *is_nullable = false;
+ return col;
+}
+
+Status FileColumnIterator::check_column_type(const IColumn& dst) const {
+ auto expected_type = _reader->get_vec_data_type();
+ if (!expected_type) {
+ return Status::OK();
+ }
Review Comment:
This breaks the normal predicate-read path. In `_lazy_init()` we materialize
`_predicate_column_ids` with `Schema::get_predicate_column_ptr()` /
`ColumnDictI32`, and `_read_columns_by_index()` now calls `check_column_type()`
on those columns before every read. For an `INT` predicate column `dst_inner`
is `PredicateColumnType<TYPE_INT>`, while `expected_type->create_column()` is
`ColumnVector<Int32>`; for low-cardinality strings it can be `ColumnDictI32` vs
`ColumnString`. So ordinary scans with pushed-down predicates will now return
`InternalError` even though the decoder already supports these storage-layer
column types. This needs a compatibility check for the valid destination
implementations, not exact `typeid()` equality against `create_column()`.`
##########
be/src/storage/segment/column_reader.cpp:
##########
@@ -2564,4 +2566,100 @@ Status RowIdColumnIteratorV2::read_by_rowids(const
rowid_t* rowids, const size_t
return Status::OK();
}
+// Helper: unwrap ColumnNullable if present, return the inner column.
+// Sets *is_nullable = true if the outer column is nullable.
+static const IColumn& unwrap_nullable(const IColumn& col, bool* is_nullable) {
+ if (const auto* nullable = check_and_get_column<ColumnNullable>(col)) {
+ *is_nullable = true;
+ return nullable->get_nested_column();
+ }
+ *is_nullable = false;
+ return col;
+}
+
+Status FileColumnIterator::check_column_type(const IColumn& dst) const {
+ auto expected_type = _reader->get_vec_data_type();
+ if (!expected_type) {
+ return Status::OK();
+ }
+ auto expected_col = expected_type->create_column();
+ // Compare the column structure: both may be nullable-wrapped
+ bool dst_nullable = false;
+ bool expected_nullable = false;
+ const auto& dst_inner = unwrap_nullable(dst, &dst_nullable);
+ const auto& expected_inner = unwrap_nullable(*expected_col,
&expected_nullable);
+ if (typeid(dst_inner) != typeid(expected_inner)) {
+ return Status::InternalError(
+ "Column type mismatch in FileColumnIterator for column '{}': "
+ "expected {} but got {}",
+ _column_name, demangle(typeid(expected_inner).name()),
+ demangle(typeid(dst_inner).name()));
+ }
+ return Status::OK();
+}
+
+Status MapFileColumnIterator::check_column_type(const IColumn& dst) const {
+ bool is_nullable = false;
+ const auto& inner = unwrap_nullable(dst, &is_nullable);
+ const auto* map_col = check_and_get_column<ColumnMap>(inner);
+ if (!map_col) {
+ return Status::InternalError(
+ "Column type mismatch in MapFileColumnIterator for column
'{}': "
+ "expected ColumnMap but got {}",
+ _column_name, demangle(typeid(inner).name()));
+ }
+ // Recursively check key and value sub-columns
+ if (_key_iterator) {
+ RETURN_IF_ERROR(_key_iterator->check_column_type(map_col->get_keys()));
+ }
+ if (_val_iterator) {
+
RETURN_IF_ERROR(_val_iterator->check_column_type(map_col->get_values()));
+ }
+ return Status::OK();
+}
+
+Status StructFileColumnIterator::check_column_type(const IColumn& dst) const {
+ bool is_nullable = false;
+ const auto& inner = unwrap_nullable(dst, &is_nullable);
+ const auto* struct_col = check_and_get_column<ColumnStruct>(inner);
+ if (!struct_col) {
+ return Status::InternalError(
+ "Column type mismatch in StructFileColumnIterator for column
'{}': "
+ "expected ColumnStruct but got {}",
+ _column_name, demangle(typeid(inner).name()));
+ }
+ // Recursively check each sub-column
Review Comment:
This only validates the common prefix of the struct layout. If `dst` has a
different arity from `_sub_column_iterators`, `check_column_type()` can still
return OK and `next_batch()` will then keep reading with the mismatched layout.
`DataTypeStruct::check_column()` already enforces exact `tuple_size()`
equality; this validator should do the same so malformed struct destinations
are rejected before the read.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]