duongcongtoai commented on PR #10689:
URL: https://github.com/apache/datafusion/pull/10689#issuecomment-2134485468

   > Nice catch ! Thanks @duongcongtoai
   > 
   > Another simple way to reproduce it is
   > 
   > ```sql
   > select unnest(column1) from (select * from (values([1,2,3]), ([4,5,6])) 
limit 1);
   > ```
   > 
   > I'm not sure if this is a bug in arrow-rs or by design. It only 
[slices](https://github.com/apache/arrow-rs/blob/95791f1c317558a57b4570660f204bd9764426aa/arrow-array/src/array/list_array.rs#L327)
 the offset data of the `ListArray`, without slicing the child data.
   
   I think current impl is correct, because the offset values after slicing is 
still offsetted based on original array. Else we have to do shifting for each 
offset elements like
   ```
   Current buffers
               undearneath value: [1,?,3,?,5,6]
               nulls: [1,0,1,0,1,1]
               offset: [0,1,2,4,6]
               logical value: [1] [null] [3,null] [5,6]
   
   Slice(2,2)
               logical values -> [3,null] [5,6]
               offset -> [2,4,6] << 2 = [0,2,4] 
               unearneath_value.slice(2:) = [3,?,5,6]
               nulls.slice(2:) = [1,0,1,1]
   ```
   


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to