Skip to content

Commit

Permalink
Review Part 32 | Module reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
ozankabak committed Feb 14, 2025
1 parent 3192eef commit 47dc8f7
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 23 deletions.
1 change: 1 addition & 0 deletions datafusion/expr-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ pub mod interval_arithmetic;
pub mod operator;
pub mod signature;
pub mod sort_properties;
pub mod statistics;
pub mod type_coercion;
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

use std::f64::consts::LN_2;

use crate::interval_arithmetic::{apply_operator, Interval};
use crate::operator::Operator;
use crate::type_coercion::binary::binary_numeric_coercion;

use arrow::array::ArrowNativeTypeOp;
use arrow::datatypes::DataType;
use datafusion_common::rounding::alter_fp_rounding_mode;
use datafusion_common::{internal_err, not_impl_err, Result, ScalarValue};
use datafusion_expr_common::interval_arithmetic::{apply_operator, Interval};
use datafusion_expr_common::operator::Operator;
use datafusion_expr_common::type_coercion::binary::binary_numeric_coercion;

/// New, enhanced `Statistics` definition, represents five core statistical
/// distributions. New variants will be added over time.
Expand Down Expand Up @@ -857,11 +858,11 @@ mod tests {
compute_mean, compute_median, compute_variance, create_bernoulli_from_comparison,
new_unknown_from_binary_op, StatisticsV2, UniformDistribution,
};
use crate::interval_arithmetic::{apply_operator, Interval};
use crate::operator::Operator;

use arrow::datatypes::DataType;
use datafusion_common::{Result, ScalarValue};
use datafusion_expr_common::interval_arithmetic::{apply_operator, Interval};
use datafusion_expr_common::operator::Operator;

// The test data in the following tests are placed as follows: (stat -> expected answer)
#[test]
Expand Down
4 changes: 3 additions & 1 deletion datafusion/expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pub mod function;
pub mod groups_accumulator {
pub use datafusion_expr_common::groups_accumulator::*;
}

pub mod interval_arithmetic {
pub use datafusion_expr_common::interval_arithmetic::*;
}
Expand All @@ -57,6 +56,9 @@ pub mod simplify;
pub mod sort_properties {
pub use datafusion_expr_common::sort_properties::*;
}
pub mod stats_v2 {
pub use datafusion_expr_common::statistics::*;
}
pub mod test;
pub mod tree_node;
pub mod type_coercion;
Expand Down
1 change: 0 additions & 1 deletion datafusion/physical-expr-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ pub mod binary_view_map;
pub mod datum;
pub mod physical_expr;
pub mod sort_expr;
pub mod stats_v2;
pub mod tree_node;
pub mod utils;
2 changes: 1 addition & 1 deletion datafusion/physical-expr-common/src/physical_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::fmt::{Debug, Display, Formatter};
use std::hash::{Hash, Hasher};
use std::sync::Arc;

use crate::stats_v2::StatisticsV2;
use crate::utils::scatter;

use arrow::array::BooleanArray;
Expand All @@ -31,6 +30,7 @@ use datafusion_common::{internal_err, not_impl_err, Result, ScalarValue};
use datafusion_expr_common::columnar_value::ColumnarValue;
use datafusion_expr_common::interval_arithmetic::Interval;
use datafusion_expr_common::sort_properties::ExprProperties;
use datafusion_expr_common::statistics::StatisticsV2;

use itertools::izip;

