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

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


The following commit(s) were added to refs/heads/branch-4.2 by this push:
     new 6d345fbd281 branch-4.2: [fix](be) Preserve rows in partial row-store 
point queries #71292 (#71366)
6d345fbd281 is described below

commit 6d345fbd2811ce0e691d9c4e5ca10e58bed1863a
Author: Jerry Hu <[email protected]>
AuthorDate: Fri Dec 4 09:52:38 2026 +0800

    branch-4.2: [fix](be) Preserve rows in partial row-store point queries 
#71292 (#71366)
    
    ### What problem does this PR solve?
    
    Issue Number: None
    
    Related PR: #71292
    
    Cherry-picked from #71292.
    
    Short-circuit point queries over partial row storage can lose existing
    rows when a scan slot, such as a non-projected key, is read by neither
    row storage nor column storage. Comparing the number of scan slots with
    the number of row-store columns does not reliably identify these slots,
    and padding only after all keys are read leaves column lengths
    inconsistent during multi-key JSONB decoding.
    
    Partial row-cache payloads also lack the row location required to read
    columns absent from row storage.
    
    This backport:
    - Precomputes the scan slots read by neither storage path and appends
    one default per successfully read row, keeping all columns aligned
    before the next key is decoded.
    - Bypasses both row-cache lookup and insertion for partial row storage,
    including previously cached incomplete payloads.
    - Preserves full-row caching and actual storage reads for output columns
    and the delete sign.
    - Adapts the BE test fixture to branch-4.2's existing Reusable, rowset
    and segment-loader APIs, covering Tablet and CloudTablet with this
    branch's contiguous segment layout. It does not import master's
    segment-retention or segment-list changes.
    
    ### Release note
    
    Fix missing rows in short-circuit point queries over partial row
    storage.
    
    ### Check List (For Author)
    
    - Test:
    - [x] Unit Test: 20 targeted ASAN BE tests passed, with no failures or
    skipped tests.
    - [x] Regression test: six native SQL suites passed, with no failed,
    fatal or skipped scripts.
    - Behavior changed:
    - [x] Yes. Preserve rows and column alignment for partial row-store
    point queries; partial row-store requests no longer use the row cache.
    - Does this need documentation?
      - [x] No.
    
    ### Validation
    
    - `./build.sh --be --fe -j 48`: passed, including FE Checkstyle with
    zero violations.
    - `./run-be-ut.sh --run --filter
    
'*PointQuerySegmentReuseTest*:*PointQueryReusableTest*:*RowCacheTest*:*LookupConnectionCacheTest*'
    -j 48`: 20 ASAN tests passed.
    - SQL regression suites:
    `test_short_circuit_partial_rowstore_projection`,
    `test_rowstore.groovy`, `test_rowstore_query.groovy`,
    `test_short_circuit_rowset_hidden_columns`,
    `test_rowstore_nested_pruning_minimal` and
    `test_point_query_light_schema_change`: all six passed.
    - `bash build-support/check-format.sh`, clang-format checks for all
    changed C++ files and `git diff --check`: passed.
    
    Native SQL validation used `enable_java_support=false`; Java UDF/JDBC, a
    live cloud deployment, multi-BE and mixed-version deployments were not
    tested. The CloudTablet unit-test parameter is not a live cloud
    validation. No performance benchmark was run.
---
 be/src/service/point_query_executor.cpp            |  37 +-
 be/src/service/point_query_executor.h              |  10 +
 be/test/service/point_query_exector_test.cpp       | 380 +++++++++++++++++++++
 ...t_short_circuit_partial_rowstore_projection.out |  18 +
 ...hort_circuit_partial_rowstore_projection.groovy |  57 ++++
 5 files changed, 487 insertions(+), 15 deletions(-)

diff --git a/be/src/service/point_query_executor.cpp 
b/be/src/service/point_query_executor.cpp
index 48eb7a9f434..c8550c45156 100644
--- a/be/src/service/point_query_executor.cpp
+++ b/be/src/service/point_query_executor.cpp
@@ -191,6 +191,17 @@ Status Reusable::init(const TDescriptorTable& t_desc_tbl, 
const std::vector<TExp
     }
     get_missing_and_include_cids(schema, output_slot_descs, 
_row_store_column_ids,
                                  _missing_col_uids, _include_col_uids);
