[Feature] Support Array Type compare function for nereids planner (#31701)
Support Array Type compare function for nereids planner
This commit is contained in:
@ -99,7 +99,14 @@ public class ArrayLiteral extends LiteralExpr {
|
||||
|
||||
@Override
|
||||
public int compareLiteral(LiteralExpr expr) {
|
||||
return 0;
|
||||
int size = Math.min(expr.getChildren().size(), this.children.size());
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (((LiteralExpr) (this.getChild(i))).compareTo((LiteralExpr) (expr.getChild(i))) != 0) {
|
||||
return ((LiteralExpr) (this.getChild(i))).compareTo((LiteralExpr) (expr.getChild(i)));
|
||||
}
|
||||
}
|
||||
return this.children.size() > expr.getChildren().size() ? 1 :
|
||||
(this.children.size() == expr.getChildren().size() ? 0 : -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -62,7 +62,7 @@ public abstract class ComparisonPredicate extends BinaryOperator {
|
||||
@Override
|
||||
public void checkLegalityBeforeTypeCoercion() {
|
||||
children().forEach(c -> {
|
||||
if (c.getDataType().isComplexType()) {
|
||||
if (c.getDataType().isComplexType() && !c.getDataType().isArrayType()) {
|
||||
throw new AnalysisException("comparison predicate could not contains complex type: " + this.toSql());
|
||||
}
|
||||
});
|
||||
|
||||
@ -1635,6 +1635,9 @@ public class TypeCoercionUtils {
|
||||
}
|
||||
|
||||
private static boolean supportCompare(DataType dataType) {
|
||||
if (dataType.isArrayType()) {
|
||||
return true;
|
||||
}
|
||||
if (!(dataType instanceof PrimitiveType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user