| 90 | } |
| 91 | |
| 92 | fn evaluate(&self, batch: &RecordBatch) -> Result<ColumnarValue> { |
| 93 | if self.index >= batch.num_columns() { |
| 94 | return internal_err!( |
| 95 | "PhysicalExpr LambdaVariable references column '{}' at index {} (zero-based) but batch only has {} columns: {:?}", |
| 96 | self.name(), |
| 97 | self.index, |
| 98 | batch.num_columns(), |
| 99 | batch |
| 100 | .schema_ref() |
| 101 | .fields() |
| 102 | .iter() |
| 103 | .map(|f| f.name()) |
| 104 | .collect::<Vec<_>>() |
| 105 | ); |
| 106 | } |
| 107 | |
| 108 | if self.field.as_ref() != batch.schema_ref().field(self.index) { |
| 109 | return exec_err!( |
| 110 | "Field of physical LambdaVariable with index {} doesn't match batch field during evaluation {} != {}", |
| 111 | self.index, |
| 112 | self.field, |
| 113 | batch.schema_ref().field(self.index) |
| 114 | ); |
| 115 | } |
| 116 | |
| 117 | Ok(ColumnarValue::Array(Arc::clone(batch.column(self.index)))) |
| 118 | } |
| 119 | |
| 120 | fn return_field(&self, _input_schema: &Schema) -> Result<FieldRef> { |
| 121 | Ok(Arc::clone(&self.field)) |