Repository: pola-rs/polars
File: crates/polars-mem-engine/src/scan_predicate/functions.rs (Rust)

Code before:
        hive_options: _,
        rechunk: _,
        cache: _,
        glob: _,
        hidden_file_prefix: _,
        projection: _,
        column_mapping: _,
        default_values,
        // Ensure these are None.
        row_index: None,
        pre_slice: None,
        cast_columns_policy: _,
        missing_columns_policy: _,
        extra_columns_policy: _,
        include_file_paths: _,
        table_statistics,
        deletion_files,
        row_count,
    } = unified_scan_args.as_mut()
    else {
        panic!("{unified_scan_args:?}")
    };

    *row_count = None;

    if selected_path_indices.clone().next() != Some(0) {
        *row_estimation = (None, usize::MAX);
        *reader_schema = None;

        // Ensure the metadata is unset, otherwise it may incorrectly be used at
        // scan. This is especially important for Parquet as it requires the
        // correct `is_nullable` in the arrow field.
        match scan_type.as_mut() {
            #[cfg(feature = "parquet")]
            FileScanIR::Parquet {
                options: _,
                metadata,
            } => *metadata = None,

            #[cfg(feature = "ipc")]
            FileScanIR::Ipc {
                options: _,
                metadata,
            } => *metadata = None,

            #[cfg(feature = "csv")]
            FileScanIR::Csv { options: _ } => {},

            #[cfg(feature = "json")]
            FileScanIR::NDJson { options: _ } => {},


Review comment (suggestion):
We rather have estimations than `None`. So I think we should multiply the estimation with the ratio of `total_files/ remaining_files`.

Code after:
        hive_options: _,
        rechunk: _,
        cache: _,
        glob: _,
        hidden_file_prefix: _,
        projection: _,
        column_mapping: _,
        default_values,
        // Ensure these are None.
        row_index: None,
        pre_slice: None,
        cast_columns_policy: _,
        missing_columns_policy: _,
        extra_columns_policy: _,
        include_file_paths: _,
        table_statistics,
        deletion_files,
        row_count,
    } = unified_scan_args.as_mut()
    else {
        panic!("{unified_scan_args:?}")
    };

    *row_count = None;

    if selected_path_indices.clone().next() != Some(0) {
        *reader_schema = None;

        // Ensure the metadata is unset, otherwise it may incorrectly be used at
        // scan. This is especially important for Parquet as it requires the
        // correct `is_nullable` in the arrow field.
        match scan_type.as_mut() {
            #[cfg(feature = "parquet")]
            FileScanIR::Parquet {
                options: _,
                metadata,
            } => *metadata = None,

            #[cfg(feature = "ipc")]
            FileScanIR::Ipc {
                options: _,
                metadata,
            } => *metadata = None,

            #[cfg(feature = "csv")]
            FileScanIR::Csv { options: _ } => {},

            #[cfg(feature = "json")]
            FileScanIR::NDJson { options: _ } => {},

            #[cfg(feature = "python")]