Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -159,6 +159,10 @@ public void testKind1OutputTypeRestrict() {
"select case when s1<=0 then true else 22 end from table1",
"701: All CASE results must be the same type or coercible to a common type. Cannot find common type between BOOLEAN and INT32, all types (without duplicates): [BOOLEAN, INT32]",
DATABASE);
tableAssertTestFail(
"select case when s1<=0 then 0 when s1>1 then null end from table1",
"701: All result types must be the same:",
DATABASE);

// TEXT and other types cannot exist at the same time
retArray = new String[] {"good,", "bad,", "okok,", "okok,"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ protected Type visitSearchedCaseExpression(SearchedCaseExpression node, Context
})
.collect(Collectors.toSet());

checkArgument(resultTypes.size() == 1, "All result types must be the same: %s", resultTypes);
if (resultTypes.size() != 1) {
throw new SemanticException(
String.format("All result types must be the same: %s", resultTypes));
}
Type resultType = resultTypes.iterator().next();
node.getDefaultValue()
.ifPresent(
Expand Down Expand Up @@ -275,7 +278,11 @@ protected Type visitSimpleCaseExpression(SimpleCaseExpression node, Context cont
})
.collect(Collectors.toSet());

checkArgument(resultTypes.size() == 1, "All result types must be the same: %s", resultTypes);
if (resultTypes.size() != 1) {
throw new SemanticException(
String.format("All result types must be the same: %s", resultTypes));
}

Type resultType = resultTypes.iterator().next();
node.getDefaultValue()
.ifPresent(
Expand Down
Loading