alamb commented on code in PR #10260:
URL: https://github.com/apache/datafusion/pull/10260#discussion_r1581819093
##########
datafusion/expr/src/expr_fn.rs:
##########
@@ -215,6 +215,18 @@ pub fn count(expr: Expr) -> Expr {
))
}
+/// Create an expression to represent the count_null() aggregate function
Review Comment:
I think this function is creating a function like `COUNT(IS NULL x)` rather
than a `count_null` function
##########
datafusion/core/tests/dataframe/describe.rs:
##########
@@ -39,7 +39,7 @@ async fn describe() -> Result<()> {
"| describe | id | bool_col | tinyint_col |
smallint_col | int_col | bigint_col | float_col
| double_col | date_string_col | string_col | timestamp_col
| year | month |",
"+------------+-------------------+----------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+-----------------+------------+-------------------------+--------------------+-------------------+",
"| count | 7300.0 | 7300 | 7300.0 |
7300.0 | 7300.0 | 7300.0 | 7300.0
| 7300.0 | 7300 | 7300 | 7300
| 7300.0 | 7300.0 |",
- "| null_count | 7300.0 | 7300 | 7300.0 |
7300.0 | 7300.0 | 7300.0 | 7300.0
| 7300.0 | 7300 | 7300 | 7300
| 7300.0 | 7300.0 |",
+ "| null_count | 0.0 | 0 | 0.0 |
0.0 | 0.0 | 0.0 | 0.0
| 0.0 | 0 | 0 | 0
| 0.0 | 0.0 |",
Review Comment:
that certainly looks better
##########
datafusion/core/src/dataframe/mod.rs:
##########
@@ -534,7 +534,7 @@ impl DataFrame {
vec![],
original_schema_fields
.clone()
- .map(|f| count(is_null(col(f.name()))).alias(f.name()))
+ .map(|f| count_null(col(f.name())).alias(f.name()))
Review Comment:
Instead of a `count_null()` new function, what do you think about using the
existing
[`count`](https://docs.rs/datafusion/latest/datafusion/logical_expr/fn.count.html)
function?
Something like `count(expr.is_null())`
```suggestion
.map(|f| count(col(f.name()).is_null()).alias(f.name())))
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]