appletreeisyellow commented on code in PR #9223:
URL: https://github.com/apache/arrow-datafusion/pull/9223#discussion_r1525651339
##########
datafusion/core/src/physical_optimizer/pruning.rs:
##########
@@ -1320,14 +1457,56 @@ fn build_statistics_expr(
);
}
};
+ let statistics_expr = wrap_case_expr(statistics_expr, expr_builder)?;
Ok(statistics_expr)
}
+/// Wrap the statistics expression in a case expression.
+/// This is necessary to handle the case where the column is known
+/// to be all nulls.
+///
+/// For example:
+///
+/// `x_min <= 10 AND 10 <= x_max`
+///
+/// will become
+///
+/// ```sql
+/// CASE
+/// WHEN x_null_count = x_row_count THEN false
+/// ELSE x_min <= 10 AND 10 <= x_max
+/// END
+/// ````
+///
+/// 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
+/// case expression to return false. Therefore, prune out the container.
+fn wrap_case_expr(
Review Comment:
I will consider it in a follow-up PR 👍
Tracked in
https://github.com/apache/arrow-datafusion/issues/9171#issuecomment-1998518531
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]