Skip to content

Commit

Permalink
update about positive constant
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Jul 25, 2024
1 parent cbb457f commit ad8709d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.literal.Literal;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.ArrayType;
import org.apache.doris.nereids.types.IntegerType;
Expand Down Expand Up @@ -75,10 +76,10 @@ public SplitByRegexp withChildren(List<Expression> children) {

@Override
public void checkLegalityBeforeTypeCoercion() {
if (getArguments().size() == 3) {
if (!getArgument(2).isConstant()) {
if (children().size() == 3) {
if (!child(2).isConstant() || ((Literal) child(2)).getDouble() < 0) {
throw new AnalysisException("the third parameter of "
+ getName() + " function must be a constant: " + toSql());
+ getName() + " function must be a positive constant: " + toSql());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1831,14 +1831,14 @@ default R visitSplitByChar(SplitByChar splitByChar, C context) {
return visitScalarFunction(splitByChar, context);
}

default R visitSplitByString(SplitByString splitByString, C context) {
return visitScalarFunction(splitByString, context);
}

default R visitSplitByRegexp(SplitByRegexp splitByRegexp, C context) {
return visitScalarFunction(splitByRegexp, context);
}

default R visitSplitByString(SplitByString splitByString, C context) {
return visitScalarFunction(splitByString, context);
}

default R visitSplitPart(SplitPart splitPart, C context) {
return visitScalarFunction(splitPart, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ suite("test_split_by_regexp") {

test {
sql " select split_by_regexp(NULL, 'a12bc23de345f', k1) from test_split_by_regexp"
exception "function must be a constant"
exception "function must be a positive constant"
}
test {
sql " select split_by_regexp(NULL, 'a12bc23de345f', -10) from test_split_by_regexp"
exception "function must be a positive constant"
}
qt_select5 "select split_by_regexp(v1, ',') from test_split_by_regexp order by k1;"
qt_select6 "select split_by_regexp('do,ris', v2) from test_split_by_regexp order by k1;"
Expand Down

0 comments on commit ad8709d

Please sign in to comment.