You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/07/14 08:54:50 UTC

[GitHub] [doris] yinzhijian opened a new pull request, #10847: [enhancement](nereids) support substring

yinzhijian opened a new pull request, #10847:
URL: https://github.com/apache/doris/pull/10847

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem Summary:
   support substring, for example:
   select substr(a, 2), substring(b ,3 ,4) from test1; 
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: (No)
   2. Has unit tests been added: (Yes)
   3. Has document been added or modified: (No Need)
   4. Does it need to update dependencies: (No)
   5. Are there any changes that cannot be rolled back: (No)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] adonis0147 commented on a diff in pull request #10847: [enhancement](nereids) support substring

Posted by GitBox <gi...@apache.org>.
adonis0147 commented on code in PR #10847:
URL: https://github.com/apache/doris/pull/10847#discussion_r920950490


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java:
##########
@@ -190,6 +192,25 @@ public Expr visitCompoundPredicate(CompoundPredicate compoundPredicate, PlanTran
                 compoundPredicate.child(1).accept(this, context));
     }
 
+    @Override
+    public Expr visitStringRegexPredicate(StringRegexPredicate stringRegexPredicate, PlanTranslatorContext context) {
+        NodeType nodeType = stringRegexPredicate.getType();
+        org.apache.doris.analysis.LikePredicate.Operator staleOp;
+        switch (nodeType) {
+            case LIKE:
+                staleOp = LikePredicate.Operator.LIKE;
+                break;
+            case REGEXP:
+                staleOp = LikePredicate.Operator.REGEXP;
+                break;
+            default:
+                throw new AnalysisException(String.format("Unknown node type: %s", nodeType.name()));
+        }
+        return new org.apache.doris.analysis.LikePredicate(staleOp,
+                stringRegexPredicate.child(0).accept(this, context),
+                stringRegexPredicate.child(1).accept(this, context));

Review Comment:
   It is better to use `left()` and `right()` instead of `child(0)` and `child(1)`.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] EmmyMiao87 merged pull request #10847: [enhancement](nereids) support substring

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 merged PR #10847:
URL: https://github.com/apache/doris/pull/10847


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #10847: [enhancement](nereids) support substring

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #10847:
URL: https://github.com/apache/doris/pull/10847#issuecomment-1186758472

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow commented on a diff in pull request #10847: [enhancement](nereids) support substring

Posted by GitBox <gi...@apache.org>.
morrySnow commented on code in PR #10847:
URL: https://github.com/apache/doris/pull/10847#discussion_r921033403


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java:
##########
@@ -1303,7 +1303,24 @@ public void finalizeImplForNereids() throws AnalysisException {
             fn = getBuiltinFunction(fnName.getFunction(), new Type[]{childType},
                     Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
             type = fn.getReturnType();
+        } else if (fnName.getFunction().equalsIgnoreCase("substring")) {
+            Type[] childTypes = getChildren().stream().map(t -> t.type).toArray(Type[]::new);
+            fn = getBuiltinFunction(fnName.getFunction(), childTypes, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
+            type = fn.getReturnType();
+        }
+        if (!fn.getFunctionName().getFunction().equals(ELEMENT_EXTRACT_FN_NAME)) {
+            Type[] args = fn.getArgs();
+            // Implicitly cast all the children to match the function if necessary

Review Comment:
   cast child should happen in nereids



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #10847: [enhancement](nereids) support substring

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #10847:
URL: https://github.com/apache/doris/pull/10847#issuecomment-1186758440

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org