hello-stephen commented on code in PR #71194:
URL: https://github.com/apache/doris/pull/71194#discussion_r4754428355
##########
be/src/core/data_type/data_type_factory.cpp:
##########
@@ -259,11 +259,21 @@ DataTypePtr DataTypeFactory::create_data_type(const
PColumnMeta& pcolumn) {
case PGenericType::STRING:
nested = std::make_shared<DataTypeString>();
break;
- case PGenericType::VARIANT:
- nested =
std::make_shared<DataTypeVariantV2>(pcolumn.variant_max_subcolumns_count(),
-
pcolumn.variant_enable_doc_mode(),
- pcolumn.variant_is_v2());
+ case PGenericType::VARIANT: {
+ using WireFormat = DataTypeVariantV2::WireFormat;
+ // Older V1 writers omit the doc-mode field and end at the sparse map.
+ // The later V1 layout includes a doc-value map even for
doc_mode=false.
+ auto wire_format = WireFormat::V1;
+ if (pcolumn.variant_is_v2()) {
+ wire_format = WireFormat::V2;
+ } else if (pcolumn.has_variant_enable_doc_mode()) {
Review Comment:
[P1] Do not infer the pre-doc layout solely from this metadata flag
Historical writers from `075c7daf2e` through `2f60973b98^` already appended
the doc-value map unconditionally, but their
`DataTypeVariant::to_pb_column_meta` did not emit `variant_enable_doc_mode`
(the field did not yet exist). These WALs select `V1` here and leave even an
empty doc map unread. For a one-row `[VARIANT, BIGINT NOT NULL]` block with
tail value `211`, the BIGINT decoder accepts that map's const/row header and
reads its zero offset as `0`; `Block::deserialize` returns success without
checking the remaining bytes. Handle this historical layout before accepting it
as pre-doc, and add an unmarked-doc-map fixture: the current test helper always
sets the flag when it appends a doc map.
--
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]