Given a column reference to `column`, returns a pruning expression in terms of the min and max that will evaluate to true if the column may contain values, and false if definitely does not contain values
(
column: &phys_expr::Column,
schema: &Schema,
required_columns: &mut RequiredColumns,
is_not: bool, // if true, treat as !col
)
| 1269 | /// if the column may contain values, and false if definitely does not |
| 1270 | /// contain values |
| 1271 | fn build_single_column_expr( |
| 1272 | column: &phys_expr::Column, |
| 1273 | schema: &Schema, |
| 1274 | required_columns: &mut RequiredColumns, |
| 1275 | is_not: bool, // if true, treat as !col |
| 1276 | ) -> Option<Arc<dyn PhysicalExpr>> { |
| 1277 | let field = schema.field_with_name(column.name()).ok()?; |
| 1278 | |
| 1279 | if *field.data_type() == DataType::Boolean { |
| 1280 | let col_ref = Arc::new(column.clone()) as _; |
| 1281 | |
| 1282 | let min = required_columns |
| 1283 | .min_column_expr(column, &col_ref, field) |
| 1284 | .ok()?; |
| 1285 | let max = required_columns |
| 1286 | .max_column_expr(column, &col_ref, field) |
| 1287 | .ok()?; |
| 1288 | |
| 1289 | // remember -- we want an expression that is: |
| 1290 | // TRUE: if there may be rows that match |
| 1291 | // FALSE: if there are no rows that match |
| 1292 | if is_not { |
| 1293 | // The only way we know a column couldn't match is if both the min and max are true |
| 1294 | // !(min && max) |
| 1295 | Some(Arc::new(phys_expr::NotExpr::new(Arc::new( |
| 1296 | phys_expr::BinaryExpr::new(min, Operator::And, max), |
| 1297 | )))) |
| 1298 | } else { |
| 1299 | // the only way we know a column couldn't match is if both the min and max are false |
| 1300 | // !(!min && !max) --> min || max |
| 1301 | Some(Arc::new(phys_expr::BinaryExpr::new(min, Operator::Or, max))) |
| 1302 | } |
| 1303 | } else { |
| 1304 | None |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | /// Given an expression reference to `expr`, if `expr` is a column expression, |
| 1309 | /// returns a pruning expression in terms of IsNull that will evaluate to true |
no test coverage detected
searching dependent graphs…