[opt](Nereids) add two args signature to trim family functions (#25169)
This commit is contained in:
@ -37,11 +37,18 @@ import java.util.List;
|
||||
public class Ltrim extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
|
||||
.args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
private Ltrim(List<Expression> args) {
|
||||
super("ltrim", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
@ -49,13 +56,20 @@ public class Ltrim extends ScalarFunction
|
||||
super("ltrim", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor with 2 argument.
|
||||
*/
|
||||
public Ltrim(Expression arg0, Expression arg1) {
|
||||
super("ltrim", arg0, arg1);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public Ltrim withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new Ltrim(children.get(0));
|
||||
Preconditions.checkArgument(children.size() == 1 || children.size() == 2);
|
||||
return new Ltrim(children);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -37,11 +37,18 @@ import java.util.List;
|
||||
public class Rtrim extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
|
||||
.args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
private Rtrim(List<Expression> args) {
|
||||
super("rtrim", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
@ -49,13 +56,20 @@ public class Rtrim extends ScalarFunction
|
||||
super("rtrim", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor with 2 argument.
|
||||
*/
|
||||
public Rtrim(Expression arg0, Expression arg1) {
|
||||
super("rtrim", arg0, arg1);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public Rtrim withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new Rtrim(children.get(0));
|
||||
Preconditions.checkArgument(children.size() == 1 || children.size() == 2);
|
||||
return new Rtrim(children);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -37,11 +37,18 @@ import java.util.List;
|
||||
public class Trim extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
|
||||
.args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE, StringType.INSTANCE),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
private Trim(List<Expression> args) {
|
||||
super("trim", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
@ -49,13 +56,20 @@ public class Trim extends ScalarFunction
|
||||
super("trim", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor with 2 argument.
|
||||
*/
|
||||
public Trim(Expression arg0, Expression arg1) {
|
||||
super("trim", arg0, arg1);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public Trim withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new Trim(children.get(0));
|
||||
Preconditions.checkArgument(children.size() == 1 || children.size() == 2);
|
||||
return new Trim(children);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user