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

Method project_batch

datafusion/physical-expr/src/projection.rs:814–834  ·  view source on GitHub ↗

Project a record batch according to this projector's expressions. # Errors This function returns an error if any expression evaluation fails or if the output schema of the resulting record batch does not match the pre-computed output schema of the projector.

(&self, batch: &RecordBatch)

Source from the content-addressed store, hash-verified

812 /// or if the output schema of the resulting record batch does not match
813 /// the pre-computed output schema of the projector.
814 pub fn project_batch(&self, batch: &RecordBatch) -> Result<RecordBatch> {
815 let arrays = evaluate_expressions_to_arrays_with_metrics(
816 self.projection.exprs.iter().map(|p| &p.expr),
817 batch,
818 self.expression_metrics.as_ref(),
819 )?;
820
821 if arrays.is_empty() {
822 let options =
823 RecordBatchOptions::new().with_row_count(Some(batch.num_rows()));
824 RecordBatch::try_new_with_options(
825 Arc::clone(&self.output_schema),
826 arrays,
827 &options,
828 )
829 .map_err(Into::into)
830 } else {
831 RecordBatch::try_new(Arc::clone(&self.output_schema), arrays)
832 .map_err(Into::into)
833 }
834 }
835
836 pub fn output_schema(&self) -> &SchemaRef {
837 &self.output_schema

Callers 3

batch_projectMethod · 0.45
adapt_batchMethod · 0.45
openMethod · 0.45

Calls 6

newFunction · 0.85
mapMethod · 0.45
iterMethod · 0.45
as_refMethod · 0.45
is_emptyMethod · 0.45

Tested by 1

openMethod · 0.36