-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: Correct null_count in describe() #10260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
f47ff6c
eeebda4
98784c5
3a22207
de67422
ec5fe18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 |", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that certainly looks better |
||
| "| mean | 3649.5 | null | 4.5 | 4.5 | 4.5 | 45.0 | 4.949999964237213 | 45.45 | null | null | null | 2009.5 | 6.526027397260274 |", | ||
| "| std | 2107.472815166704 | null | 2.8724780750809518 | 2.8724780750809518 | 2.8724780750809518 | 28.724780750809533 | 3.1597258182544645 | 29.012028558317645 | null | null | null | 0.5000342500942125 | 3.44808750051728 |", | ||
| "| min | 0.0 | null | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 01/01/09 | 0 | 2008-12-31T23:00:00 | 2009.0 | 1.0 |", | ||
|
|
@@ -69,7 +69,7 @@ async fn describe_boolean_binary() -> Result<()> { | |
| "| describe | a | b |", | ||
| "+------------+------+------+", | ||
| "| count | 1 | 1 |", | ||
| "| null_count | 1 | 1 |", | ||
| "| null_count | 0 | 0 |", | ||
| "| mean | null | null |", | ||
| "| std | null | null |", | ||
| "| min | a | null |", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -215,6 +215,18 @@ pub fn count(expr: Expr) -> Expr { | |||||
| )) | ||||||
| } | ||||||
|
|
||||||
| /// Create an expression to represent the COUNT(IS NULL x) aggregate function | ||||||
|
||||||
| /// Create an expression to represent the COUNT(IS NULL x) aggregate function | |
| /// Create an aggregate that returns the number `NULL` values in a column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a
count_null()new function, what do you think about using the existingcountfunction?Something like
count(expr.is_null())There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using
count, it sums allnon-nullExpr whileis_nullconvertsExprto a boolean expression, which is why it doesn't work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Make sense to me. Another classic trick is to use a CASE expression, something like