matanper commented on issue #69330:
URL: https://github.com/apache/doris/issues/69330#issuecomment-6286437956

   Root cause found; it is not specific to `read_by_rowids`.
   
   `PathInData::operator=` copies the path string and then calls 
`build_parts()`, which returns early when the source has no parts. Assigning an 
empty (root) path onto a longer one therefore keeps the old `parts` and 
`has_nested`: the result is an empty string with stale parts, and the string's 
old buffer still holds the previous path bytes.
   
   `build_materialized_slots` sorts the slots with `std::ranges::sort`. 
`PathInData` has no move operations, so the sort copy-assigns. A slot at the 
requested path itself (a materialized subcolumn whose relative path is empty) 
can be assigned over a deeper slot, which then has `path.size() == 0` with 
`depth == parts.size() > 0`. `ObjectEmitter::open_suffix` splits by `depth`, 
`component_end` is only guarded by a `DCHECK`, and `memchr` scans past the 
buffer to the next `.`.
   
   It needs a hierarchical read whose requested path also exists as a 
materialized subcolumn, plus a sort order that moves that slot onto a deep one; 
late materialization was simply where we hit it.
   
   Fix we're running:
   1. `PathInData::build_parts()` / `build_path()` always clear what they 
rebuild (including `has_nested`) before rebuilding, so assigning an empty path 
leaves no parts.
   2. `ObjectEmitter::component_end()` returns `Status::Corruption` when 
`offset > path.size` instead of relying on a `DCHECK`.
   
   Unit tests: assigning an empty `PathInData` leaves no parts / `has_nested`, 
including when sorted among longer paths; and an assembler test requesting `a` 
with slots `a`, `a.k.p1..p5`, `a.z`, `a.b`, which fails with "Variant path of 0 
bytes has fewer components than its depth" before the fix and returns 
`{"b":2,"k":{"p1":{"p2":{"p3":{"p4":{"p5":7}}}}},"z":3}` after. We can open a 
PR.
   


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