@@ -122,26 +122,28 @@ impl StringHashTable {
122122 }
123123 }
124124
125- /// Extracts the string value at the given row index, handling nulls and different string types
125+ /// Extracts the string value at the given row index, handling nulls and different string types.
126+ ///
127+ /// Returns `None` if the value is null, otherwise `Some(value.to_string())`.
126128 fn extract_string_value ( & self , row_idx : usize ) -> Option < String > {
127- // Helper to extract value if not null - avoids duplicating the null check logic
128- let extract = |is_null : bool , value : & str | ( !is_null) . then ( || value. to_string ( ) ) ;
129-
130- match self . data_type {
129+ let is_null_and_value = match self . data_type {
131130 DataType :: Utf8 => {
132131 let arr = self . owned . as_string :: < i32 > ( ) ;
133- extract ( arr. is_null ( row_idx) , arr. value ( row_idx) )
132+ ( arr. is_null ( row_idx) , arr. value ( row_idx) )
134133 }
135134 DataType :: LargeUtf8 => {
136135 let arr = self . owned . as_string :: < i64 > ( ) ;
137- extract ( arr. is_null ( row_idx) , arr. value ( row_idx) )
136+ ( arr. is_null ( row_idx) , arr. value ( row_idx) )
138137 }
139138 DataType :: Utf8View => {
140139 let arr = self . owned . as_string_view ( ) ;
141- extract ( arr. is_null ( row_idx) , arr. value ( row_idx) )
140+ ( arr. is_null ( row_idx) , arr. value ( row_idx) )
142141 }
143142 _ => panic ! ( "Unsupported data type" ) ,
144- }
143+ } ;
144+
145+ // Extract value only if not null
146+ ( !is_null_and_value. 0 ) . then ( || is_null_and_value. 1 . to_string ( ) )
145147 }
146148}
147149
0 commit comments