Skip to content

Commit

Permalink
Add more user-friendly error messages for the last and last_by aggreg…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
Beyyes authored Jan 17, 2025
1 parent 3072ae5 commit 49a91ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4065,19 +4065,19 @@ public void exceptionTest() {
DATABASE_NAME);
tableAssertTestFail(
"select first() from table1",
"701: Aggregate functions [first] should only have two arguments",
"701: Aggregate functions [first] should only have one or two arguments",
DATABASE_NAME);
tableAssertTestFail(
"select first_by() from table1",
"701: Aggregate functions [first_by] should only have three arguments",
"701: Aggregate functions [first_by] should only have two or three arguments",
DATABASE_NAME);
tableAssertTestFail(
"select last() from table1",
"701: Aggregate functions [last] should only have two arguments",
"701: Aggregate functions [last] should only have one or two arguments",
DATABASE_NAME);
tableAssertTestFail(
"select last_by() from table1",
"701: Aggregate functions [last_by] should only have three arguments",
"701: Aggregate functions [last_by] should only have two or three arguments",
DATABASE_NAME);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ && isIntegerNumber(argumentTypes.get(2)))) {
if (argumentTypes.size() != 2) {
throw new SemanticException(
String.format(
"Aggregate functions [%s] should only have two arguments", functionName));
"Aggregate functions [%s] should only have one or two arguments", functionName));
} else if (!isTimestampType(argumentTypes.get(1))) {
throw new SemanticException(
String.format(
Expand All @@ -602,7 +602,8 @@ && isIntegerNumber(argumentTypes.get(2)))) {
if (argumentTypes.size() != 3) {
throw new SemanticException(
String.format(
"Aggregate functions [%s] should only have three arguments", functionName));
"Aggregate functions [%s] should only have two or three arguments",
functionName));
}
break;
case SqlConstant.MAX_BY:
Expand Down

0 comments on commit 49a91ec

Please sign in to comment.