Skip to content

Commit

Permalink
Minor: some cosmetics in filter.rs, fix clippy due to logical confl…
Browse files Browse the repository at this point in the history
…ict (apache#11368)

* Minor: some cosmetics in `filter.rs`

* Minor: some cosmetics in `filter.rs`
  • Loading branch information
comphead authored and xinlifoobar committed Jul 18, 2024
1 parent 8ba2fbb commit 6d1e0c7
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions datafusion/physical-plan/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
// specific language governing permissions and limitations
// under the License.

//! FilterExec evaluates a boolean predicate against all input batches to determine which rows to
//! include in its output batches.

use std::any::Any;
use std::pin::Pin;
use std::sync::Arc;
Expand Down Expand Up @@ -60,7 +57,7 @@ pub struct FilterExec {
input: Arc<dyn ExecutionPlan>,
/// Execution metrics
metrics: ExecutionPlanMetricsSet,
/// Selectivity for statistics. 0 = no rows, 100 all rows
/// Selectivity for statistics. 0 = no rows, 100 = all rows
default_selectivity: u8,
cache: PlanProperties,
}
Expand Down Expand Up @@ -91,14 +88,14 @@ impl FilterExec {

Ok(Self {
predicate,
input: input.clone(),
input: Arc::clone(&input),
metrics: ExecutionPlanMetricsSet::new(),
default_selectivity,
cache,
})
}
other => {
plan_err!("Filter predicate must return boolean values, not {other:?}")
plan_err!("Filter predicate must return BOOLEAN values, got {other:?}")
}
}
}
Expand All @@ -108,7 +105,9 @@ impl FilterExec {
default_selectivity: u8,
) -> Result<Self, DataFusionError> {
if default_selectivity > 100 {
return plan_err!("Default filter selectivity needs to be less than 100");
return plan_err!(
"Default filter selectivity value needs to be less than or equal to 100"
);
}
self.default_selectivity = default_selectivity;
Ok(self)
Expand Down Expand Up @@ -369,12 +368,12 @@ pub(crate) fn batch_filter(
.and_then(|v| v.into_array(batch.num_rows()))
.and_then(|array| {
let filter_array = match as_boolean_array(&array) {
Ok(boolean_array) => {
Ok(boolean_array.to_owned())
},
Ok(boolean_array) => Ok(boolean_array.to_owned()),
Err(_) => {
let Ok(null_array) = as_null_array(&array) else {
return internal_err!("Cannot create filter_array from non-boolean predicates, unable to continute");
return internal_err!(
"Cannot create filter_array from non-boolean predicates"
);
};

// if the predicate is null, then the result is also null
Expand Down

0 comments on commit 6d1e0c7

Please sign in to comment.