|
@@ -151,6 +151,33 @@ public class CaseTests extends AbstractScalarFunctionTestCase {
|
|
|
return testCase(type, typedData, lhsOrRhs ? lhs : rhs, toStringMatcher(1, false), false, null, addWarnings(warnings));
|
|
|
})
|
|
|
);
|
|
|
+ if (type.noText() == DataType.KEYWORD) {
|
|
|
+ DataType otherType = type == DataType.KEYWORD ? DataType.TEXT : DataType.KEYWORD;
|
|
|
+ suppliers.add(
|
|
|
+ new TestCaseSupplier(
|
|
|
+ TestCaseSupplier.nameFrom(Arrays.asList(cond, type, otherType)),
|
|
|
+ List.of(DataType.BOOLEAN, type, otherType),
|
|
|
+ () -> {
|
|
|
+ Object lhs = randomLiteral(type).value();
|
|
|
+ Object rhs = randomLiteral(otherType).value();
|
|
|
+ List<TestCaseSupplier.TypedData> typedData = List.of(
|
|
|
+ cond(cond, "cond"),
|
|
|
+ new TestCaseSupplier.TypedData(lhs, type, "lhs"),
|
|
|
+ new TestCaseSupplier.TypedData(rhs, otherType, "rhs")
|
|
|
+ );
|
|
|
+ return testCase(
|
|
|
+ type,
|
|
|
+ typedData,
|
|
|
+ lhsOrRhs ? lhs : rhs,
|
|
|
+ toStringMatcher(1, false),
|
|
|
+ false,
|
|
|
+ null,
|
|
|
+ addWarnings(warnings)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
if (lhsOrRhs) {
|
|
|
suppliers.add(
|
|
|
new TestCaseSupplier(
|
|
@@ -222,7 +249,6 @@ public class CaseTests extends AbstractScalarFunctionTestCase {
|
|
|
)
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
suppliers.add(
|
|
|
new TestCaseSupplier(
|
|
|
"partial foldable " + TestCaseSupplier.nameFrom(Arrays.asList(cond, type, type)),
|
|
@@ -292,6 +318,33 @@ public class CaseTests extends AbstractScalarFunctionTestCase {
|
|
|
}
|
|
|
)
|
|
|
);
|
|
|
+ if (type.noText() == DataType.KEYWORD) {
|
|
|
+ DataType otherType = type == DataType.KEYWORD ? DataType.TEXT : DataType.KEYWORD;
|
|
|
+ suppliers.add(
|
|
|
+ new TestCaseSupplier(
|
|
|
+ TestCaseSupplier.nameFrom(Arrays.asList(DataType.NULL, type, otherType)),
|
|
|
+ List.of(DataType.NULL, type, otherType),
|
|
|
+ () -> {
|
|
|
+ Object lhs = randomLiteral(type).value();
|
|
|
+ Object rhs = randomLiteral(otherType).value();
|
|
|
+ List<TestCaseSupplier.TypedData> typedData = List.of(
|
|
|
+ new TestCaseSupplier.TypedData(null, DataType.NULL, "cond"),
|
|
|
+ new TestCaseSupplier.TypedData(lhs, type, "lhs"),
|
|
|
+ new TestCaseSupplier.TypedData(rhs, otherType, "rhs")
|
|
|
+ );
|
|
|
+ return testCase(
|
|
|
+ type,
|
|
|
+ typedData,
|
|
|
+ lhsOrRhs ? lhs : rhs,
|
|
|
+ startsWith("CaseEagerEvaluator[conditions=[ConditionEvaluator[condition="),
|
|
|
+ false,
|
|
|
+ null,
|
|
|
+ addWarnings(warnings)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
suppliers.add(
|
|
|
new TestCaseSupplier(
|
|
@@ -804,7 +857,7 @@ public class CaseTests extends AbstractScalarFunctionTestCase {
|
|
|
if (types.get(0) != DataType.BOOLEAN && types.get(0) != DataType.NULL) {
|
|
|
return typeErrorMessage(includeOrdinal, types, 0, "boolean");
|
|
|
}
|
|
|
- DataType mainType = types.get(1);
|
|
|
+ DataType mainType = types.get(1).noText();
|
|
|
for (int i = 2; i < types.size(); i++) {
|
|
|
if (i % 2 == 0 && i != types.size() - 1) {
|
|
|
// condition
|
|
@@ -813,7 +866,7 @@ public class CaseTests extends AbstractScalarFunctionTestCase {
|
|
|
}
|
|
|
} else {
|
|
|
// value
|
|
|
- if (types.get(i) != mainType) {
|
|
|
+ if (types.get(i).noText() != mainType) {
|
|
|
return typeErrorMessage(includeOrdinal, types, i, mainType.typeName());
|
|
|
}
|
|
|
}
|