[Improve](InPredict) enhance in predict with array type (#31828)
This commit is contained in:
@ -86,6 +86,18 @@ public class InPredicate extends Expression {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (children().get(0).getDataType().isArrayType()) {
|
||||
// we should check in value list is all list type
|
||||
for (int i = 1; i < children().size(); i++) {
|
||||
if (!children().get(i).getDataType().isArrayType() && !children().get(i).getDataType().isNullType()) {
|
||||
throw new AnalysisException("in predicate list should compare with struct type list, but got : "
|
||||
+ children().get(i).getDataType().toSql());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
children().forEach(c -> {
|
||||
if (c.getDataType().isObjectType()) {
|
||||
throw new AnalysisException("in predicate could not contains object type: " + this.toSql());
|
||||
|
||||
@ -954,7 +954,8 @@ public class TypeCoercionUtils {
|
||||
if (inPredicate.getOptions().stream().map(Expression::getDataType)
|
||||
.allMatch(dt -> dt.equals(inPredicate.getCompareExpr().getDataType()))) {
|
||||
if (!supportCompare(inPredicate.getCompareExpr().getDataType())
|
||||
&& !inPredicate.getCompareExpr().getDataType().isStructType()) {
|
||||
&& !inPredicate.getCompareExpr().getDataType().isStructType() && !inPredicate.getCompareExpr()
|
||||
.getDataType().isArrayType()) {
|
||||
throw new AnalysisException("data type " + inPredicate.getCompareExpr().getDataType()
|
||||
+ " could not used in InPredicate " + inPredicate.toSql());
|
||||
}
|
||||
@ -970,8 +971,13 @@ public class TypeCoercionUtils {
|
||||
throw new AnalysisException("data type " + optionalCommonType.get()
|
||||
+ " is not match " + inPredicate.getCompareExpr().getDataType() + " used in InPredicate");
|
||||
}
|
||||
if (inPredicate.getCompareExpr().getDataType().isArrayType() && optionalCommonType.isPresent()
|
||||
&& !optionalCommonType.get().isArrayType()) {
|
||||
throw new AnalysisException("data type " + optionalCommonType.get()
|
||||
+ " is not match " + inPredicate.getCompareExpr().getDataType() + " used in InPredicate");
|
||||
}
|
||||
if (optionalCommonType.isPresent() && !supportCompare(optionalCommonType.get())
|
||||
&& !optionalCommonType.get().isStructType()) {
|
||||
&& !optionalCommonType.get().isStructType() && !optionalCommonType.get().isArrayType()) {
|
||||
throw new AnalysisException("data type " + optionalCommonType.get()
|
||||
+ " could not used in InPredicate " + inPredicate.toSql());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user