From eea02647c207489a1a89ce59a248cf15df35c487 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Thu, 15 Aug 2024 16:59:16 +0100 Subject: [PATCH] Remove dead code after disk and in memory table provider unification (#633) --- vortex-datafusion/src/expr.rs | 59 ++--------------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/vortex-datafusion/src/expr.rs b/vortex-datafusion/src/expr.rs index 260f935be6..001677c565 100644 --- a/vortex-datafusion/src/expr.rs +++ b/vortex-datafusion/src/expr.rs @@ -5,12 +5,9 @@ use std::fmt::Debug; use std::sync::Arc; use arrow_schema::{Schema, SchemaRef}; -use datafusion::optimizer::simplify_expressions::ExprSimplifier; use datafusion_common::tree_node::{TreeNode, TreeNodeRecursion}; -use datafusion_common::{DataFusionError, Result as DFResult, ToDFSchema}; -use datafusion_expr::execution_props::ExecutionProps; -use datafusion_expr::simplify::SimplifyContext; -use datafusion_expr::{and, lit, Expr, Operator as DFOperator}; +use datafusion_common::{DataFusionError, Result as DFResult}; +use datafusion_expr::Operator as DFOperator; use datafusion_physical_expr::PhysicalExpr; use vortex::array::{ConstantArray, StructArray}; use vortex::compute::compare; @@ -22,33 +19,6 @@ use vortex_scalar::Scalar; use crate::scalar::dfvalue_to_scalar; -/// Convert a set of expressions into a single AND expression. -/// -/// # Returns -/// -/// If conversion is successful, the result will be a -/// [binary expression node][datafusion_expr::Expr::BinaryExpr] containing the conjunction. -pub(crate) fn make_conjunction(exprs: impl AsRef<[Expr]>) -> DFResult { - Ok(exprs - .as_ref() - .iter() - .fold(lit(true), |conj, elem| and(conj, elem.clone()))) -} - -/// Simplify an expression using DataFusion's builtin analysis passes. -/// -/// This encapsulates common optimizations like constant folding and eliminating redundant -/// expressions, e.g. `value AND true`. -pub(crate) fn simplify_expr(expr: &Expr, schema: SchemaRef) -> DFResult { - let schema = schema.to_dfschema_ref()?; - - let props = ExecutionProps::new(); - let context = SimplifyContext::new(&props).with_schema(schema); - let simplifier = ExprSimplifier::new(context); - - simplifier.simplify(expr.clone()) -} - pub trait VortexPhysicalExpr: Debug + Send + Sync { fn evaluate(&self, array: &Array) -> VortexResult; } @@ -206,28 +176,3 @@ pub(crate) fn extract_columns_from_expr( Ok(predicate_projection) } - -#[cfg(test)] -mod test { - use std::sync::Arc; - - use arrow_schema::{DataType, Field, Schema}; - use datafusion_expr::{col, lit}; - - use super::*; - - #[test] - fn test_conjunction_simplify() { - let schema = Arc::new(Schema::new(vec![ - Field::new("int_col", DataType::Int32, false), - Field::new("bool_col", DataType::Boolean, false), - ])); - - let exprs = vec![col("int_col").gt_eq(lit(4)), col("bool_col").is_true()]; - - assert_eq!( - simplify_expr(&make_conjunction(&exprs).unwrap(), schema).unwrap(), - and(col("int_col").gt_eq(lit(4)), col("bool_col").is_true()) - ); - } -}