wrap_null_count_check_expr

Function wrap_null_count_check_expr 

Source
fn wrap_null_count_check_expr(
    statistics_expr: Arc<dyn PhysicalExpr>,
    expr_builder: &mut PruningExpressionBuilder<'_>,
) -> Result<Arc<dyn PhysicalExpr>>
Expand description

Wrap the statistics expression in a check that skips the expression if the column is all nulls.

This is important not only as an optimization but also because statistics may not be accurate for columns that are all nulls. For example, for an int column x with all nulls, the min/max/null_count statistics might be set to 0 and evaluating x = 0 would incorrectly include the column.

For example:

x_min <= 10 AND 10 <= x_max

will become

x_null_count != x_row_count AND (x_min <= 10 AND 10 <= x_max)

If the column is known to be all nulls, then the expression x_null_count = x_row_count will be true, which will cause the boolean expression to return false. Therefore, prune out the container.