Skip to content

Commit c5dc3e2

Browse files
committed
binary done
Signed-off-by: jayzhan211 <[email protected]>
1 parent 446bc82 commit c5dc3e2

File tree

9 files changed

+31
-22
lines changed

9 files changed

+31
-22
lines changed

datafusion-cli/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion/physical-expr-common/src/expressions/binary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use std::{any::Any, sync::Arc};
2323
use crate::expressions::datum::{apply, apply_cmp};
2424
use crate::intervals::cp_solver::{propagate_arithmetic, propagate_comparison};
2525
use crate::physical_expr::down_cast_any_ref;
26-
use crate::sort_properties::SortProperties;
2726
use crate::physical_expr::PhysicalExpr;
27+
use crate::sort_properties::SortProperties;
2828

2929
use arrow::array::*;
3030
use arrow::compute::kernels::boolean::{and_kleene, not, or_kleene};

datafusion/physical-expr-common/src/expressions/datum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use arrow::array::BooleanArray;
1819
use arrow::array::{ArrayRef, Datum};
1920
use arrow::error::ArrowError;
20-
use arrow::array::BooleanArray;
2121
use datafusion_common::{Result, ScalarValue};
2222
use datafusion_expr::ColumnarValue;
2323
use std::sync::Arc;

datafusion/physical-expr-common/src/intervals/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@
1919
2020
pub mod cp_solver;
2121
pub mod utils;
22-

datafusion/physical-expr-common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
pub mod aggregate;
1919
pub mod expressions;
20-
pub mod physical_expr;
2120
pub mod intervals;
21+
pub mod physical_expr;
2222
pub mod sort_expr;
2323
pub mod sort_properties;
2424
pub mod tree_node;

datafusion/physical-expr-common/src/physical_expr.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ use datafusion_common::{internal_err, not_impl_err, DFSchema, Result};
2929
use datafusion_expr::execution_props::ExecutionProps;
3030
use datafusion_expr::expr::Alias;
3131
use datafusion_expr::interval_arithmetic::Interval;
32-
use datafusion_expr::{ColumnarValue, Expr};
32+
use datafusion_expr::{BinaryExpr, ColumnarValue, Expr};
3333

34+
use crate::expressions::binary::binary;
3435
use crate::expressions::column::Column;
3536
use crate::expressions::literal::Literal;
3637
use crate::sort_properties::SortProperties;
@@ -288,7 +289,7 @@ pub fn create_physical_expr(
288289
input_dfschema: &DFSchema,
289290
execution_props: &ExecutionProps,
290291
) -> Result<Arc<dyn PhysicalExpr>> {
291-
let _input_schema: &Schema = &input_dfschema.into();
292+
let input_schema: &Schema = &input_dfschema.into();
292293

293294
match e {
294295
Expr::Alias(Alias { expr, .. }) => {
@@ -366,19 +367,19 @@ pub fn create_physical_expr(
366367
// );
367368
// create_physical_expr(&binary_op, input_dfschema, execution_props)
368369
// }
369-
// Expr::BinaryExpr(BinaryExpr { left, op, right }) => {
370-
// // Create physical expressions for left and right operands
371-
// let lhs = create_physical_expr(left, input_dfschema, execution_props)?;
372-
// let rhs = create_physical_expr(right, input_dfschema, execution_props)?;
373-
// // Note that the logical planner is responsible
374-
// // for type coercion on the arguments (e.g. if one
375-
// // argument was originally Int32 and one was
376-
// // Int64 they will both be coerced to Int64).
377-
// //
378-
// // There should be no coercion during physical
379-
// // planning.
380-
// binary(lhs, *op, rhs, input_schema)
381-
// }
370+
Expr::BinaryExpr(BinaryExpr { left, op, right }) => {
371+
// Create physical expressions for left and right operands
372+
let lhs = create_physical_expr(left, input_dfschema, execution_props)?;
373+
let rhs = create_physical_expr(right, input_dfschema, execution_props)?;
374+
// Note that the logical planner is responsible
375+
// for type coercion on the arguments (e.g. if one
376+
// argument was originally Int32 and one was
377+
// Int64 they will both be coerced to Int64).
378+
//
379+
// There should be no coercion during physical
380+
// planning.
381+
binary(lhs, *op, rhs, input_schema)
382+
}
382383
// Expr::Like(Like {
383384
// negated,
384385
// expr,

datafusion/physical-expr/src/expressions/like.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ use std::{any::Any, sync::Arc};
2020

2121
use crate::{physical_expr::down_cast_any_ref, PhysicalExpr};
2222

23-
use datafusion_physical_expr_common::expressions::datum::apply_cmp;
2423
use arrow::record_batch::RecordBatch;
2524
use arrow_schema::{DataType, Schema};
2625
use datafusion_common::{internal_err, Result};
2726
use datafusion_expr::ColumnarValue;
27+
use datafusion_physical_expr_common::expressions::datum::apply_cmp;
2828

2929
// Like expression
3030
#[derive(Debug, Hash)]

datafusion/physical-expr/src/expressions/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ pub use datafusion_functions_aggregate::first_last::{
7474
FirstValuePhysicalExpr as FirstValue, LastValuePhysicalExpr as LastValue,
7575
};
7676

77-
pub use datafusion_physical_expr_common::expressions::binary::{binary, BinaryExpr};
7877
pub use case::{case, CaseExpr};
7978
pub use cast::{cast, cast_with_options, CastExpr};
8079
pub use column::UnKnownColumn;
8180
pub use datafusion_expr::utils::format_state_name;
81+
pub use datafusion_physical_expr_common::expressions::binary::{binary, BinaryExpr};
8282
pub use datafusion_physical_expr_common::expressions::column::{col, Column};
8383
pub use datafusion_physical_expr_common::expressions::literal::{lit, Literal};
84+
pub use datafusion_physical_expr_common::expressions::try_cast::{try_cast, TryCastExpr};
8485
pub use in_list::{in_list, InListExpr};
8586
pub use is_not_null::{is_not_null, IsNotNullExpr};
8687
pub use is_null::{is_null, IsNullExpr};
8788
pub use like::{like, LikeExpr};
8889
pub use negative::{negative, NegativeExpr};
8990
pub use no_op::NoOp;
9091
pub use not::{not, NotExpr};
91-
pub use datafusion_physical_expr_common::expressions::try_cast::{try_cast, TryCastExpr};
9292

9393
#[cfg(test)]
9494
pub(crate) mod tests {

datafusion/physical-expr/src/planner.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ pub fn create_physical_expr(
106106
input_dfschema: &DFSchema,
107107
execution_props: &ExecutionProps,
108108
) -> Result<Arc<dyn PhysicalExpr>> {
109+
use datafusion_physical_expr_common::physical_expr::create_physical_expr as create_physical_expr_common;
110+
111+
// Temporary solution, after all the logic is moved to common, we can remove this function
112+
let res = create_physical_expr_common(e, input_dfschema, execution_props);
113+
if res.is_ok() {
114+
return res;
115+
}
116+
109117
let input_schema: &Schema = &input_dfschema.into();
110118

111119
match e {

0 commit comments

Comments
 (0)