Convert a leaf predicate to a Vortex expression.
(
_column: &str,
index: usize,
op: PredicateOperator,
literals: &[Datum],
file_fields: &[DataField],
)
| 279 | |
| 280 | /// Convert a leaf predicate to a Vortex expression. |
| 281 | fn leaf_to_vortex_expr( |
| 282 | _column: &str, |
| 283 | index: usize, |
| 284 | op: PredicateOperator, |
| 285 | literals: &[Datum], |
| 286 | file_fields: &[DataField], |
| 287 | ) -> Option<Expression> { |
| 288 | let file_field = file_fields.get(index)?; |
| 289 | // Use the file-level column name for the Vortex expression. |
| 290 | let column_expr = col(file_field.name()); |
| 291 | |
| 292 | match op { |
| 293 | PredicateOperator::IsNull => Some(is_null(column_expr)), |
| 294 | PredicateOperator::IsNotNull => Some(not(is_null(column_expr))), |
| 295 | PredicateOperator::Eq => { |
| 296 | let v = datum_to_vortex_lit(literals.first()?, file_field)?; |
| 297 | Some(eq(column_expr, v)) |
| 298 | } |
| 299 | PredicateOperator::NotEq => { |
| 300 | let v = datum_to_vortex_lit(literals.first()?, file_field)?; |
| 301 | Some(not_eq(column_expr, v)) |
| 302 | } |
| 303 | PredicateOperator::Lt => { |
| 304 | let v = datum_to_vortex_lit(literals.first()?, file_field)?; |
| 305 | Some(lt(column_expr, v)) |
| 306 | } |
| 307 | PredicateOperator::LtEq => { |
| 308 | let v = datum_to_vortex_lit(literals.first()?, file_field)?; |
| 309 | Some(lt_eq(column_expr, v)) |
| 310 | } |
| 311 | PredicateOperator::Gt => { |
| 312 | let v = datum_to_vortex_lit(literals.first()?, file_field)?; |
| 313 | Some(gt(column_expr, v)) |
| 314 | } |
| 315 | PredicateOperator::GtEq => { |
| 316 | let v = datum_to_vortex_lit(literals.first()?, file_field)?; |
| 317 | Some(gt_eq(column_expr, v)) |
| 318 | } |
| 319 | PredicateOperator::In => { |
| 320 | // OR of eq for each literal value. |
| 321 | // All literals must be convertible; otherwise skip the entire predicate |
| 322 | // to avoid incorrectly filtering out rows that match unconverted literals. |
| 323 | let exprs: Vec<Expression> = literals |
| 324 | .iter() |
| 325 | .map(|d| datum_to_vortex_lit(d, file_field).map(|v| eq(col(file_field.name()), v))) |
| 326 | .collect::<Option<Vec<_>>>()?; |
| 327 | or_collect(exprs) |
| 328 | } |
| 329 | PredicateOperator::NotIn => { |
| 330 | // AND of not_eq for each literal value. |
| 331 | // All literals must be convertible; otherwise skip the entire predicate |
| 332 | // to avoid incorrectly keeping rows that match unconverted literals. |
| 333 | let exprs: Vec<Expression> = literals |
| 334 | .iter() |
| 335 | .map(|d| { |
| 336 | datum_to_vortex_lit(d, file_field).map(|v| not_eq(col(file_field.name()), v)) |
| 337 | }) |
| 338 | .collect::<Option<Vec<_>>>()?; |
no test coverage detected