Convert a single Paimon `Predicate` tree node into a Vortex `Expression`.
(
predicate: &Predicate,
file_fields: &[DataField],
)
| 242 | |
| 243 | /// Convert a single Paimon `Predicate` tree node into a Vortex `Expression`. |
| 244 | fn predicate_to_vortex_expr( |
| 245 | predicate: &Predicate, |
| 246 | file_fields: &[DataField], |
| 247 | ) -> Option<Expression> { |
| 248 | match predicate { |
| 249 | Predicate::AlwaysTrue => Some(lit(true)), |
| 250 | Predicate::AlwaysFalse => Some(lit(false)), |
| 251 | Predicate::And(children) => { |
| 252 | // Dropping unconvertible children is safe for AND: it makes the filter |
| 253 | // less restrictive, so no matching rows are incorrectly excluded. |
| 254 | let exprs: Vec<Expression> = children |
| 255 | .iter() |
| 256 | .filter_map(|c| predicate_to_vortex_expr(c, file_fields)) |
| 257 | .collect(); |
| 258 | and_collect(exprs) |
| 259 | } |
| 260 | Predicate::Or(children) => { |
| 261 | // All children must be convertible; otherwise skip the entire OR |
| 262 | // to avoid incorrectly filtering out rows that match unconverted branches. |
| 263 | let exprs: Vec<Expression> = children |
| 264 | .iter() |
| 265 | .map(|c| predicate_to_vortex_expr(c, file_fields)) |
| 266 | .collect::<Option<Vec<_>>>()?; |
| 267 | or_collect(exprs) |
| 268 | } |
| 269 | Predicate::Not(inner) => predicate_to_vortex_expr(inner, file_fields).map(not), |
| 270 | Predicate::Leaf { |
| 271 | column, |
| 272 | index, |
| 273 | op, |
| 274 | literals, |
| 275 | .. |
| 276 | } => leaf_to_vortex_expr(column, *index, *op, literals, file_fields), |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | /// Convert a leaf predicate to a Vortex expression. |
| 281 | fn leaf_to_vortex_expr( |