Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
* @author Yanming Zhou
* @author Alim Naizabek
* @author Jakub Soltys
* @author Young-ho Kim
*/
public abstract class QueryUtils {

Expand Down Expand Up @@ -184,7 +185,7 @@ public abstract class QueryUtils {

builder = new StringBuilder();
// any function call including parameters within the brackets
builder.append("\\w+\\s*\\([\\w\\.,\\s'=:;\\\\?]+\\)");
builder.append("\\w+\\s*\\([\\w\\.,\\s'=:;\\\\?\\*]+\\)");
// the potential alias
builder.append("\\s+(?:as)+\\s+([\\w\\.]+)");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* @author Pranav HS
* @author Eduard Dudar
* @author Mark Paluch
* @author Young-ho Kim
*/
class QueryUtilsUnitTests {

Expand Down Expand Up @@ -560,6 +561,13 @@ void discoversFunctionAliasesCorrectly() {
assertThat(getFunctionAliases("COUNT(1) as alias1, 2 as alias2")).containsExactly("alias1");
}

@Test // GH-4242
void discoversCountStarFunctionAlias() {

assertThat(getFunctionAliases("SELECT COUNT(*) as total FROM User u")).containsExactly("total");
assertThat(getFunctionAliases("SELECT u, COUNT(*) as cnt FROM User u GROUP BY u")).containsExactly("cnt");
}

@Test // GH-3911
void discoversFieldAliasesCorrectly() {

Expand Down
Loading