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

Method project_batch

datafusion/datasource-parquet/src/push_decoder.rs:218–238  ·  view source on GitHub ↗
(&self, batch: &RecordBatch)

Source from the content-addressed store, hash-verified

216 }
217
218 fn project_batch(&self, batch: &RecordBatch) -> Result<RecordBatch> {
219 let mut batch = self.projector.project_batch(batch)?;
220 if self.replace_schema {
221 // Ensure the output batch has the expected schema.
222 // This handles things like schema level and field level metadata, which may not be present
223 // in the physical file schema.
224 // It is also possible for nullability to differ; some writers create files with
225 // OPTIONAL fields even when there are no nulls in the data.
226 // In these cases it may make sense for the logical schema to be `NOT NULL`.
227 // RecordBatch::try_new_with_options checks that if the schema is NOT NULL
228 // the array cannot contain nulls, amongst other checks.
229 let (_stream_schema, arrays, num_rows) = batch.into_parts();
230 let options = RecordBatchOptions::new().with_row_count(Some(num_rows));
231 batch = RecordBatch::try_new_with_options(
232 Arc::clone(&self.output_schema),
233 arrays,
234 &options,
235 )?;
236 }
237 Ok(batch)
238 }
239}

Calls 2

newFunction · 0.85
into_partsMethod · 0.80