Skip to content

Commit

Permalink
Fix: support Qualified Wildcard in count aggregate function
Browse files Browse the repository at this point in the history
  • Loading branch information
HuSen8891 committed Sep 29, 2024
1 parent 3892499 commit 5ea4f37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 1 addition & 7 deletions datafusion/optimizer/src/analyzer/count_wildcard_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ impl AnalyzerRule for CountWildcardRule {
}

fn is_wildcard(expr: &Expr) -> bool {
matches!(
expr,
Expr::Wildcard {
qualifier: None,
..
}
)
matches!(expr, Expr::Wildcard { .. })
}

fn is_count_star_aggregate(aggregate_function: &AggregateFunction) -> bool {
Expand Down
6 changes: 6 additions & 0 deletions datafusion/sql/src/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
qualifier: None,
options: WildcardOptions::default(),
}),
FunctionArg::Unnamed(FunctionArgExpr::QualifiedWildcard(object_name)) => {
Ok(Expr::Wildcard {
qualifier: Some(self.object_name_to_table_reference(object_name)?),
options: WildcardOptions::default(),
})
}
_ => not_impl_err!("Unsupported qualified wildcard argument: {sql:?}"),
}
}
Expand Down
5 changes: 5 additions & 0 deletions datafusion/sqllogictest/test_files/aggregate.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,11 @@ SELECT COUNT(*) FROM aggregate_test_100
----
100

query I
SELECT COUNT(aggregate_test_100.*) FROM aggregate_test_100
----
100

# csv_query_count_literal
query I
SELECT COUNT(2) FROM aggregate_test_100
Expand Down

0 comments on commit 5ea4f37

Please sign in to comment.