Path: blob/main/crates/polars-plan/src/plans/python/source.rs
6940 views
use std::sync::Arc;12use polars_core::schema::SchemaRef;3use polars_utils::python_function::PythonFunction;4#[cfg(feature = "ir_serde")]5use serde::{Deserialize, Serialize};67use crate::dsl::python_dsl::PythonScanSource;8use crate::plans::{ExprIR, PlSmallStr};910#[derive(Clone, PartialEq, Eq, Debug, Default)]11#[cfg_attr(feature = "ir_serde", derive(Serialize, Deserialize))]12pub struct PythonOptions {13/// A function that returns a Python Generator.14/// The generator should produce Polars DataFrame's.15pub scan_fn: Option<PythonFunction>,16/// Schema of the file.17pub schema: SchemaRef,18/// Schema the reader will produce when the file is read.19pub output_schema: Option<SchemaRef>,20// Projected column names.21pub with_columns: Option<Arc<[PlSmallStr]>>,22// Which interface is the python function.23pub python_source: PythonScanSource,24/// A `head` call passed to the reader.25pub n_rows: Option<usize>,26/// Optional predicate the reader must apply.27pub predicate: PythonPredicate,28/// Validate if the source gives the proper schema.29pub validate_schema: bool,30/// Whether this scan is free of side effects (allows for CSE when that is the case).31pub is_pure: bool,32}3334#[derive(Clone, PartialEq, Eq, Debug, Default)]35#[cfg_attr(feature = "ir_serde", derive(Serialize, Deserialize))]36pub enum PythonPredicate {37// A pyarrow predicate python expression38// can be evaluated with python.eval39PyArrow(String),40Polars(ExprIR),41#[default]42None,43}444546