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/12/13 10:04:18 UTC

[GitHub] [doris] starocean999 opened a new pull request, #15038: [nereids](function)fix encryption function translation bug

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

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] 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] hello-stephen commented on pull request #15038: [nereids](function)fix encryption function translation bug

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #15038:
URL: https://github.com/apache/doris/pull/15038#issuecomment-1348222110

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 34.94 seconds
    load time: 435 seconds
    storage size: 17123356960 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221213111358_clickbench_pr_62640.html


-- 
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 #15038: [nereids](function)fix encryption function translation bug

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

   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


[GitHub] [doris] morrySnow merged pull request #15038: [nereids](function)fix encryption function translation bug

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


-- 
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 #15038: [nereids](function)fix encryption function translation bug

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

   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] 924060929 commented on pull request #15038: [nereids](function)fix encryption function translation bug

Posted by GitBox <gi...@apache.org>.
924060929 commented on PR #15038:
URL: https://github.com/apache/doris/pull/15038#issuecomment-1357005475

   I think we should create new function like `checkArguments` in the new ScalarFunction, and do the check in the analysis stage


-- 
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 #15038: [nereids](function)fix encryption function translation bug

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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java:
##########
@@ -402,4 +414,61 @@ private static org.apache.doris.analysis.AssertNumRowsElement.Assertion translat
                 throw new AnalysisException("UnSupported type: " + assertion);
         }
     }
+
+    private void translateEncryptionFunctions(ScalarFunction function, PlanTranslatorContext context,
+            List<Expr> arguments, List<Type> argTypes) {
+        String blockEncryptionMode = context.getRuntimeTranslator().get().getRuntimeFilterContext()
+                .getSessionVariable().getBlockEncryptionMode();
+        if (function.getName().equalsIgnoreCase("aes_decrypt")
+                || function.getName().equalsIgnoreCase("aes_encrypt")) {
+            HashSet<String> aesModes = new HashSet<>(Arrays.asList(

Review Comment:
   we should put this set to an util class and make it static



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java:
##########
@@ -402,4 +414,61 @@ private static org.apache.doris.analysis.AssertNumRowsElement.Assertion translat
                 throw new AnalysisException("UnSupported type: " + assertion);
         }
     }
+
+    private void translateEncryptionFunctions(ScalarFunction function, PlanTranslatorContext context,
+            List<Expr> arguments, List<Type> argTypes) {
+        String blockEncryptionMode = context.getRuntimeTranslator().get().getRuntimeFilterContext()
+                .getSessionVariable().getBlockEncryptionMode();

Review Comment:
   if u want session variables, u has two way to do that:
   1. ConnectContext.get(). getSessionVariable()
   2. put cascadesContext into PlanTranslatorContext



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java:
##########
@@ -402,4 +414,61 @@ private static org.apache.doris.analysis.AssertNumRowsElement.Assertion translat
                 throw new AnalysisException("UnSupported type: " + assertion);
         }
     }
+
+    private void translateEncryptionFunctions(ScalarFunction function, PlanTranslatorContext context,
+            List<Expr> arguments, List<Type> argTypes) {
+        String blockEncryptionMode = context.getRuntimeTranslator().get().getRuntimeFilterContext()
+                .getSessionVariable().getBlockEncryptionMode();
+        if (function.getName().equalsIgnoreCase("aes_decrypt")
+                || function.getName().equalsIgnoreCase("aes_encrypt")) {
+            HashSet<String> aesModes = new HashSet<>(Arrays.asList(
+                    "AES_128_ECB",
+                    "AES_192_ECB",
+                    "AES_256_ECB",
+                    "AES_128_CBC",
+                    "AES_192_CBC",
+                    "AES_256_CBC",
+                    "AES_128_CFB",
+                    "AES_192_CFB",
+                    "AES_256_CFB",
+                    "AES_128_CFB1",
+                    "AES_192_CFB1",
+                    "AES_256_CFB1",
+                    "AES_128_CFB8",
+                    "AES_192_CFB8",
+                    "AES_256_CFB8",
+                    "AES_128_CFB128",
+                    "AES_192_CFB128",
+                    "AES_256_CFB128",
+                    "AES_128_CTR",
+                    "AES_192_CTR",
+                    "AES_256_CTR",
+                    "AES_128_OFB",
+                    "AES_192_OFB",
+                    "AES_256_OFB"
+            ));
+            if (StringUtils.isAllBlank(blockEncryptionMode)) {
+                blockEncryptionMode = "AES_128_ECB";
+            }
+            if (!aesModes.contains(blockEncryptionMode.toUpperCase())) {
+                throw new AnalysisException("session variable block_encryption_mode is invalid with aes");
+            }
+        } else if (function.getName().equalsIgnoreCase("sm4_decrypt")
+                || function.getName().equalsIgnoreCase("sm4_encrypt")) {

Review Comment:
   maybe we need a new interface for all en/decrypt functions, the interface has two use:
   1. we can use xxx instanceOf xxx, instead of use function name to judge function type
   2. afford some helper function, such as
     a. isAes()
     b. isSm4()
   
   > 



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