Skip to content

Commit

Permalink
rm cfg test
Browse files Browse the repository at this point in the history
Signed-off-by: jayzhan211 <[email protected]>
  • Loading branch information
jayzhan211 committed May 29, 2024
1 parent 5e7da3b commit ead8121
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 77 deletions.
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub mod single_distinct_to_groupby;
pub mod unwrap_cast_in_comparison;
pub mod utils;

#[cfg(test)]
// Remove #cfg[test] to expose EmptyFunctionRegistry integration tests
pub mod test;

pub use analyzer::{Analyzer, AnalyzerRule};
Expand Down
11 changes: 6 additions & 5 deletions datafusion/optimizer/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use datafusion_common::config::ConfigOptions;
use datafusion_common::{assert_contains, not_impl_err, Result};
use datafusion_expr::registry::FunctionRegistry;
use datafusion_expr::{col, logical_plan::table_scan, LogicalPlan, LogicalPlanBuilder};
use std::collections::HashSet;
use std::sync::Arc;

pub mod user_defined;
Expand Down Expand Up @@ -79,20 +80,20 @@ impl FunctionRegistry for EmptyFunctionRegistry {
not_impl_err!("Registering FunctionRewrite")
}

fn udaf(&self, name: &str) -> Result<Arc<datafusion_expr::AggregateUDF>> {
fn udaf(&self, _name: &str) -> Result<Arc<datafusion_expr::AggregateUDF>> {
not_impl_err!("Getting AggregateUDF")
}

fn udf(&self, name: &str) -> Result<Arc<datafusion_expr::ScalarUDF>> {
fn udf(&self, _name: &str) -> Result<Arc<datafusion_expr::ScalarUDF>> {
not_impl_err!("Getting ScalarUDF")
}

fn udwf(&self, name: &str) -> Result<Arc<datafusion_expr::WindowUDF>> {
fn udwf(&self, _name: &str) -> Result<Arc<datafusion_expr::WindowUDF>> {
not_impl_err!("Getting WindowUDF")
}

fn udfs(&self) -> std::collections::HashSet<String> {
not_impl_err!("Getting UDFs")
fn udfs(&self) -> HashSet<String> {
HashSet::default()
}
}

Expand Down
73 changes: 2 additions & 71 deletions datafusion/optimizer/tests/optimizer_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use std::sync::Arc;
use arrow::datatypes::{DataType, Field, Schema, SchemaRef, TimeUnit};

use datafusion_common::config::ConfigOptions;
use datafusion_common::{not_impl_err, plan_err, Result};
use datafusion_expr::registry::FunctionRegistry;
use datafusion_common::{plan_err, Result};
use datafusion_expr::{AggregateUDF, LogicalPlan, ScalarUDF, TableSource, WindowUDF};
use datafusion_optimizer::analyzer::Analyzer;
use datafusion_optimizer::optimizer::Optimizer;
use datafusion_optimizer::test::EmptyFunctionRegistry;
use datafusion_optimizer::{OptimizerConfig, OptimizerContext, OptimizerRule};
use datafusion_sql::planner::{ContextProvider, SqlToRel};
use datafusion_sql::sqlparser::ast::Statement;
Expand All @@ -35,75 +35,6 @@ use datafusion_sql::sqlparser::parser::Parser;
use datafusion_sql::TableReference;


#[derive(Default)]
struct EmptyFunctionRegistry;
impl FunctionRegistry for EmptyFunctionRegistry {
fn register_udf(
&mut self,
_udf: Arc<datafusion_expr::ScalarUDF>,
) -> Result<Option<Arc<datafusion_expr::ScalarUDF>>> {
not_impl_err!("Registering ScalarUDF")
}

fn register_udaf(
&mut self,
_udaf: Arc<datafusion_expr::AggregateUDF>,
) -> Result<Option<Arc<datafusion_expr::AggregateUDF>>> {
not_impl_err!("Registering AggregateUDF")
}

fn register_udwf(
&mut self,
_udaf: Arc<datafusion_expr::WindowUDF>,
) -> Result<Option<Arc<datafusion_expr::WindowUDF>>> {
not_impl_err!("Registering WindowUDF")
}

fn deregister_udf(
&mut self,
_name: &str,
) -> Result<Option<Arc<datafusion_expr::ScalarUDF>>> {
not_impl_err!("Deregistering ScalarUDF")
}

fn deregister_udaf(
&mut self,
_name: &str,
) -> Result<Option<Arc<datafusion_expr::AggregateUDF>>> {
not_impl_err!("Deregistering AggregateUDF")
}

fn deregister_udwf(
&mut self,
_name: &str,
) -> Result<Option<Arc<datafusion_expr::WindowUDF>>> {
not_impl_err!("Deregistering WindowUDF")
}

fn register_function_rewrite(
&mut self,
_rewrite: Arc<dyn datafusion_expr::expr_rewriter::FunctionRewrite + Send + Sync>,
) -> Result<()> {
not_impl_err!("Registering FunctionRewrite")
}

fn udaf(&self, name: &str) -> Result<Arc<datafusion_expr::AggregateUDF>> {
not_impl_err!("Getting AggregateUDF")
}

fn udf(&self, name: &str) -> Result<Arc<datafusion_expr::ScalarUDF>> {
not_impl_err!("Getting ScalarUDF")
}

fn udwf(&self, name: &str) -> Result<Arc<datafusion_expr::WindowUDF>> {
not_impl_err!("Getting WindowUDF")
}

fn udfs(&self) -> std::collections::HashSet<String> {
not_impl_err!("Getting UDFs")
}
}

#[cfg(test)]
#[ctor::ctor]
fn init() {
Expand Down

0 comments on commit ead8121

Please sign in to comment.