From 4d7d1a54e8a0cde9b725f6b13958e072d2ee7e48 Mon Sep 17 00:00:00 2001 From: Antoine Dupuis <1048669+mnshdw@users.noreply.github.com> Date: Fri, 28 Aug 2026 16:30:47 +0200 Subject: [PATCH] fix(dict): cap max_dict_bytes at the u32 range BinaryView addresses Fixes #9687 Signed-off-by: Antoine Dupuis <1048669+mnshdw@users.noreply.github.com> --- vortex-array/src/builders/dict/bytes.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vortex-array/src/builders/dict/bytes.rs b/vortex-array/src/builders/dict/bytes.rs index 361735536ed..88d45dc2601 100644 --- a/vortex-array/src/builders/dict/bytes.rs +++ b/vortex-array/src/builders/dict/bytes.rs @@ -71,7 +71,7 @@ impl BytesDictBuilder { values_nulls: BitBufferMut::empty(), hasher: DefaultHashBuilder::default(), dtype, - max_dict_bytes: constraints.max_bytes, + max_dict_bytes: constraints.max_bytes.min(u32::MAX as usize), max_dict_len: constraints.max_len, } } @@ -318,6 +318,7 @@ mod test { use vortex_error::VortexResult; use vortex_session::VortexSession; + use super::BytesDictBuilder; use crate::IntoArray; use crate::VortexSessionExecute; use crate::arrays::PrimitiveArray; @@ -430,4 +431,13 @@ mod test { assert_eq!(codes.as_slice::(), &[0, 0, 1, 1, 0, 1, 0, 1]); Ok(()) } + + #[test] + fn max_dict_bytes_cannot_exceed_the_view_offset_range() { + let builder = BytesDictBuilder::::new( + DType::Utf8(Nullability::NonNullable), + &super::super::UNCONSTRAINED, + ); + assert_eq!(builder.max_dict_bytes, u32::MAX as usize); + } }