Jay-ju commented on code in PR #67051:
URL: https://github.com/apache/doris/pull/67051#discussion_r3885694302
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/lance/source/LancePredicateConverter.java:
##########
@@ -257,6 +268,60 @@ private Optional<Expression> convertIsNull(IsNullPredicate
predicate) {
return Optional.of(comparisonFunction(function,
fieldReference(field)));
}
+ private Optional<Expression> convertLike(LikePredicate predicate) {
+ if (predicate.getOp() != LikePredicate.Operator.LIKE) {
+ return Optional.empty();
+ }
+ return convertStringPredicate("like:str_str", predicate.getChild(0),
predicate.getChild(1), true);
+ }
+
+ private Optional<Expression> convertStringFunction(FunctionCallExpr
function) {
+ if (function.getFnName() == null || function.getChildren().size() !=
2) {
+ return Optional.empty();
+ }
+ String functionName =
function.getFnName().getFunction().toLowerCase(Locale.ROOT);
+ switch (functionName) {
+ case "like":
+ return convertStringPredicate(
+ "like:str_str", function.getChild(0),
function.getChild(1), true);
+ case "starts_with":
+ return convertStringPredicate(
+ "starts_with:str_str", function.getChild(0),
function.getChild(1), false);
+ case "ends_with":
+ return convertStringPredicate(
+ "ends_with:str_str", function.getChild(0),
function.getChild(1), false);
+ default:
+ return Optional.empty();
+ }
+ }
+
+ private Optional<Expression> convertStringPredicate(
+ String function, Expr input, Expr pattern, boolean
rejectEscapedPattern) {
+ SlotRef slot = directSlot(input);
+ LiteralExpr literal = directLiteral(pattern);
+ ResolvedField field = slot == null ? null : findField(slot);
+ if (field == null || !isStringType(field.field.getType()) || !(literal
instanceof StringLiteral)) {
+ return Optional.empty();
+ }
+ String patternValue = literal.getStringValue();
+ // Doris uses backslash as LIKE's default escape character, while the
Substrait function
+ // has no escape argument. Keep escaped LIKE patterns in Doris rather
than changing meaning.
+ if (rejectEscapedPattern && patternValue.indexOf('\\') >= 0) {
Review Comment:
Fixed in f613605eaf8. String predicates containing an embedded NUL now
remain residual. Added unit coverage for both LikePredicate and
FunctionCallExpr forms, plus an end-to-end regression query that checks the
residual plan and Doris result.
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/lance/source/LancePredicateConverter.java:
##########
@@ -257,6 +268,60 @@ private Optional<Expression> convertIsNull(IsNullPredicate
predicate) {
return Optional.of(comparisonFunction(function,
fieldReference(field)));
}
+ private Optional<Expression> convertLike(LikePredicate predicate) {
+ if (predicate.getOp() != LikePredicate.Operator.LIKE) {
+ return Optional.empty();
+ }
+ return convertStringPredicate("like:str_str", predicate.getChild(0),
predicate.getChild(1), true);
+ }
+
+ private Optional<Expression> convertStringFunction(FunctionCallExpr
function) {
+ if (function.getFnName() == null || function.getChildren().size() !=
2) {
+ return Optional.empty();
+ }
+ String functionName =
function.getFnName().getFunction().toLowerCase(Locale.ROOT);
Review Comment:
Fixed in f613605eaf8. FunctionCallExpr pushdown now requires a resolved
Doris BUILTIN function; unresolved functions and same-named UDFs remain as
Doris residuals. Added a unit case with a resolved JAVA_UDF named starts_with.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]