polars_plan/plans/
anonymous_scan.rs1use std::any::Any;
2use std::fmt::{Debug, Formatter};
3
4use polars_core::prelude::*;
5
6pub use super::options::AnonymousScanOptions;
7use crate::dsl::Expr;
8
9pub struct AnonymousScanArgs {
10 pub n_rows: Option<usize>,
11 pub with_columns: Option<Arc<[PlSmallStr]>>,
12 pub schema: SchemaRef,
13 pub output_schema: Option<SchemaRef>,
14 pub predicate: Option<Expr>,
15}
16
17pub trait AnonymousScan: Send + Sync {
18 fn as_any(&self) -> &dyn Any;
19 fn scan(&self, scan_opts: AnonymousScanArgs) -> PolarsResult<DataFrame>;
21
22 fn next_batch(&self, scan_opts: AnonymousScanArgs) -> PolarsResult<Option<DataFrame>> {
25 self.scan(scan_opts).map(Some)
26 }
27
28 fn schema(&self, _infer_schema_length: Option<usize>) -> PolarsResult<SchemaRef> {
31 polars_bail!(ComputeError: "must supply either a schema or a schema function");
32 }
33 fn allows_predicate_pushdown(&self) -> bool {
37 false
38 }
39 fn allows_projection_pushdown(&self) -> bool {
43 false
44 }
45 fn allows_slice_pushdown(&self) -> bool {
49 false
50 }
51}
52
53impl Debug for dyn AnonymousScan {
54 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
55 write!(f, "anonymous_scan")
56 }
57}