Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xinlifoobar committed Jul 18, 2024
1 parent e81fe1d commit 049c59d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions datafusion/optimizer/src/analyzer/type_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ use datafusion_expr::type_coercion::{is_datetime, is_utf8_or_large_utf8};
use datafusion_expr::utils::merge_schema;
use datafusion_expr::{
is_false, is_not_false, is_not_true, is_not_unknown, is_true, is_unknown, not,
type_coercion, AggregateFunction, AggregateUDF, Expr, ExprSchemable, Filter,
LogicalPlan, Operator, ScalarUDF, Signature, WindowFrame, WindowFrameBound,
WindowFrameUnits,
type_coercion, AggregateFunction, AggregateUDF, Expr, ExprSchemable, LogicalPlan,
Operator, ScalarUDF, Signature, WindowFrame, WindowFrameBound, WindowFrameUnits,
};

use crate::analyzer::AnalyzerRule;
Expand Down Expand Up @@ -104,12 +103,13 @@ fn analyze_internal(
// select t2.c2 from t1 where t1.c1 in (select t2.c1 from t2 where t2.c2=t1.c3)
schema.merge(external_schema);

if let LogicalPlan::Filter(Filter {
predicate, input, ..
}) = &plan
{
if let Ok(predicate) = predicate.clone().cast_to(&DataType::Boolean, &schema) {
plan = LogicalPlan::Filter(Filter::try_new(predicate, Arc::clone(input))?);
if let LogicalPlan::Filter(filter) = &mut plan {
if let Ok(new_predicate) = filter
.predicate
.clone()
.cast_to(&DataType::Boolean, filter.input.schema())
{
filter.predicate = new_predicate;
}
}

Expand Down
3 changes: 2 additions & 1 deletion datafusion/physical-plan/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,14 @@ pub(crate) fn batch_filter(
.and_then(|v| v.into_array(batch.num_rows()))
.and_then(|array| {
Ok(match as_boolean_array(&array) {
// apply filter array to record batch
Ok(filter_array) => filter_record_batch(batch, filter_array)?,
Err(_) => {
return internal_err!(
"Cannot create filter_array from non-boolean predicates"
);
}
}) // apply filter array to record batch
})
})
}

Expand Down
1 change: 1 addition & 0 deletions datafusion/sqllogictest/test_files/misc.slt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ select 'foo', '', NULL
----
foo (empty) NULL

# Where clause accept NULL literal
query I
select 1 where NULL
----
Expand Down

0 comments on commit 049c59d

Please sign in to comment.