Path: blob/main/crates/polars-plan/src/plans/anonymous_scan.rs
8440 views
use std::any::Any;1use std::fmt::{Debug, Formatter};23use polars_core::prelude::*;45use crate::dsl::Expr;67pub struct AnonymousScanArgs {8pub n_rows: Option<usize>,9pub with_columns: Option<Arc<[PlSmallStr]>>,10pub schema: SchemaRef,11pub output_schema: Option<SchemaRef>,12pub predicate: Option<Expr>,13}1415pub trait AnonymousScan: Send + Sync {16fn as_any(&self) -> &dyn Any;17/// Creates a DataFrame from the supplied function & scan options.18fn scan(&self, scan_opts: AnonymousScanArgs) -> PolarsResult<DataFrame>;1920/// function to supply the schema.21/// Allows for an optional infer schema argument for data sources with dynamic schemas22fn schema(&self, _infer_schema_length: Option<usize>) -> PolarsResult<SchemaRef> {23polars_bail!(ComputeError: "must supply either a schema or a schema function");24}25/// Specify if the scan provider should allow predicate pushdowns.26///27/// Defaults to `false`28fn allows_predicate_pushdown(&self) -> bool {29false30}31/// Specify if the scan provider should allow projection pushdowns.32///33/// Defaults to `false`34fn allows_projection_pushdown(&self) -> bool {35false36}37}3839impl Debug for dyn AnonymousScan {40fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {41write!(f, "anonymous_scan")42}43}444546