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

mrhhsg pushed a commit to branch cherry-pick-nested_column_prune_4.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 2aea8f567dd1f4ddfbcf1ea0b75aa4fd31f666d4
Author: Jerry Hu <[email protected]>
AuthorDate: Fri Nov 28 10:58:35 2025 +0800

    [fix](olap) The tablet schema cache caused incorrect behavior in the 
complex-type column pruning functionality (#58373)
    
    ### What problem does this PR solve?
    
    TabletSchema with pruned column type should not be cached.
    
    Related PR: #xxx
    
    Problem Summary:
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [ ] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 be/src/vec/exec/scan/olap_scanner.cpp | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/be/src/vec/exec/scan/olap_scanner.cpp 
b/be/src/vec/exec/scan/olap_scanner.cpp
index 7112a5a4183..3ecb1063f1c 100644
--- a/be/src/vec/exec/scan/olap_scanner.cpp
+++ b/be/src/vec/exec/scan/olap_scanner.cpp
@@ -168,16 +168,34 @@ Status OlapScanner::prepare() {
     // value (e.g. select a from t where a .. and b ... limit 1),
     // it will be very slow when reading data in segment iterator
     _tablet_reader->set_batch_size(_state->batch_size());
-
     TabletSchemaSPtr cached_schema;
     std::string schema_key;
     {
         TOlapScanNode& olap_scan_node = local_state->olap_scan_node();
-        if (olap_scan_node.__isset.schema_version && 
olap_scan_node.__isset.columns_desc &&
-            !olap_scan_node.columns_desc.empty() &&
-            olap_scan_node.columns_desc[0].col_unique_id >= 0 && // Why check 
first column?
-            tablet->tablet_schema()->num_variant_columns() == 0 &&
-            tablet->tablet_schema()->num_virtual_columns() == 0) {
+
+        const auto check_can_use_cache = [&]() {
+            if (!(olap_scan_node.__isset.schema_version && 
olap_scan_node.__isset.columns_desc &&
+                  !olap_scan_node.columns_desc.empty() &&
+                  olap_scan_node.columns_desc[0].col_unique_id >= 0 && // Why 
check first column?
+                  tablet->tablet_schema()->num_variant_columns() == 0 &&
+                  tablet->tablet_schema()->num_virtual_columns() == 0)) {
+                return false;
+            }
+
+            const bool has_pruned_column =
+                    std::ranges::any_of(_output_tuple_desc->slots(), [](const 
auto& slot) {
+                        if ((slot->type()->get_primitive_type() == 
PrimitiveType::TYPE_STRUCT ||
+                             slot->type()->get_primitive_type() == 
PrimitiveType::TYPE_MAP ||
+                             slot->type()->get_primitive_type() == 
PrimitiveType::TYPE_ARRAY) &&
+                            !slot->all_access_paths().empty()) {
+                            return true;
+                        }
+                        return false;
+                    });
+            return !has_pruned_column;
+        }();
+
+        if (check_can_use_cache) {
             schema_key =
                     SchemaCache::get_schema_key(tablet->tablet_id(), 
olap_scan_node.columns_desc,
                                                 olap_scan_node.schema_version);


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

Reply via email to