Skip to content

Commit

Permalink
Removed custom naming for DISTINCT COUNT (#39537)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9412a2e)
  • Loading branch information
astefan committed Mar 1, 2019
1 parent ba44f28 commit 06d0e0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 4 additions & 0 deletions x-pack/plugin/sql/qa/src/main/resources/agg.sql-spec
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ SELECT (emp_no % 3) + 1 AS e, (languages % 3) + 1 AS l FROM test_emp GROUP BY e,

// COUNT
aggCountImplicit
SELECT COUNT(*) FROM test_emp;
aggCountImplicitAlias
SELECT COUNT(*) AS count FROM test_emp;
aggCountImplicitWithCast
SELECT CAST(COUNT(*) AS INT) c FROM "test_emp";
Expand All @@ -109,6 +111,8 @@ SELECT gender g, CAST(COUNT(*) AS INT) c FROM "test_emp" WHERE emp_no < 10020 GR
aggCountWithAlias
SELECT gender g, COUNT(*) c FROM "test_emp" GROUP BY g ORDER BY gender;
countDistinct
SELECT COUNT(DISTINCT "hire_date") FROM test_emp;
countDistinctAlias
SELECT COUNT(DISTINCT hire_date) AS count FROM test_emp;
countDistinctAndCountSimpleWithAlias
SELECT COUNT(*) cnt, COUNT(DISTINCT first_name) as names, gender FROM test_emp GROUP BY gender ORDER BY gender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ public String functionId() {
return functionId;
}

@Override
public String name() {
if (distinct()) {
StringBuilder sb = new StringBuilder(super.name());
sb.insert(sb.indexOf("(") + 1, "DISTINCT ");
return sb.toString();
}
return super.name();
}

@Override
public AggregateFunctionAttribute toAttribute() {
// COUNT(*) gets its value from the parent aggregation on which _count is called
Expand Down

0 comments on commit 06d0e0e

Please sign in to comment.