Skip to content

Commit

Permalink
chore(query): fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li committed Jan 15, 2023
1 parent d2d6ab7 commit ce44722
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/query/sql/src/planner/semantic/distinct_to_groupby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ impl VisitorMut for DistinctToGroupBy {
alias,
} = &select_list[0]
{
if (name.name.to_ascii_lowercase() == "count" && *distinct)
|| name.name.to_ascii_lowercase() == "count_distinct"
if ((name.name.to_ascii_lowercase() == "count" && *distinct)
|| name.name.to_ascii_lowercase() == "count_distinct")
&& args.iter().all(|arg| !matches!(arg, Expr::Literal { .. }))
{
let tmp_token = span[0].clone();
let subquery = Query {
Expand Down
32 changes: 32 additions & 0 deletions tests/sqllogictests/suites/mode/standalone/explain/explain.test
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,38 @@ HashJoin
├── push downs: [filters: [], limit: NONE]
└── estimated rows: 5.00

query T
explain select count(distinct a) from t1;
----
EvalScalar
├── expressions: [count() (#3)]
├── estimated rows: 1.00
└── AggregateFinal
├── group by: []
├── aggregate functions: [count()]
├── estimated rows: 1.00
└── AggregatePartial
├── group by: []
├── aggregate functions: [count()]
├── estimated rows: 1.00
└── AggregateFinal
├── group by: [a]
├── aggregate functions: []
├── estimated rows: 1.00
└── AggregatePartial
├── group by: [a]
├── aggregate functions: []
├── estimated rows: 1.00
└── TableScan
├── table: default.default.t1
├── read rows: 1
├── read bytes: 31
├── partitions total: 1
├── partitions scanned: 1
├── push downs: [filters: [], limit: NONE]
├── output columns: [0]
└── estimated rows: 1.00

query T
explain select count_distinct(a) from t1;
----
Expand Down

0 comments on commit ce44722

Please sign in to comment.