From e60b4e473e07d3fd585208d6e3bdf47fcc9d98b1 Mon Sep 17 00:00:00 2001 From: Noel Kwan Date: Fri, 8 Nov 2024 22:17:50 +0800 Subject: [PATCH] prune BatchFilter if predicate always true --- .../rule/batch/batch_iceberg_predicate_pushdown.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/optimizer/rule/batch/batch_iceberg_predicate_pushdown.rs b/src/frontend/src/optimizer/rule/batch/batch_iceberg_predicate_pushdown.rs index cc6a23ca3936c..8df8777d59384 100644 --- a/src/frontend/src/optimizer/rule/batch/batch_iceberg_predicate_pushdown.rs +++ b/src/frontend/src/optimizer/rule/batch/batch_iceberg_predicate_pushdown.rs @@ -45,13 +45,17 @@ impl Rule for BatchIcebergPredicatePushDownRule { assert_eq!(scan.predicate, IcebergPredicate::AlwaysTrue); let predicate = filter.predicate().clone(); - let (iceberg_predicate, new_predicate) = + let (iceberg_predicate, rw_predicate) = rw_predicate_to_iceberg_predicate(predicate, scan.schema().fields()); let scan = scan.clone_with_predicate(iceberg_predicate); - let filter = filter - .clone_with_input(scan.into()) - .clone_with_predicate(new_predicate); - Some(filter.into()) + if rw_predicate.always_true() { + Some(scan.into()) + } else { + let filter = filter + .clone_with_input(scan.into()) + .clone_with_predicate(rw_predicate); + Some(filter.into()) + } } }