Repository: pola-rs/polars
File: crates/polars-plan/src/plans/optimizer/expand_datasets.rs (Rust)

Code before:
                                if unified_scan_args
                                    .row_index
                                    .as_ref()
                                    .is_some_and(|ri| live_col == &ri.name)
                                {
                                    row_index_in_live_filter = true;
                                    false
                                } else {
                                    true
                                }
                            })
                            .cloned()
                            .collect();

                    Arc::get_mut(&mut out).unwrap().sort_unstable();

                    out
                });

                let pyarrow_predicate: Option<String> = if !unified_scan_args
                    .has_row_index_or_slice()
                    && let Some(predicate) = &predicate
                {
                    use crate::plans::aexpr::MintermIter;

                    // Convert each AND-minterm independently; combine successes.
                    let parts: Vec<String> = MintermIter::new(predicate.node(), expr_arena)
                        .filter_map(|node| predicate_to_pa(node, expr_arena, Default::default()))
                        .collect();
                    match parts.len() {
                        0 => None,
                        1 => Some(parts.into_iter().next().unwrap()),
                        _ => Some(format!("({})", parts.join(" & "))),
                    }
                } else {
                    None
                };

                let existing_resolved_version_key = match guard.as_ref() {
                    Some(resolved) => {
                        let ExpandedDataset {
                            version,
                            limit: cached_limit,
                            projection: cached_projection,
                            live_filter_columns: cached_live_filter_columns,
                            pyarrow_predicate: cached_pyarrow_predicate,
                            expanded_dsl: _,
                            python_scan: _,
                        } = resolved;

                        (&limit == cached_limit

Review comment (suggestion):
```suggestion
                    // Convert minterms independently, can allow conversion to partially succeed if there are unsupported expressions
```


Code after:
                                if unified_scan_args
                                    .row_index
                                    .as_ref()
                                    .is_some_and(|ri| live_col == &ri.name)
                                {
                                    row_index_in_live_filter = true;
                                    false
                                } else {
                                    true
                                }
                            })
                            .cloned()
                            .collect();

                    Arc::get_mut(&mut out).unwrap().sort_unstable();

                    out
                });

                let pyarrow_predicate: Option<String> = if !unified_scan_args
                    .has_row_index_or_slice()
                    && let Some(predicate) = &predicate
                {
                    use crate::plans::aexpr::MintermIter;

                    // Convert minterms independently, can allow conversion to partially succeed if there are unsupported expressions
                    let parts: Vec<String> = MintermIter::new(predicate.node(), expr_arena)
                        .filter_map(|node| predicate_to_pa(node, expr_arena, Default::default()))
                        .collect();
                    match parts.len() {
                        0 => None,
                        1 => Some(parts.into_iter().next().unwrap()),
                        _ => Some(format!("({})", parts.join(" & "))),
                    }
                } else {
                    None
                };

                let existing_resolved_version_key = match guard.as_ref() {
                    Some(resolved) => {
                        let ExpandedDataset {
                            version,
                            limit: cached_limit,
                            projection: cached_projection,
                            live_filter_columns: cached_live_filter_columns,
                            pyarrow_predicate: cached_pyarrow_predicate,
                            expanded_dsl: _,
                            python_scan: _,
                        } = resolved;

                        (&limit == cached_limit