You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by li...@apache.org on 2026/04/14 01:55:36 UTC
(doris) branch master updated: [fix](fe) Fix struct field slot type in NestedColumnPruning for OFFSET-only access (#62446)
This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 39460636d80 [fix](fe) Fix struct field slot type in NestedColumnPruning for OFFSET-only access (#62446)
39460636d80 is described below
commit 39460636d80b11d884b4e30c7ee75835934c01d4
Author: HappenLee <ha...@selectdb.com>
AuthorDate: Tue Apr 14 09:55:29 2026 +0800
[fix](fe) Fix struct field slot type in NestedColumnPruning for OFFSET-only access (#62446)
Problem Summary: When using struct_element() to access a string field
inside a struct (e.g., length(struct_element(struct_col, 'f3'))), the
NestedColumnPruning rule incorrectly returned Optional.empty() for the
slot type, causing the slot type to become nullable and lose its
original type information.
The fix changes the return value from Optional.empty() to
Optional.of(type) when the column is accessed in OFFSET-only mode (e.g.,
length()), ensuring the slot type remains the original type (e.g.,
varchar).
Release note: None
Test: Added test case in string_length_column_pruning.groovy
---
.../org/apache/doris/nereids/rules/rewrite/NestedColumnPruning.java | 3 +--
.../column_pruning/string_length_column_pruning.groovy | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NestedColumnPruning.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NestedColumnPruning.java
index e096d8c2f85..3c368f0f4b3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NestedColumnPruning.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NestedColumnPruning.java
@@ -666,8 +666,7 @@ public class NestedColumnPruning implements CustomRewriter {
return Optional.of(type);
} else if (isStringOffsetOnly) {
// Only the offset array is accessed (e.g. length(str_col)).
- // The slot type stays unchanged (varchar); the access path tells BE to skip char data.
- return Optional.empty();
+ return Optional.of(type);
} else if (!accessPartialChild) {
return Optional.empty();
}
diff --git a/regression-test/suites/nereids_rules_p0/column_pruning/string_length_column_pruning.groovy b/regression-test/suites/nereids_rules_p0/column_pruning/string_length_column_pruning.groovy
index ba089f735a1..1159055c431 100644
--- a/regression-test/suites/nereids_rules_p0/column_pruning/string_length_column_pruning.groovy
+++ b/regression-test/suites/nereids_rules_p0/column_pruning/string_length_column_pruning.groovy
@@ -69,7 +69,7 @@ suite("string_length_column_pruning") {
contains "OFFSET"
notContains "type=bigint"
}
- //sql "select length(struct_element(struct_col, 'f3')) from slcp_str_tbl"
+ sql "select length(struct_element(struct_col, 'f3')) from slcp_str_tbl"
// length() in both SELECT and WHERE: predicate must remain length(str_col) > 1,
// never be rewritten to CAST(str_col AS int) > 1. Slot type must stay varchar.
explain {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org