Expand Down
13 changes: 6 additions & 7 deletions datafusion/physical-expr/src/expressions/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ use datafusion_common::{internal_err, Result, ScalarValue};
use datafusion_expr::binary::BinaryTypeCoercer;
use datafusion_expr::interval_arithmetic::{apply_operator, Interval};
use datafusion_expr::sort_properties::ExprProperties;
use datafusion_expr::{ColumnarValue, Operator};
use datafusion_physical_expr_common::datum::{apply, apply_cmp, apply_cmp_for_nested};
use datafusion_physical_expr_common::stats_v2::StatisticsV2::{
self, Bernoulli, Gaussian,
};
use datafusion_physical_expr_common::stats_v2::{
use datafusion_expr::stats_v2::StatisticsV2::{Bernoulli, Gaussian};
use datafusion_expr::stats_v2::{
combine_bernoullis, combine_gaussians, create_bernoulli_from_comparison,
new_unknown_from_binary_op,
new_unknown_from_binary_op, StatisticsV2,
};
use datafusion_expr::{ColumnarValue, Operator};
use datafusion_physical_expr_common::datum::{apply, apply_cmp, apply_cmp_for_nested};

use kernels::{
bitwise_and_dyn, bitwise_and_dyn_scalar, bitwise_or_dyn, bitwise_or_dyn_scalar,
bitwise_shift_left_dyn, bitwise_shift_left_dyn_scalar, bitwise_shift_right_dyn,
Expand Down
6 changes: 3 additions & 3 deletions datafusion/physical-expr/src/expressions/negative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ use arrow::{
use datafusion_common::{internal_err, plan_err, Result};
use datafusion_expr::interval_arithmetic::Interval;
use datafusion_expr::sort_properties::ExprProperties;
use datafusion_expr::stats_v2::StatisticsV2::{
self, Bernoulli, Exponential, Gaussian, Uniform, Unknown,
};
use datafusion_expr::{
type_coercion::{is_interval, is_null, is_signed_numeric, is_timestamp},
ColumnarValue,
};
use datafusion_physical_expr_common::stats_v2::StatisticsV2::{
self, Bernoulli, Exponential, Gaussian, Uniform, Unknown,
};

/// Negative expression
#[derive(Debug, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/expressions/not.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use arrow::datatypes::{DataType, Schema};
use arrow::record_batch::RecordBatch;
use datafusion_common::{cast::as_boolean_array, internal_err, Result, ScalarValue};
use datafusion_expr::interval_arithmetic::Interval;
use datafusion_expr::stats_v2::StatisticsV2::{self, Bernoulli};
use datafusion_expr::ColumnarValue;
use datafusion_physical_expr_common::stats_v2::StatisticsV2::{self, Bernoulli};

/// Not expression
#[derive(Debug, Eq)]
Expand Down
20 changes: 20 additions & 0 deletions datafusion/physical-expr/src/statistics/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.

//! Statistics and constraint propagation library
pub mod stats_solver;
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use crate::utils::{build_dag, ExprTreeNode};

use arrow::datatypes::{DataType, Schema};
use datafusion_common::{Result, ScalarValue};
use datafusion_expr::stats_v2::StatisticsV2;
use datafusion_expr_common::interval_arithmetic::Interval;
use datafusion_physical_expr_common::stats_v2::StatisticsV2;

use petgraph::adj::DefaultIx;
use petgraph::prelude::Bfs;
Expand Down Expand Up @@ -211,9 +211,9 @@ mod tests {
use datafusion_common::{Result, ScalarValue};
use datafusion_expr_common::interval_arithmetic::Interval;
use datafusion_expr_common::operator::Operator;
use datafusion_expr_common::statistics::StatisticsV2;
use datafusion_expr_common::type_coercion::binary::BinaryTypeCoercer;
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
use datafusion_physical_expr_common::stats_v2::StatisticsV2;

pub fn binary_expr(
left: Arc<dyn PhysicalExpr>,
Expand Down
2 changes: 0 additions & 2 deletions datafusion/physical-expr/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ use petgraph::graph::NodeIndex;
use petgraph::stable_graph::StableGraph;

// Public interface:
pub mod stats_v2_graph;

pub use guarantee::{Guarantee, LiteralGuarantee};

/// Assume the predicate is in the form of CNF, split the predicate to a Vec of PhysicalExprs.
Expand Down

0 comments on commit 47dc8f7

Please sign in to comment.