jkosh44 commented on code in PR #14489: URL: https://github.com/apache/datafusion/pull/14489#discussion_r1941739956
########## datafusion/functions-nested/src/extract.rs: ########## @@ -487,7 +487,17 @@ where // 0 ~ len - 1 let adjusted_zero_index = if index < 0 { if let Ok(index) = index.try_into() { - index + len + // When index < 0 and -index > length, index is clamped to the beginning of the list. + // Otherwise, when index < 0, the index is counted from the end of the list. + // + // Note, we actually test the contrapositive, index < -length, because negating a + // negative will panic if the negative is equal to the smallest representable value + // while negating a positive is always safe. + if index < (O::zero() - O::one()) * len { Review Comment: If anyone knows a simpler way of negating `len`, please let me know. -- 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