mrhhsg commented on code in PR #68125:
URL: https://github.com/apache/doris/pull/68125#discussion_r4226722047


##########
be/src/exec/rowid_fetcher.cpp:
##########
@@ -995,61 +1044,63 @@ Status RowIdStorageReader::read_doris_format_row(
         segment = seg_item.segment;
     }
 
+    if (fetch_columns.size() < slots.size()) {
+        return Status::InternalError(
+                "fetch request carries {} column descs for {} slots, slot {} 
has none",
+                fetch_columns.size(), slots.size(), 
slots[fetch_columns.size()].col_name());
+    }
+
     // if row_store_read_struct not empty, means the line we should read from 
row_store
     if (!row_store_read_struct.default_values.empty()) {
         if (!tablet->tablet_schema()->has_row_store_for_all_columns()) {
             return Status::InternalError("Tablet {} does not have row store 
for all columns",
                                          tablet->tablet_id());
         }
-        auto result_columns_guard = result_block.mutate_columns_scoped();
-        MutableColumns& result_columns = 
result_columns_guard.mutable_columns();
-        io::IOContext io_ctx;
-        io_ctx.reader_type = ReaderType::READER_QUERY;
-        io_ctx.file_cache_stats = &stats.file_cache_stats;
-        io_ctx.file_cache_miss_policy = file_cache_miss_policy;
-        for (auto row_id : row_ids) {
-            RowLocation loc(rowset_id, segment->id(), 
cast_set<uint32_t>(row_id));
-            row_store_read_struct.row_store_buffer.clear();
-            RETURN_IF_ERROR(scope_timer_run(
-                    [&]() {
-                        return tablet->lookup_row_data({}, loc, rowset, stats,
-                                                       
row_store_read_struct.row_store_buffer,
-                                                       false, &io_ctx);
-                    },
-                    lookup_row_data_ms));
-
-            RETURN_IF_ERROR(JsonbSerializeUtil::jsonb_to_columns(
-                    row_store_read_struct.serdes, 
row_store_read_struct.row_store_buffer.data(),
-                    row_store_read_struct.row_store_buffer.size(),
-                    row_store_read_struct.col_uid_to_idx, result_columns,
-                    row_store_read_struct.default_values, {}));
+        if (row_store_read_struct.decode_row_store) {
+            auto result_columns_guard = result_block.mutate_columns_scoped();
+            MutableColumns& result_columns = 
result_columns_guard.mutable_columns();
+            io::IOContext io_ctx;
+            io_ctx.reader_type = ReaderType::READER_QUERY;
+            io_ctx.file_cache_stats = &stats.file_cache_stats;
+            io_ctx.file_cache_miss_policy = file_cache_miss_policy;
+            for (auto row_id : row_ids) {
+                RowLocation loc(rowset_id, segment->id(), 
cast_set<uint32_t>(row_id));
+                row_store_read_struct.row_store_buffer.clear();
+                RETURN_IF_ERROR(scope_timer_run(
+                        [&]() {
+                            return tablet->lookup_row_data({}, loc, rowset, 
stats,
+                                                           
row_store_read_struct.row_store_buffer,
+                                                           false, &io_ctx);
+                        },
+                        lookup_row_data_ms));
+
+                RETURN_IF_ERROR(JsonbSerializeUtil::jsonb_to_columns(
+                        row_store_read_struct.serdes, 
row_store_read_struct.row_store_buffer.data(),
+                        row_store_read_struct.row_store_buffer.size(),
+                        row_store_read_struct.col_uid_to_idx, result_columns,
+                        row_store_read_struct.default_values,
+                        row_store_read_struct.include_col_uids));

Review Comment:
   Addressed in 6951a5bbbf9. `JsonbSerializeUtil::jsonb_to_columns` now takes 
the already-appended row count from a column named in `include_cids` (which 
this call always fills) instead of `dst_columns[0]`, so an excluded hidden slot 
in front no longer resets the count on every row; callers without an include 
set keep counting from slot 0.
   
   `BlockSerializeTest.JsonbToColumnsCountsRowsFromIncludedColumn` decodes a 
two-row batch whose first slot is excluded and whose last slot is absent from 
the JSONB; the pre-fix decoder trips `Check failed: dst_column->size() == 
num_rows + 1` on the second row. The regression suite additionally adds a 
column after the loads and reruns the lazy TopN fetch with the hidden column 
named first over the compacted row store. Note that the FE orders the fetch 
slots by HashMap iteration and in practice places the hidden column last, so 
the slot-0 case is pinned by the unit test.



-- 
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]

Reply via email to