Skip to content

Commit

Permalink
Merge commit 'f8c623fe045d70a87eac8dc8620b74ff73be56d5' into chunchun…
Browse files Browse the repository at this point in the history
…/update-df-apr-week-4-3
  • Loading branch information
appletreeisyellow committed Apr 30, 2024
2 parents ed56f4a + f8c623f commit e0ffd76
Show file tree
Hide file tree
Showing 43 changed files with 454 additions and 278 deletions.
33 changes: 0 additions & 33 deletions datafusion/core/src/physical_optimizer/join_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,28 +882,6 @@ mod tests_statistical {
(big, medium, small)
}

pub(crate) fn crosscheck_plans(plan: Arc<dyn ExecutionPlan>) -> Result<()> {
let subrules: Vec<Box<PipelineFixerSubrule>> = vec![
Box::new(hash_join_convert_symmetric_subrule),
Box::new(hash_join_swap_subrule),
];
let new_plan = plan
.transform_up(|p| apply_subrules(p, &subrules, &ConfigOptions::new()))
.data()?;
// TODO: End state payloads will be checked here.
let config = ConfigOptions::new().optimizer;
let collect_left_threshold = config.hash_join_single_partition_threshold;
let collect_threshold_num_rows = config.hash_join_single_partition_threshold_rows;
let _ = new_plan.transform_up(|plan| {
statistical_join_selection_subrule(
plan,
collect_left_threshold,
collect_threshold_num_rows,
)
})?;
Ok(())
}

#[tokio::test]
async fn test_join_with_swap() {
let (big, small) = create_big_and_small();
Expand Down Expand Up @@ -958,7 +936,6 @@ mod tests_statistical {
swapped_join.right().statistics().unwrap().total_byte_size,
Precision::Inexact(2097152)
);
crosscheck_plans(join.clone()).unwrap();
}

#[tokio::test]
Expand Down Expand Up @@ -1001,7 +978,6 @@ mod tests_statistical {
swapped_join.right().statistics().unwrap().total_byte_size,
Precision::Inexact(2097152)
);
crosscheck_plans(join.clone()).unwrap();
}

#[tokio::test]
Expand Down Expand Up @@ -1055,7 +1031,6 @@ mod tests_statistical {
Precision::Inexact(2097152)
);
assert_eq!(original_schema, swapped_join.schema());
crosscheck_plans(join).unwrap();
}
}

Expand All @@ -1078,7 +1053,6 @@ mod tests_statistical {
"\n\nexpected:\n\n{:#?}\nactual:\n\n{:#?}\n\n",
expected_lines, actual_lines
);
crosscheck_plans(plan).unwrap();
};
}

Expand Down Expand Up @@ -1180,7 +1154,6 @@ mod tests_statistical {
swapped_join.right().statistics().unwrap().total_byte_size,
Precision::Inexact(2097152)
);
crosscheck_plans(join).unwrap();
}

#[rstest(
Expand Down Expand Up @@ -1249,7 +1222,6 @@ mod tests_statistical {
swapped_join.right().statistics().unwrap().total_byte_size,
Precision::Inexact(2097152)
);
crosscheck_plans(join.clone()).unwrap();
}

#[rstest(
Expand Down Expand Up @@ -1311,7 +1283,6 @@ mod tests_statistical {
swapped_join.right().statistics().unwrap().total_byte_size,
Precision::Inexact(2097152)
);
crosscheck_plans(join.clone()).unwrap();
}

#[tokio::test]
Expand Down Expand Up @@ -1523,7 +1494,6 @@ mod tests_statistical {

assert_eq!(*swapped_join.partition_mode(), expected_mode);
}
crosscheck_plans(join).unwrap();
}
}

Expand Down Expand Up @@ -1568,8 +1538,6 @@ mod util_tests {

#[cfg(test)]
mod hash_join_tests {

use self::tests_statistical::crosscheck_plans;
use super::*;
use crate::physical_optimizer::test_utils::SourceType;
use crate::test_util::UnboundedExec;
Expand Down Expand Up @@ -2000,7 +1968,6 @@ mod hash_join_tests {
)
);
};
crosscheck_plans(plan).unwrap();
Ok(())
}
}
2 changes: 1 addition & 1 deletion datafusion/expr/src/built_in_window_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub enum BuiltInWindowFunction {
}

