Skip to content

Commit

Permalink
Implement Column expression
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Aug 6, 2019
1 parent d1ede3c commit 768a7ae
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions rust/datafusion/src/execution/physical_plan/expressions.rs
Original file line number Diff line number Diff line change
@@ -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<ArrayRef> {
Ok(batch.column(self.index).clone())
}
}
1 change: 1 addition & 0 deletions rust/datafusion/src/execution/physical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ pub trait PhysicalExpr: Send + Sync {
fn evaluate(&self, batch: &RecordBatch) -> Result<ArrayRef>;
}

pub mod expressions;
pub mod projection;

0 comments on commit 768a7ae

Please sign in to comment.