Skip to content

Commit 5ea4f37

Browse files
committed
Fix: support Qualified Wildcard in count aggregate function
1 parent 3892499 commit 5ea4f37

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

datafusion/optimizer/src/analyzer/count_wildcard_rule.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,7 @@ impl AnalyzerRule for CountWildcardRule {
4848
}
4949

5050
fn is_wildcard(expr: &Expr) -> bool {
51-
matches!(
52-
expr,
53-
Expr::Wildcard {
54-
qualifier: None,
55-
..
56-
}
57-
)
51+
matches!(expr, Expr::Wildcard { .. })
5852
}
5953

6054
fn is_count_star_aggregate(aggregate_function: &AggregateFunction) -> bool {

datafusion/sql/src/expr/function.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
432432
qualifier: None,
433433
options: WildcardOptions::default(),
434434
}),
435+
FunctionArg::Unnamed(FunctionArgExpr::QualifiedWildcard(object_name)) => {
436+
Ok(Expr::Wildcard {
437+
qualifier: Some(self.object_name_to_table_reference(object_name)?),
438+
options: WildcardOptions::default(),
439+
})
440+
}
435441
_ => not_impl_err!("Unsupported qualified wildcard argument: {sql:?}"),
436442
}
437443
}

datafusion/sqllogictest/test_files/aggregate.slt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,11 @@ SELECT COUNT(*) FROM aggregate_test_100
11241124
----
11251125
100
11261126

1127+
query I
1128+
SELECT COUNT(aggregate_test_100.*) FROM aggregate_test_100
1129+
----
1130+
100
1131+
11271132
# csv_query_count_literal
11281133
query I
11291134
SELECT COUNT(2) FROM aggregate_test_100

0 commit comments

Comments
 (0)