risingwave_frontend/optimizer/rule/batch/
batch_iceberg_count_star.rs1use risingwave_pb::batch_plan::iceberg_scan_node::IcebergScanType;
16
17use super::prelude::*;
18use crate::optimizer::plan_node::{BatchIcebergScan, PlanAggCall};
19
20pub struct BatchIcebergCountStar {}
21
22impl Rule<Batch> for BatchIcebergCountStar {
23 fn apply(&self, plan: PlanRef) -> Option<PlanRef> {
24 let agg = plan.as_batch_simple_agg()?;
25 if agg.core.group_key.is_empty()
26 && agg.agg_calls().len() == 1
27 && agg.agg_calls()[0].eq(&PlanAggCall::count_star())
28 {
29 let batch_iceberg = agg.core.input.as_batch_iceberg_scan()?;
30 if batch_iceberg.iceberg_scan_type() != IcebergScanType::DataScan {
31 return None;
32 }
33 return Some(
34 BatchIcebergScan::new_count_star_with_batch_iceberg_scan(batch_iceberg).into(),
35 );
36 }
37 None
38 }
39}
40
41impl BatchIcebergCountStar {
42 pub fn create() -> BoxedRule {
43 Box::new(BatchIcebergCountStar {})
44 }
45}