diff --git a/rust/datafusion/src/execution/physical_plan/expressions.rs b/rust/datafusion/src/execution/physical_plan/expressions.rs new file mode 100644 index 0000000000000..7fa5ef0864b7c --- /dev/null +++ b/rust/datafusion/src/execution/physical_plan/expressions.rs @@ -0,0 +1,35 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Defines physical expressions that can evaluated at runtime during query execution + +use arrow::array::ArrayRef; +use arrow::record_batch::RecordBatch; +use crate::error::Result; +use crate::execution::physical_plan::PhysicalExpr; + +/// Represents the column at a given index in a RecordBatch +pub struct Column { + index: usize +} + +impl PhysicalExpr for Column { + /// Evaluate the expression + fn evaluate(&self, batch: &RecordBatch) -> Result { + Ok(batch.column(self.index).clone()) + } +} \ No newline at end of file diff --git a/rust/datafusion/src/execution/physical_plan/mod.rs b/rust/datafusion/src/execution/physical_plan/mod.rs index 7aedd7902eb9e..d8d31fd6bb3e6 100644 --- a/rust/datafusion/src/execution/physical_plan/mod.rs +++ b/rust/datafusion/src/execution/physical_plan/mod.rs @@ -50,4 +50,5 @@ pub trait PhysicalExpr: Send + Sync { fn evaluate(&self, batch: &RecordBatch) -> Result; } +pub mod expressions; pub mod projection;