[Feature] Support Array Type compare function for nereids planner (#31701)

Support Array Type compare function for nereids planner
This commit is contained in:
koarz
2024-03-20 20:11:57 +08:00
committed by yiguolei
parent 6d076f9947
commit 8e3d28b93a
6 changed files with 163 additions and 8 deletions

View File

@ -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

View File

@ -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());
}
});

View File

@ -1635,6 +1635,9 @@ public class TypeCoercionUtils {
}
private static boolean supportCompare(DataType dataType) {
if (dataType.isArrayType()) {
return true;
}
if (!(dataType instanceof PrimitiveType)) {
return false;
}