englefly opened a new pull request, #62631:
URL: https://github.com/apache/doris/pull/62631
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #62205
Problem Summary:
PR #62205 introduced the `length(str)` OFFSET optimization for nested column
pruning. When `length()` is applied to a string-like nested field, the pruner
marks the access path with an OFFSET suffix so BE can read only the offset
array instead of full element data.
However, the OFFSET path dedup logic operates at **slot granularity**: if
ANY non-OFFSET path exists for the same slot, ALL OFFSET paths are stripped.
This is incorrect for `array<struct<...>>` columns where different struct
fields have independent access patterns.
**Bug 1 (crash):** Given a query like:
```sql
SELECT array_match_all(x -> length(struct_element(x, 'str_field')) > 0, arr),
struct_element(element_at(arr, 1), 'int_field')
FROM t
```
The `int_field` non-OFFSET path causes the `str_field` OFFSET path to be
stripped. BE never reads `str_field` data → crash or wrong results.
**Fix:** Replace slot-level OFFSET dedup with per-field bidirectional prefix
matching. An OFFSET path `P+["OFFSET"]` is only stripped when a non-OFFSET path
Q shares a prefix relationship with P (covering the same container or
ancestor), not when Q accesses a sibling struct field.
**Bug 2 (wrong pruning):** When `isStringOffsetOnly=true` AND
`accessPartialChild=true` (e.g., `cardinality(arr) + arr[*].f1`),
`pruneDataType()` returns the full type instead of pruning unused fields.
**Fix:** Add `!accessPartialChild` guard to the `isStringOffsetOnly` check.
### Release note
Fix a BE crash caused by nested column pruning incorrectly stripping OFFSET
access paths for array<struct> columns when different struct fields have
independent access patterns (e.g., length() on one field + direct access on
another).
### Check List (For Author)
- Test: Regression test
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?
Issue Number: close #xxx
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 -->
--
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]