[fix](Nereids) return null when encryption is invalid rather than throw exception (#16234)
This commit is contained in:
@ -62,13 +62,6 @@ public abstract class AesCryptoFunction extends CryptoFunction {
|
||||
super(name, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkLegalityBeforeTypeCoercion() {
|
||||
if (arity() == 4) {
|
||||
CryptoFunction.checkBlockEncryptionMode(getArgument(3), AES_MODES, "aes");
|
||||
}
|
||||
}
|
||||
|
||||
public static StringLiteral getDefaultBlockEncryptionMode() {
|
||||
return CryptoFunction.getDefaultBlockEncryptionMode("AES_128_ECB");
|
||||
}
|
||||
|
||||
@ -17,11 +17,9 @@
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.nereids.exceptions.AnalysisException;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral;
|
||||
import org.apache.doris.nereids.trees.expressions.literal.StringLiteral;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
|
||||
@ -29,7 +27,6 @@ import com.google.common.collect.Lists;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/** CryptoFunction */
|
||||
public abstract class CryptoFunction extends ScalarFunction
|
||||
@ -69,17 +66,6 @@ public abstract class CryptoFunction extends ScalarFunction
|
||||
return getName() + "(" + StringUtils.join(args, ", ") + ")";
|
||||
}
|
||||
|
||||
/** checkBlockEncryptionMode */
|
||||
static void checkBlockEncryptionMode(Expression blockEncryptionMode, Set<String> modes, String name) {
|
||||
if (!(blockEncryptionMode instanceof StringLikeLiteral)) {
|
||||
throw new AnalysisException("blockEncryptionMode should be string literal: " + blockEncryptionMode);
|
||||
}
|
||||
String mode = ((StringLikeLiteral) blockEncryptionMode).getStringValue();
|
||||
if (!modes.contains(mode.toUpperCase())) {
|
||||
throw new AnalysisException("session variable block_encryption_mode is invalid with " + name);
|
||||
}
|
||||
}
|
||||
|
||||
/** getBlockEncryptionMode */
|
||||
static StringLiteral getDefaultBlockEncryptionMode(String defaultMode) {
|
||||
String blockEncryptionMode = "";
|
||||
|
||||
@ -43,13 +43,6 @@ public abstract class Sm4CryptoFunction extends CryptoFunction {
|
||||
super(name, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkLegalityBeforeTypeCoercion() {
|
||||
if (arity() == 4) {
|
||||
CryptoFunction.checkBlockEncryptionMode(getArgument(3), SM4_MODES, "sm4");
|
||||
}
|
||||
}
|
||||
|
||||
/** getDefaultBlockEncryptionMode */
|
||||
static StringLiteral getDefaultBlockEncryptionMode() {
|
||||
return CryptoFunction.getDefaultBlockEncryptionMode("SM4_128_ECB");
|
||||
|
||||
Reference in New Issue
Block a user