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: [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]

Reply via email to