+    // An empty include set means JSONB decodes every slot only for full-row 
storage.
+    // Otherwise, e.g. tuple [k, v, delete_sign] with row-store columns [v, z, 
w], k is
+    // read by neither storage path even though the two collections have the 
same size.
+    if (!has_full_row_store()) {
+        for (size_t i = 0; i < tuple_desc()->slots().size(); ++i) {
+            int uid = tuple_desc()->slots()[i]->col_unique_id();
+            if (!_include_col_uids.contains(uid) && 
!_missing_col_uids.contains(uid)) {
+                _unmaterialized_slot_indices.push_back(i);
+            }
+        }
+    }
 
     return Status::OK();
 }
@@ -503,9 +514,12 @@ Status PointQueryExecutor::_lookup_row_key() {
     io_ctx.file_cache_stats = &_profile_metrics.read_stats.file_cache_stats;
     io_ctx.remote_scan_cache_write_limiter = 
_remote_scan_cache_write_limiter.get();
     std::vector<std::unique_ptr<SegmentCacheHandle>> 
segment_caches(specified_rowsets.size());
+    // A cached partial row (e.g. only v) has no row location for reading k or 
the delete sign.
+    const bool use_row_cache =
+            !config::disable_storage_row_cache && 
_reusable->has_full_row_store();
     for (size_t i = 0; i < _row_read_ctxs.size(); ++i) {
         RowLocation location;
-        if (!config::disable_storage_row_cache) {
+        if (use_row_cache) {
             RowCache::CacheHandle cache_handle;
             auto hit_cache = RowCache::instance()->lookup(
                     {_tablet->tablet_id(), _row_read_ctxs[i]._primary_key}, 
&cache_handle);
@@ -558,7 +572,9 @@ Status PointQueryExecutor::_lookup_row_data() {
             std::string value;
             // fill block by row store
             if (_reusable->rs_column_uid() != -1) {
-                bool use_row_cache = !config::disable_storage_row_cache;
+                // Match the lookup guard: partial payloads cannot satisfy 
column-store reads.
+                const bool use_row_cache =
+                        !config::disable_storage_row_cache && 
_reusable->has_full_row_store();
                 io::IOContext io_ctx;
                 io_ctx.reader_type = ReaderType::READER_QUERY;
                 io_ctx.file_cache_stats = 
&_profile_metrics.read_stats.file_cache_stats;
@@ -637,19 +653,10 @@ Status PointQueryExecutor::_lookup_row_data() {
                             *read_schema, slot, row_ids, column, 
storage_read_options, iter));
                 }
             }
-        }
-        if (result_columns.size() > _reusable->include_col_uids().size()) {
-            // Padding rows for some columns that no need to output to mysql 
client
-            // eg. SELECT k1,v1,v2 FROM TABLE WHERE k1 = 1, k1 is not in 
output slots, tuple as bellow
-            // TupleDescriptor{id=1, tbl=table_with_column_group}
-            // SlotDescriptor{id=8, col=v1, colUniqueId=1 ...}
-            // SlotDescriptor{id=9, col=v2, colUniqueId=2 ...}
-            // thus missing in include_col_uids and missing_col_uids
-            for (auto& column : result_columns) {
-                int padding_rows = _row_hits - cast_set<int>(column->size());
-                if (padding_rows > 0) {
-                    column->insert_many_defaults(padding_rows);
-                }
+            // Keep every tuple slot aligned before the next key: JSONB 
decoding uses the
+            // first column's size as the number of rows already materialized.
+            for (size_t pos : _reusable->unmaterialized_slot_indices()) {
+                result_columns[pos]->insert_default();
             }
         }
     }
diff --git a/be/src/service/point_query_executor.h 
b/be/src/service/point_query_executor.h
index d990ffd3bb0..996c4cdcdfa 100644
--- a/be/src/service/point_query_executor.h
+++ b/be/src/service/point_query_executor.h
@@ -98,6 +98,14 @@ public:
 
     const std::unordered_set<int32_t> include_col_uids() const { return 
_include_col_uids; }
 
+    bool has_full_row_store() const {
+        return _row_store_column_ids != -1 && _include_col_uids.empty();
+    }
+
+    const std::vector<size_t>& unmaterialized_slot_indices() const {
+        return _unmaterialized_slot_indices;
+    }
+
     RuntimeState* runtime_state() { return _runtime_state.get(); }
 
     // delete sign idx in block
@@ -121,6 +129,8 @@ private:
     std::unordered_set<int32_t> _missing_col_uids;
     // included cids in rowstore(column group)
     std::unordered_set<int32_t> _include_col_uids;
+    // Scan tuple slots read by neither row storage nor column storage.
+    std::vector<size_t> _unmaterialized_slot_indices;
     // delete sign idx in block
     int32_t _delete_sign_idx = -1;
 };
diff --git a/be/test/service/point_query_exector_test.cpp 
b/be/test/service/point_query_exector_test.cpp
index d67961db388..ee9d4f7be99 100644
--- a/be/test/service/point_query_exector_test.cpp
+++ b/be/test/service/point_query_exector_test.cpp
@@ -22,26 +22,48 @@
 #include <gen_cpp/internal_service.pb.h>
 #include <gtest/gtest.h>
 
+#include <cstdint>
+#include <memory>
+#include <mutex>
 #include <string>
+#include <unordered_set>
 #include <utility>
 #include <vector>
 
+#include "cloud/cloud_storage_engine.h"
+#include "cloud/cloud_tablet.h"
+#include "common/config.h"
 #include "common/object_pool.h"
+#include "core/assert_cast.h"
 #include "core/block/block.h"
 #include "core/block/column_with_type_and_name.h"
+#include "core/column/column_nullable.h"
 #include "core/column/column_string.h"
+#include "core/column/column_vector.h"
 #include "core/data_type/data_type_string.h"
 #include "core/data_type/data_type_struct.h"
 #include "core/data_type_serde/data_type_serde.h"
+#include "core/field.h"
 #include "exprs/vexpr.h"
+#include "io/fs/local_file_system.h"
 #include "runtime/descriptor_helper.h"
 #include "runtime/descriptors.h"
 #include "runtime/exec_env.h"
+#include "runtime/memory/cache_manager.h"
 #include "runtime/runtime_state.h"
 #include "service/point_query_executor.h"
+#include "storage/options.h"
+#include "storage/rowset/beta_rowset_writer.h"
+#include "storage/rowset/rowset.h"
+#include "storage/rowset/rowset_writer_context.h"
+#include "storage/segment/segment_loader.h"
+#include "storage/storage_engine.h"
+#include "storage/tablet/tablet.h"
+#include "storage/tablet/tablet_meta.h"
 #include "storage/tablet/tablet_schema.h"
 #include "storage/utils.h"
 #include "util/jsonb/serialize.h"
+#include "util/thrift_util.h"
 
 namespace doris {
 
@@ -574,4 +596,362 @@ TEST_F(LookupConnectionCacheTest, PQTestEntryLifetime) {
     EXPECT_EQ(entry.use_count(), 2) << "Cache should maintain sole ownership 
after scope exit";
 }
 
+// Exercise the executor's key/data stages with real MoW segments. The 
parameters cover
+// local tablets and cloud tablets using the branch's contiguous segment IDs.
+class PointQuerySegmentReuseTest : public testing::TestWithParam<bool> {
+protected:
+    void SetUp() override {
+        _saved_disable_row_cache = config::disable_storage_row_cache;
+        _saved_disable_segment_cache = config::disable_segment_cache;
+        config::disable_storage_row_cache = true;
+        config::disable_segment_cache = false;
+        auto* env = ExecEnv::GetInstance();
+        _saved_cache_manager = env->get_cache_manager();
+        _cache_manager.reset(CacheManager::create_global_instance());
+        env->set_cache_manager(_cache_manager.get());
+        _saved_row_cache = env->get_row_cache();
+        _saved_segment_loader = env->segment_loader();
+        _row_cache.reset(new RowCache(1024 * 1024, 1));
+        _segment_loader = std::make_unique<SegmentLoader>(64 * 1024 * 1024, 
1024);
+        env->_row_cache = _row_cache.get();
+        env->set_segment_loader(_segment_loader.get());
+        EngineOptions options;
+        options.backend_uid = UniqueId::gen_uid();
+        _engine = std::make_unique<StorageEngine>(options);
+        
ASSERT_TRUE(io::global_local_filesystem()->delete_directory(kTestDir).ok());
+        
ASSERT_TRUE(io::global_local_filesystem()->create_directory(kTestDir).ok());
+    }
+
+    void TearDown() override {
+        evict_segments();
+        _tablet.reset();
+        _rowsets.clear();
+        _cloud_engine.reset();
+        _engine.reset();
+        auto* env = ExecEnv::GetInstance();
+        env->_row_cache = _saved_row_cache;
+        env->set_segment_loader(_saved_segment_loader);
+        _row_cache.reset();
+        _segment_loader.reset();
+        env->set_cache_manager(_saved_cache_manager);
+        _cache_manager.reset();
+        config::disable_storage_row_cache = _saved_disable_row_cache;
+        config::disable_segment_cache = _saved_disable_segment_cache;
+        
EXPECT_TRUE(io::global_local_filesystem()->delete_directory(kTestDir).ok());
+    }
+
+    Status create_tablet(bool partial_row_store = false) {
+        TabletMetaPB meta_pb;
+        meta_pb.set_tablet_id(987654);
+        meta_pb.set_enable_unique_key_merge_on_write(true);
+        meta_pb.set_tablet_state(PB_RUNNING);
+        auto* schema_pb = meta_pb.mutable_schema();
+        schema_pb->set_keys_type(UNIQUE_KEYS);
+        schema_pb->set_num_short_key_columns(1);
+        schema_pb->set_num_rows_per_row_block(1024);
+        schema_pb->set_next_column_unique_id(6);
+        schema_pb->set_delete_sign_idx(4);
+        schema_pb->set_store_row_column(true);
+        if (partial_row_store) {
+            for (int uid : {1, 2, 3}) {
+                schema_pb->add_row_store_column_unique_ids(uid);
+            }
+        }
+        auto add_column = [&](int uid, const std::string& name, const 
std::string& type, int length,
+                              bool nullable) {
+            auto* column = schema_pb->add_column();
+            column->set_unique_id(uid);
+            column->set_name(name);
+            column->set_type(type);
+            column->set_length(length);
+            column->set_index_length(type == "STRING" ? 4 : length);
+            column->set_is_key(uid == 0);
+            column->set_is_nullable(nullable);
+            column->set_aggregation("NONE");
+        };
+        add_column(0, "k", "INT", 4, false);
+        add_column(1, "v1", "INT", 4, false);
+        add_column(2, "v2", "INT", 4, true);
+        add_column(3, "v3", "INT", 4, false);
+        add_column(4, DELETE_SIGN, "TINYINT", 1, false);
+        add_column(5, BeConsts::ROW_STORE_COL, "STRING", 2147483643, false);
+        auto meta = std::make_shared<TabletMeta>();
+        meta->init_from_pb(meta_pb);
+        if (GetParam()) {
+            _cloud_engine = std::make_unique<CloudStorageEngine>(EngineOptions 
{});
+            _tablet = std::make_shared<CloudTablet>(*_cloud_engine, meta);
+        } else {
+            _tablet = std::make_shared<Tablet>(*_engine, meta, nullptr);
+        }
+        RETURN_IF_ERROR(write_rowset(1, {{10, 11}, {20}, {30}}));
+        RETURN_IF_ERROR(write_rowset(2, {{40}}));
+        // Key 20 still has a primary-index entry but is invisible through the 
delete bitmap.
+        const auto& rowset = _rowsets.front();
+        meta->delete_bitmap().add({rowset->rowset_id(), 1, 1}, 0);
+        return Status::OK();
+    }
+
+    Status write_rowset(int64_t version, const 
std::vector<std::vector<int32_t>>& keys,
+                        int8_t delete_sign = 0) {
+        RowsetWriterContext context;
+        context.rowset_id = _engine->next_rowset_id();
+        context.tablet_id = _tablet->tablet_id();
+        context.tablet_schema = _tablet->tablet_schema();
+        context.tablet_path = kTestDir;
+        context.rowset_state = VISIBLE;
+        context.version = {version, version};
+        context.enable_unique_key_merge_on_write = true;
+        context.enable_segcompaction = false;
+        context.write_type = DataWriteType::TYPE_DIRECT;
+        BetaRowsetWriter writer(*_engine);
+        RETURN_IF_ERROR(writer.init(context));
+        for (const auto& segment_keys : keys) {
+            Block block = context.tablet_schema->create_block();
+            {
+                auto guard = block.mutate_columns_scoped();
+                auto& columns = guard.mutable_columns();
+                for (int32_t key : segment_keys) {
+                    columns[0]->insert(Field::create_field<TYPE_INT>(key));
+                    columns[1]->insert(Field::create_field<TYPE_INT>(key * 
10));
+                    if (key == 11) {
+                        columns[2]->insert_default();
+                    } else {
+                        columns[2]->insert(Field::create_field<TYPE_INT>(key * 
100));
+                    }
+                    columns[3]->insert(Field::create_field<TYPE_INT>(key * 
1000));
+                    
columns[4]->insert(Field::create_field<TYPE_TINYINT>(delete_sign));
+                    columns[5]->insert_default();
+                }
+            }
+            RETURN_IF_ERROR(writer.flush_single_block(&block));
+        }
+        RowsetSharedPtr rowset;
+        RETURN_IF_ERROR(writer.build(rowset));
+        {
+            std::unique_lock lock(_tablet->get_header_lock());
+            _tablet->_rs_version_map.emplace(rowset->version(), rowset);
+        }
+        _rowsets.push_back(std::move(rowset));
+        return Status::OK();
+    }
+
+    Status prepare_executor(PointQueryExecutor* executor, const 
std::vector<int32_t>& keys,
+                            const std::vector<int>& scan_positions = {0, 1, 2, 
4},
+                            const std::vector<int>& output_positions = {0, 1, 
2}) {
+        TDescriptorTableBuilder descriptor_builder;
+        TTupleDescriptorBuilder tuple_builder;
+        for (int pos : scan_positions) {
+            const auto& column = _tablet->tablet_schema()->column(pos);
+            auto slot = TSlotDescriptorBuilder()
+                                .type(pos == 4 ? TYPE_TINYINT : TYPE_INT)
+                                .column_name(column.name())
+                                .column_pos(pos)
+                                .nullable(column.is_nullable())
+                                .build();
+            slot.__set_col_unique_id(column.unique_id());
+            tuple_builder.add_slot(slot);
+        }
+        tuple_builder.build(&descriptor_builder);
+        auto descriptor = descriptor_builder.desc_tbl();
+        std::vector<TExpr> output_exprs;
+        for (int pos : output_positions) {
+            TExprNode node;
+            node.__set_node_type(TExprNodeType::SLOT_REF);
+            node.__set_type(descriptor.slotDescriptors[pos].slotType);
+            node.__set_is_nullable(
+                    
_tablet->tablet_schema()->column(scan_positions[pos]).is_nullable());
+            node.__set_num_children(0);
+            TSlotRef slot_ref;
+            slot_ref.__set_slot_id(descriptor.slotDescriptors[pos].id);
+            slot_ref.__set_tuple_id(0);
+            node.__set_slot_ref(slot_ref);
+            TExpr expr;
+            expr.nodes.push_back(node);
+            output_exprs.push_back(expr);
+        }
+        TQueryOptions options;
+        options.__set_enable_short_circuit_query_access_column_store(
+                !_tablet->tablet_schema()->row_columns_uids().empty());
+        executor->_tablet = _tablet;
+        executor->_reusable = std::make_shared<Reusable>();
+        RETURN_IF_ERROR(executor->_reusable->init(descriptor, output_exprs, 
options,
+                                                  *_tablet->tablet_schema(), 
1));
+        PTabletKeyLookupRequest request;
+        ThriftSerializer serializer(false, 128);
+        for (int32_t key : keys) {
+            TExprNode literal;
+            literal.__set_node_type(TExprNodeType::INT_LITERAL);
+            literal.__set_type(descriptor.slotDescriptors[0].slotType);
+            literal.__set_is_nullable(false);
+            literal.__set_num_children(0);
+            TIntLiteral int_literal;
+            int_literal.__set_value(key);
+            literal.__set_int_literal(int_literal);
+            RETURN_IF_ERROR(serializer.serialize(
+                    &literal, 
request.add_key_tuples()->add_key_column_literals()));
+        }
+        RETURN_IF_ERROR(executor->_init_keys(&request));
+        executor->_result_block = executor->_reusable->get_block();
+        return Status::OK();
+    }
+
+    void evict_segments() {
+        for (const auto& rowset : _rowsets) {
+            SegmentLoader::instance()->erase_segments(rowset->rowset_id(), 
rowset->num_segments());
+        }
+    }
+
+    static constexpr const char* kTestDir = "./point_query_segment_reuse_test";
+    std::unique_ptr<StorageEngine> _engine;
+    std::unique_ptr<CloudStorageEngine> _cloud_engine;
+    BaseTabletSPtr _tablet;
+    std::vector<RowsetSharedPtr> _rowsets;
+    std::unique_ptr<RowCache> _row_cache;
+    std::unique_ptr<SegmentLoader> _segment_loader;
+    std::unique_ptr<CacheManager> _cache_manager;
+    CacheManager* _saved_cache_manager = nullptr;
+    RowCache* _saved_row_cache = nullptr;
+    SegmentLoader* _saved_segment_loader = nullptr;
+    bool _saved_disable_row_cache = true;
+    bool _saved_disable_segment_cache = false;
+};
+
+// NOLINTNEXTLINE(readability-function-cognitive-complexity): compare cold and 
cached execution using the same request and expected result.
+TEST_P(PointQuerySegmentReuseTest, LookupUpAndRowCacheHit) {
+    ASSERT_EQ(Status::OK(), create_tablet());
+    config::disable_storage_row_cache = false;
+    // MySQL text rows: length-prefixed cells, with 0xfb for SQL NULL.
+    const std::vector<std::string> expected_rows {"\00230\003300\0043000", 
"\00210\003100\0041000",
+                                                  "\00240\003400\0044000", 
"\00211\003110\373"};
+    for (bool cached : {false, true}) {
+        PointQueryExecutor executor;
+        PTabletKeyLookupResponse response;
+        // Only existing keys: the warm request must not need an index lookup 
for a missing key.
+        ASSERT_EQ(Status::OK(), prepare_executor(&executor, {30, 10, 40, 11}));
+        executor._response = &response;
+        ASSERT_EQ(Status::OK(), executor.lookup_up());
+        EXPECT_FALSE(response.empty_batch());
+        TResultBatch batch;
+        auto length = static_cast<uint32_t>(response.row_batch().size());
+        ASSERT_TRUE(deserialize_thrift_msg(
+                            reinterpret_cast<const 
uint8_t*>(response.row_batch().data()), &length,
+                            false, &batch)
+                            .ok());
+        EXPECT_EQ(batch.rows, expected_rows);
+        EXPECT_EQ(executor._profile_metrics.row_cache_hits, cached ? 4 : 0);
+        if (cached) {
+            for (const auto& context : executor._row_read_ctxs) {
+                EXPECT_EQ(context._rowset_ptr, nullptr);
+            }
+        }
+        evict_segments();
+    }
+}
+
+TEST_P(PointQuerySegmentReuseTest, 
PartialRowStoreProjectionKeepsBlockRowsAligned) {
+    ASSERT_EQ(Status::OK(), create_tablet(true));
+    {
+        PointQueryExecutor executor;
+        ASSERT_EQ(Status::OK(), prepare_executor(&executor, {10}, {0, 1, 4}, 
{1}));
+        ASSERT_EQ(Status::OK(), executor._lookup_row_key());
+        ASSERT_EQ(executor._row_hits, 1);
+        EXPECT_EQ(executor._reusable->include_col_uids().size(), 3);
+        EXPECT_EQ(executor._reusable->missing_col_uids(), 
(std::unordered_set<int32_t> {4}));
+        ASSERT_EQ(Status::OK(), executor._lookup_row_data());
+        const auto& block = *executor._result_block;
+        for (const auto& column : block.get_columns()) {
+            ASSERT_EQ(column->size(), 1);
+        }
+        EXPECT_EQ(block.rows(), 1);
+        EXPECT_EQ(block.get_by_position(1).column->get_int(0), 100);
+        EXPECT_EQ(block.get_by_position(2).column->get_int(0), 0);
+    }
+    {
+        PointQueryExecutor executor;
+        ASSERT_EQ(Status::OK(), prepare_executor(&executor, {30, 99, 10, 20, 
11}, {0, 2, 4}, {1}));
+        ASSERT_EQ(Status::OK(), executor._lookup_row_key());
+        ASSERT_EQ(executor._row_hits, 3);
+        ASSERT_EQ(Status::OK(), executor._lookup_row_data());
+        const auto& block = *executor._result_block;
+        for (const auto& column : block.get_columns()) {
+            ASSERT_EQ(column->size(), 3);
+        }
+        EXPECT_EQ(block.rows(), 3);
+        const auto& values = assert_cast<const 
ColumnNullable&>(*block.get_by_position(1).column);
+        EXPECT_EQ(values.get_nested_column().get_int(0), 3000);
+        EXPECT_EQ(values.get_nested_column().get_int(1), 1000);
+        EXPECT_FALSE(values.is_null_at(0));
+        EXPECT_FALSE(values.is_null_at(1));
+        EXPECT_TRUE(values.is_null_at(2));
+        for (size_t row = 0; row < 3; ++row) {
+            EXPECT_EQ(block.get_by_position(2).column->get_int(row), 0);
+        }
+    }
+    {
+        PointQueryExecutor executor;
+        ASSERT_EQ(Status::OK(), prepare_executor(&executor, {99, 20}, {0, 1, 
4}, {1}));
+        ASSERT_EQ(Status::OK(), executor._lookup_row_key());
+        EXPECT_EQ(executor._row_hits, 0);
+        ASSERT_EQ(Status::OK(), executor._lookup_row_data());
+        for (const auto& column : executor._result_block->get_columns()) {
+            EXPECT_EQ(column->size(), 0);
+        }
+    }
+}
+
+TEST_P(PointQuerySegmentReuseTest, PartialRowStoreBypassesIncompleteRowCache) {
+    ASSERT_EQ(Status::OK(), create_tablet(true));
+    config::disable_storage_row_cache = false;
+    for (bool preloaded : {false, true}) {
+        PointQueryExecutor executor;
+        ASSERT_EQ(Status::OK(), prepare_executor(&executor, {10}, {0, 1, 4}, 
{0, 1}));
+        ASSERT_EQ(Status::OK(), executor._lookup_row_key());
+        EXPECT_EQ(executor._row_hits, 1);
+        EXPECT_EQ(executor._profile_metrics.row_cache_hits, 0);
+        const auto& context = executor._row_read_ctxs.front();
+        ASSERT_TRUE(context._row_location.has_value());
+        ASSERT_EQ(Status::OK(), executor._lookup_row_data());
+        const auto& block = *executor._result_block;
+        for (const auto& column : block.get_columns()) {
+            ASSERT_EQ(column->size(), 1);
+        }
+        EXPECT_EQ(block.get_by_position(0).column->get_int(0), 10);
+        EXPECT_EQ(block.get_by_position(1).column->get_int(0), 100);
+        EXPECT_EQ(block.get_by_position(2).column->get_int(0), 0);
+        RowCache::CacheHandle handle;
+        EXPECT_EQ(_row_cache->lookup({_tablet->tablet_id(), 
context._primary_key}, &handle),
+                  preloaded);
+        if (!preloaded) {
+            // Seed a real partial payload, as a BE without the fix could have 
cached it.
+            std::string value;
+            io::IOContext io_ctx;
+            io_ctx.reader_type = ReaderType::READER_QUERY;
+            ASSERT_EQ(Status::OK(),
+                      _tablet->lookup_row_data(context._primary_key, 
context._row_location.value(),
+                                               *context._rowset_ptr,
+                                               
executor._profile_metrics.read_stats, value, true,
+                                               &io_ctx));
+            RowCache::CacheHandle seeded_handle;
+            ASSERT_TRUE(_row_cache->lookup({_tablet->tablet_id(), 
context._primary_key},
+                                           &seeded_handle));
+        }
+    }
+}
+
+TEST_P(PointQuerySegmentReuseTest, PartialRowStoreFiltersDeleteSign) {
+    ASSERT_EQ(Status::OK(), create_tablet(true));
+    // No delete bitmap for key 50: its stored delete sign must still filter 
the row.
+    ASSERT_EQ(Status::OK(), write_rowset(3, {{50}}, 1));
+    PointQueryExecutor executor;
+    ASSERT_EQ(Status::OK(), prepare_executor(&executor, {50}, {0, 1, 4}, {1}));
+    ASSERT_EQ(Status::OK(), executor._lookup_row_key());
+    EXPECT_EQ(executor._row_hits, 1);
+    ASSERT_EQ(Status::OK(), executor._lookup_row_data());
+    for (const auto& column : executor._result_block->get_columns()) {
+        EXPECT_EQ(column->size(), 0);
+    }
+}
+
+INSTANTIATE_TEST_SUITE_P(TabletTypes, PointQuerySegmentReuseTest, 
testing::Bool());
+
 } // namespace doris
diff --git 
a/regression-test/data/point_query_p0/test_short_circuit_partial_rowstore_projection.out
 
b/regression-test/data/point_query_p0/test_short_circuit_partial_rowstore_projection.out
new file mode 100644
index 00000000000..1ac587a0885
--- /dev/null
+++ 
b/regression-test/data/point_query_p0/test_short_circuit_partial_rowstore_projection.out
@@ -0,0 +1,18 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !scan_v --
+seven
+
+-- !scan_v_v --
+seven  seven
+
+-- !scan_k_v --
+7      seven
+
+-- !point_v --
+seven
+
+-- !point_v_v --
+seven  seven
+
+-- !point_k_v --
+7      seven
diff --git 
a/regression-test/suites/point_query_p0/test_short_circuit_partial_rowstore_projection.groovy
 
b/regression-test/suites/point_query_p0/test_short_circuit_partial_rowstore_projection.groovy
new file mode 100644
index 00000000000..5f0159b97b6
--- /dev/null
+++ 
b/regression-test/suites/point_query_p0/test_short_circuit_partial_rowstore_projection.groovy
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_short_circuit_partial_rowstore_projection", "p0") {
+    sql "DROP TABLE IF EXISTS short_circuit_partial_rowstore_projection"
+    sql """
+        CREATE TABLE short_circuit_partial_rowstore_projection (
+            k INT NOT NULL,
+            v VARCHAR(20),
+            w INT,
+            z VARCHAR(20)
+        )
+        UNIQUE KEY(k)
+        DISTRIBUTED BY HASH(k) BUCKETS 1
+        PROPERTIES (
+            "enable_unique_key_merge_on_write" = "true",
+            "light_schema_change" = "true",
+            "row_store_columns" = "v,z,w",
+            "replication_num" = "1"
+        )
+    """
+    sql "INSERT INTO short_circuit_partial_rowstore_projection VALUES (7, 
'seven', 70, 't')"
+    sql "SET enable_sql_cache = false"
+    sql "SET enable_short_circuit_query_access_column_store = true"
+
+    sql "SET enable_short_circuit_query = false"
+    explain {
+        sql "SELECT v FROM short_circuit_partial_rowstore_projection WHERE k = 
7"
+        notContains "SHORT-CIRCUIT"
+    }
+    order_qt_scan_v "SELECT v FROM short_circuit_partial_rowstore_projection 
WHERE k = 7"
+    order_qt_scan_v_v "SELECT v, v FROM 
short_circuit_partial_rowstore_projection WHERE k = 7"
+    order_qt_scan_k_v "SELECT k, v FROM 
short_circuit_partial_rowstore_projection WHERE k = 7"
+
+    sql "SET enable_short_circuit_query = true"
+    explain {
+        sql "SELECT v FROM short_circuit_partial_rowstore_projection WHERE k = 
7"
+        contains "SHORT-CIRCUIT"
+    }
+    order_qt_point_v "SELECT v FROM short_circuit_partial_rowstore_projection 
WHERE k = 7"
+    order_qt_point_v_v "SELECT v, v FROM 
short_circuit_partial_rowstore_projection WHERE k = 7"
+    order_qt_point_k_v "SELECT k, v FROM 
short_circuit_partial_rowstore_projection WHERE k = 7"
+}


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

Reply via email to