You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/09/30 14:30:20 UTC
[GitHub] [arrow-datafusion] rdettai commented on a change in pull request #1063: Optimize count agg expr with null column statistics
rdettai commented on a change in pull request #1063:
URL: https://github.com/apache/arrow-datafusion/pull/1063#discussion_r719466893
##########
File path: datafusion/src/physical_optimizer/aggregate_statistics.rs
##########
@@ -153,6 +159,37 @@ fn take_optimizable_count(
None
}
+fn take_optimizable_count_with_nulls(
+ agg_expr: &dyn AggregateExpr,
+ stats: &Statistics,
+) -> Option<(ScalarValue, String)> {
+ if let (Some(num_rows), Some(col_stats), Some(casted_expr)) = (
+ stats.num_rows,
+ &stats.column_statistics,
+ agg_expr.as_any().downcast_ref::<expressions::Min>(),
+ ) {
+ if casted_expr.expressions().len() == 1 {
+ // TODO optimize with exprs other than Column
+ if let Some(col_expr) = casted_expr.expressions()[0]
+ .as_any()
+ .downcast_ref::<expressions::Column>()
+ {
+ if let ColumnStatistics {
+ null_count: Some(val),
+ ..
+ } = &col_stats[col_expr.index()]
+ {
+ return Some((
+ ScalarValue::UInt64(Some((num_rows - val) as u64)),
+ "COUNT(Uint8(1))".to_string(),
Review comment:
Shouldn't this be the column name instead of `UInt8`?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org