polars_lazy/scan/
anonymous_scan.rs1use polars_core::prelude::*;
2use polars_io::RowIndex;
3
4use crate::prelude::*;
5
6#[derive(Clone)]
7pub struct ScanArgsAnonymous {
8 pub infer_schema_length: Option<usize>,
9 pub schema: Option<SchemaRef>,
10 pub skip_rows: Option<usize>,
11 pub n_rows: Option<usize>,
12 pub row_index: Option<RowIndex>,
13 pub name: &'static str,
14}
15
16impl Default for ScanArgsAnonymous {
17 fn default() -> Self {
18 Self {
19 infer_schema_length: None,
20 skip_rows: None,
21 n_rows: None,
22 schema: None,
23 row_index: None,
24 name: "ANONYMOUS SCAN",
25 }
26 }
27}
28impl LazyFrame {
29 pub fn anonymous_scan(
30 function: Arc<dyn AnonymousScan>,
31 args: ScanArgsAnonymous,
32 ) -> PolarsResult<Self> {
33 let mut lf: LazyFrame = DslBuilder::anonymous_scan(
34 function,
35 args.schema,
36 args.infer_schema_length,
37 args.skip_rows,
38 args.n_rows,
39 args.name,
40 )?
41 .build()
42 .into();
43
44 if let Some(rc) = args.row_index {
45 lf = lf.with_row_index(rc.name.clone(), Some(rc.offset))
46 };
47
48 Ok(lf)
49 }
50}