| 272 | } |
| 273 | |
| 274 | fn contained( |
| 275 | &self, |
| 276 | column: &Column, |
| 277 | values: &HashSet<ScalarValue>, |
| 278 | ) -> Option<BooleanArray> { |
| 279 | let index = self.partition_schema.index_of(column.name()).ok()?; |
| 280 | let array = self.partition_values.get(index)?; |
| 281 | let boolean_array = values.iter().try_fold(None, |acc, v| { |
| 282 | let arrow_value = v.to_scalar().ok()?; |
| 283 | let eq_result = arrow::compute::kernels::cmp::eq(array, &arrow_value).ok()?; |
| 284 | match acc { |
| 285 | None => Some(Some(eq_result)), |
| 286 | Some(acc_array) => { |
| 287 | arrow::compute::kernels::boolean::or_kleene(&acc_array, &eq_result) |
| 288 | .map(Some) |
| 289 | .ok() |
| 290 | } |
| 291 | } |
| 292 | })??; |
| 293 | // If the boolean array is empty or all null values, return None |
| 294 | if boolean_array.is_empty() || boolean_array.null_count() == boolean_array.len() { |
| 295 | None |
| 296 | } else { |
| 297 | Some(boolean_array) |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | /// Prune a set of containers represented by their statistics. |