Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved/fixed aggregate function error messages. #8977

Merged
merged 1 commit into from
Apr 8, 2022
Merged
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 @@ -54,9 +54,13 @@ public KsqlAggregateFunction createAggregateFunction(
case TIMESTAMP:
return new MaxKudaf(FUNCTION_NAME, initArgs.udafIndex(), argSchema);
default:
throw new KsqlException("No MAX aggregate function with " + argTypeList.get(0) + " "
+ "argument type exists!");

throw new KsqlException(
String.format(
"No %s aggregate function with %s argument type exists!",
FUNCTION_NAME,
argTypeList.get(0)
)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ public KsqlAggregateFunction createAggregateFunction(
case TIMESTAMP:
return new MinKudaf(FUNCTION_NAME, initArgs.udafIndex(), argSchema);
default:
throw new KsqlException("No MIN aggregate function with " + argTypeList.get(0) + " "
+ "argument type exists!");

throw new KsqlException(
String.format(
"No %s aggregate function with %s argument type exists!",
FUNCTION_NAME,
argTypeList.get(0)
)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ public KsqlAggregateFunction createAggregateFunction(
case DECIMAL:
return new DecimalSumKudaf(FUNCTION_NAME, initArgs.udafIndex(), (SqlDecimal) argSchema);
default:
throw new KsqlException("No Max aggregate function with " + argTypeList.get(0) + " "
+ " argument type exists!");

throw new KsqlException(
String.format(
"No %s aggregate function with %s argument type exists!",
FUNCTION_NAME,
argTypeList.get(0)
)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ public KsqlAggregateFunction createAggregateFunction(
Collections.singletonList(ParamTypes.STRING),
String.class);
default:
throw new KsqlException("No TOPK aggregate function with " + argumentType.get(0)
+ " argument type exists!");
throw new KsqlException(
String.format(
"No %s aggregate function with %s argument type exists!",
NAME,
argumentType.get(0)
)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ public KsqlAggregateFunction createAggregateFunction(
SchemaConverters.sqlToFunctionConverter().toFunctionType(argSchema),
SchemaConverters.sqlToJavaConverter().toJavaType(argSchema));
default:
throw new KsqlException("No TOPKDISTINCT aggregate function with " + argTypeList.get(0)
+ " argument type exists!");
throw new KsqlException(
String.format(
"No %s aggregate function with %s argument type exists!",
NAME,
argTypeList.get(0)
)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,25 @@ public void shouldThrowWhenExecutingInsertIntoTable() {
assertThat(e, statementText(is("insert into bar select * from test2;")));
}

@Test
public void shouldThrowForBadSumAggregate() {
// When:
final KsqlStatementException e = assertThrows(
KsqlStatementException.class,
() -> KsqlEngineTestUtil.executeQuery(
serviceContext,
ksqlEngine,
"SELECT 'dummy', SUM(CAST(col1 AS STRING)) FROM test1 GROUP BY 'dummy' EMIT CHANGES;",
ksqlConfig,
Collections.emptyMap()
)
);

// Then:
assertThat(e, rawMessage(containsString(
"No SUM aggregate function with STRING argument type exists!")));
}

@Test
public void shouldThrowOnInsertIntoStreamWithTableResult() {
KsqlEngineTestUtil.execute(
Expand Down