impl BuiltInWindowFunction {
fn name(&self) -> &str {
pub fn name(&self) -> &str {
use BuiltInWindowFunction::*;
match self {
RowNumber => "ROW_NUMBER",
Expand Down
10 changes: 10 additions & 0 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,16 @@ impl WindowFunctionDefinition {
WindowFunctionDefinition::WindowUDF(fun) => fun.signature().clone(),
}
}

/// Function's name for display
pub fn name(&self) -> &str {
match self {
WindowFunctionDefinition::BuiltInWindowFunction(fun) => fun.name(),
WindowFunctionDefinition::WindowUDF(fun) => fun.name(),
WindowFunctionDefinition::AggregateFunction(fun) => fun.name(),
WindowFunctionDefinition::AggregateUDF(fun) => fun.name(),
}
}
}

impl fmt::Display for WindowFunctionDefinition {
Expand Down
7 changes: 7 additions & 0 deletions datafusion/functions/src/string/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ pub fn ascii<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
pub struct AsciiFunc {
signature: Signature,
}

impl Default for AsciiFunc {
fn default() -> Self {
Self::new()
}
}

impl AsciiFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/bit_length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ pub struct BitLengthFunc {
signature: Signature,
}

impl Default for BitLengthFunc {
fn default() -> Self {
Self::new()
}
}

impl BitLengthFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/btrim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ pub struct BTrimFunc {
aliases: Vec<String>,
}

impl Default for BTrimFunc {
fn default() -> Self {
Self::new()
}
}

impl BTrimFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/chr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ pub struct ChrFunc {
signature: Signature,
}

impl Default for ChrFunc {
fn default() -> Self {
Self::new()
}
}

impl ChrFunc {
pub fn new() -> Self {
Self {
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/levenshtein.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub struct LevenshteinFunc {
signature: Signature,
}

impl Default for LevenshteinFunc {
fn default() -> Self {
Self::new()
}
}

impl LevenshteinFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ pub struct LowerFunc {
signature: Signature,
}

impl Default for LowerFunc {
fn default() -> Self {
Self::new()
}
}

impl LowerFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/ltrim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ pub struct LtrimFunc {
signature: Signature,
}

impl Default for LtrimFunc {
fn default() -> Self {
Self::new()
}
}

impl LtrimFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
44 changes: 22 additions & 22 deletions datafusion/functions/src/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ use std::sync::Arc;

use datafusion_expr::ScalarUDF;

mod ascii;
mod bit_length;
mod btrim;
mod chr;
mod common;
mod concat;
mod concat_ws;
mod ends_with;
mod initcap;
mod levenshtein;
mod lower;
mod ltrim;
mod octet_length;
mod overlay;
mod repeat;
mod replace;
mod rtrim;
mod split_part;
mod starts_with;
mod to_hex;
mod upper;
mod uuid;
pub mod ascii;
pub mod bit_length;
pub mod btrim;
pub mod chr;
pub mod common;
pub mod concat;
pub mod concat_ws;
pub mod ends_with;
pub mod initcap;
pub mod levenshtein;
pub mod lower;
pub mod ltrim;
pub mod octet_length;
pub mod overlay;
pub mod repeat;
pub mod replace;
pub mod rtrim;
pub mod split_part;
pub mod starts_with;
pub mod to_hex;
pub mod upper;
pub mod uuid;

// create UDFs
make_udf_function!(ascii::AsciiFunc, ASCII, ascii);
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/octet_length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ pub struct OctetLengthFunc {
signature: Signature,
}

impl Default for OctetLengthFunc {
fn default() -> Self {
Self::new()
}
}

impl OctetLengthFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub struct OverlayFunc {
signature: Signature,
}

impl Default for OverlayFunc {
fn default() -> Self {
Self::new()
}
}

impl OverlayFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/repeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub struct RepeatFunc {
signature: Signature,
}

impl Default for RepeatFunc {
fn default() -> Self {
Self::new()
}
}

impl RepeatFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub struct ReplaceFunc {
signature: Signature,
}

impl Default for ReplaceFunc {
fn default() -> Self {
Self::new()
}
}

impl ReplaceFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/rtrim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ pub struct RtrimFunc {
signature: Signature,
}

impl Default for RtrimFunc {
fn default() -> Self {
Self::new()
}
}

impl RtrimFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/split_part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub struct SplitPartFunc {
signature: Signature,
}

impl Default for SplitPartFunc {
fn default() -> Self {
Self::new()
}
}

impl SplitPartFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
7 changes: 7 additions & 0 deletions datafusion/functions/src/string/starts_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ pub fn starts_with<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
pub struct StartsWithFunc {
signature: Signature,
}

impl Default for StartsWithFunc {
fn default() -> Self {
Self::new()
}
}

impl StartsWithFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
7 changes: 7 additions & 0 deletions datafusion/functions/src/string/to_hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ where
pub struct ToHexFunc {
signature: Signature,
}

impl Default for ToHexFunc {
fn default() -> Self {
Self::new()
}
}

impl ToHexFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/string/upper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ pub struct UpperFunc {
signature: Signature,
}

impl Default for UpperFunc {
fn default() -> Self {
Self::new()
}
}

impl UpperFunc {
pub fn new() -> Self {
use DataType::*;
Expand Down
Loading

0 comments on commit e0ffd76

Please sign in to comment.