MCPcopy Create free account
hub / github.com/apache/datafusion / scan

Method scan

datafusion-examples/examples/udf/simple_udtf.rs:96–127  ·  view source on GitHub ↗
(
        &self,
        _state: &dyn Session,
        projection: Option<&Vec<usize>>,
        _filters: &[Expr],
        _limit: Option<usize>,
    )

Source from the content-addressed store, hash-verified

94 }
95
96 async fn scan(
97 &self,
98 _state: &dyn Session,
99 projection: Option<&Vec<usize>>,
100 _filters: &[Expr],
101 _limit: Option<usize>,
102 ) -> Result<Arc<dyn ExecutionPlan>> {
103 let batches = if let Some(max_return_lines) = self.limit {
104 // get max return rows from self.batches
105 let mut batches = vec![];
106 let mut lines = 0;
107 for batch in &self.batches {
108 let batch_lines = batch.num_rows();
109 if lines + batch_lines > max_return_lines {
110 let batch_lines = max_return_lines - lines;
111 batches.push(batch.slice(0, batch_lines));
112 break;
113 } else {
114 batches.push(batch.clone());
115 lines += batch_lines;
116 }
117 }
118 batches
119 } else {
120 self.batches.clone()
121 };
122 Ok(MemorySourceConfig::try_new_exec(
123 &[batches],
124 TableProvider::schema(self),
125 projection.cloned(),
126 )?)
127 }
128}
129
130#[derive(Debug)]

Callers

nothing calls this directly

Calls 5

sliceMethod · 0.80
schemaFunction · 0.50
pushMethod · 0.45
cloneMethod · 0.45
clonedMethod · 0.45

Tested by

no test coverage detected