Skip to content

Commit

Permalink
[fix](Nereids) add one arg truncate (#35876)
Browse files Browse the repository at this point in the history
pick from #29864
  • Loading branch information
morrySnow authored Jun 4, 2024
1 parent dc04778 commit 29f0856
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,17 @@ public class Truncate extends ScalarFunction

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE)
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE)
);

/**
* constructor with 1 argument.
*/
public Truncate(Expression arg0) {
super("truncate", arg0);
}

/**
* constructor with 2 arguments.
*/
Expand All @@ -56,8 +64,12 @@ public Truncate(Expression arg0, Expression arg1) {
*/
@Override
public Truncate withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new Truncate(children.get(0), children.get(1));
Preconditions.checkArgument(children.size() == 1 || children.size() == 2);
if (children.size() == 1) {
return new Truncate(children.get(0));
} else {
return new Truncate(children.get(0), children.get(1));
}
}

@Override
Expand Down

0 comments on commit 29f0856

Please sign in to comment.