Skip to content

Commit 1976441

Browse files
committed
Removed custom naming for DISTINCT COUNT (#39537)
(cherry picked from commit 9412a2e)
1 parent 185054c commit 1976441

File tree

2 files changed

+4
-10
lines changed
  • x-pack/plugin/sql
    • qa/src/main/resources
    • src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate

2 files changed

+4
-10
lines changed

x-pack/plugin/sql/qa/src/main/resources/agg.sql-spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ SELECT (emp_no % 3) + 1 AS e, (languages % 3) + 1 AS l FROM test_emp GROUP BY e,
8989

9090
// COUNT
9191
aggCountImplicit
92+
SELECT COUNT(*) FROM test_emp;
93+
aggCountImplicitAlias
9294
SELECT COUNT(*) AS count FROM test_emp;
9395
aggCountImplicitWithCast
9496
SELECT CAST(COUNT(*) AS INT) c FROM "test_emp";
@@ -109,6 +111,8 @@ SELECT gender g, CAST(COUNT(*) AS INT) c FROM "test_emp" WHERE emp_no < 10020 GR
109111
aggCountWithAlias
110112
SELECT gender g, COUNT(*) c FROM "test_emp" GROUP BY g ORDER BY gender;
111113
countDistinct
114+
SELECT COUNT(DISTINCT "hire_date") FROM test_emp;
115+
countDistinctAlias
112116
SELECT COUNT(DISTINCT hire_date) AS count FROM test_emp;
113117
countDistinctAndCountSimpleWithAlias
114118
SELECT COUNT(*) cnt, COUNT(DISTINCT first_name) as names, gender FROM test_emp GROUP BY gender ORDER BY gender;

x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/aggregate/Count.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ public String functionId() {
6363
return functionId;
6464
}
6565

66-
@Override
67-
public String name() {
68-
if (distinct()) {
69-
StringBuilder sb = new StringBuilder(super.name());
70-
sb.insert(sb.indexOf("(") + 1, "DISTINCT ");
71-
return sb.toString();
72-
}
73-
return super.name();
74-
}
75-
7666
@Override
7767
public AggregateFunctionAttribute toAttribute() {
7868
// COUNT(*) gets its value from the parent aggregation on which _count is called

0 commit comments

Comments
 (0)