Skip to content

Commit

Permalink
[enhancement](paimon)support predict for null and notnull (apache#29134)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwenchi authored and HappenLee committed Jan 12, 2024
1 parent 6cecb5f commit 12629b0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.doris.analysis.CompoundPredicate;
import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.FunctionCallExpr;
import org.apache.doris.analysis.IsNullPredicate;
import org.apache.doris.analysis.LiteralExpr;
import org.apache.doris.analysis.SlotRef;
import org.apache.doris.thrift.TExprOpcode;
Expand Down Expand Up @@ -70,10 +71,16 @@ public Predicate convertToPaimonExpr(Expr dorisExpr) {

switch (compoundPredicate.getOp()) {
case AND: {
return PredicateBuilder.and(left, right);
if (left != null && right != null) {
return PredicateBuilder.and(left, right);
}
return null;
}
case OR: {
return PredicateBuilder.or(left, right);
if (left != null && right != null) {
return PredicateBuilder.or(left, right);
}
return null;
}
default:
return null;
Expand Down Expand Up @@ -120,6 +127,12 @@ private Predicate binaryExprDesc(Expr dorisExpr) {
if (name.equals("like") && !s.startsWith("%") && s.endsWith("%")) {
return builder.startsWith(idx, BinaryString.fromString(s.substring(0, s.length() - 1)));
}
} else if (dorisExpr instanceof IsNullPredicate) {
if (((IsNullPredicate) dorisExpr).isNotNull()) {
return builder.isNotNull(idx);
} else {
return builder.isNull(idx);
}
}
return null;
default:
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ suite("test_paimon_catalog", "p0,external,doris,external_docker,external_docker_

def c100= """select * from array_nested order by c1;"""

def c101="""select * from all_table where c1 is not null or c2 is not null order by c1"""

String hdfs_port = context.config.otherConfigs.get("hdfs_port")
String catalog_name = "paimon1"
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
Expand Down Expand Up @@ -284,6 +286,7 @@ suite("test_paimon_catalog", "p0,external,doris,external_docker,external_docker_
qt_c98 c98
qt_c99 c99
qt_c100 c100
qt_c101 c101

// test view from jion paimon
sql """ switch internal """
Expand Down

0 comments on commit 12629b0

Please sign in to comment.