morrySnow commented on code in PR #51163:
URL: https://github.com/apache/doris/pull/51163#discussion_r2102074527
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sha2.java:
##########
@@ -48,6 +51,22 @@ public Sha2(Expression arg0, Expression arg1) {
super("sha2", arg0, arg1);
}
+ @Override
+ public void checkLegalityBeforeTypeCoercion() {
+ checkLegalityAfterRewrite();
+ }
+
+ @Override
+ public void checkLegalityAfterRewrite() {
+ if ((children.size() != 2) || !(child(1) instanceof
IntegerLikeLiteral)) {
+ throw new AnalysisException("sha2 needs two params, and the second
is must be a integer constant: " + this.toSql());
+ }
+ final int constParam = ((IntegerLikeLiteral) child(1)).getIntValue();
+ if (!Lists.newArrayList(224, 256, 384, 512).contains(constParam)) {
Review Comment:
please use a static list for Lists.newArrayList(224, 256, 384, 512)
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sha2.java:
##########
@@ -48,6 +51,22 @@ public Sha2(Expression arg0, Expression arg1) {
super("sha2", arg0, arg1);
}
+ @Override
+ public void checkLegalityBeforeTypeCoercion() {
+ checkLegalityAfterRewrite();
+ }
+
+ @Override
+ public void checkLegalityAfterRewrite() {
+ if ((children.size() != 2) || !(child(1) instanceof
IntegerLikeLiteral)) {
+ throw new AnalysisException("sha2 needs two params, and the second
is must be a integer constant: " + this.toSql());
+ }
+ final int constParam = ((IntegerLikeLiteral) child(1)).getIntValue();
+ if (!Lists.newArrayList(224, 256, 384, 512).contains(constParam)) {
+ throw new AnalysisException("sha2 functions only support digest
length of 224/256/384/512");
Review Comment:
use List to string to avoid exception msg is not same with if condiiton
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Sha2.java:
##########
@@ -48,6 +51,22 @@ public Sha2(Expression arg0, Expression arg1) {
super("sha2", arg0, arg1);
}
+ @Override
+ public void checkLegalityBeforeTypeCoercion() {
+ checkLegalityAfterRewrite();
+ }
+
+ @Override
+ public void checkLegalityAfterRewrite() {
+ if ((children.size() != 2) || !(child(1) instanceof
IntegerLikeLiteral)) {
+ throw new AnalysisException("sha2 needs two params, and the second
is must be a integer constant: " + this.toSql());
Review Comment:
constant is not same with literal, the log is not reflect the if condition
conrrectly
--
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]