Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Mryange committed Aug 6, 2024
1 parent 81ff2a0 commit 2a47ae1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public class MicroSecondsAdd extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {

private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
FunctionSignature.ret(DateTimeV2Type.MICRO)
.args(DateTimeV2Type.MICRO, IntegerType.INSTANCE));

public MicroSecondsAdd(Expression arg0, Expression arg1) {
super("microseconds_add", arg0, arg1);
Expand All @@ -57,6 +56,14 @@ public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}

@Override
public FunctionSignature computeSignature(FunctionSignature signature) {
signature = super.computeSignature(signature);
signature.withArgumentType(0, DateTimeV2Type.MICRO);
signature = signature.withReturnType(DateTimeV2Type.MICRO);
return signature;
}

@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitMicroSecondsAdd(this, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public class MicroSecondsSub extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {

private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
FunctionSignature.ret(DateTimeV2Type.MICRO)
.args(DateTimeV2Type.MICRO, IntegerType.INSTANCE));

public MicroSecondsSub(Expression arg0, Expression arg1) {
super("microseconds_sub", arg0, arg1);
Expand All @@ -57,6 +56,14 @@ public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}

@Override
public FunctionSignature computeSignature(FunctionSignature signature) {
signature = super.computeSignature(signature);
signature.withArgumentType(0, DateTimeV2Type.MICRO);
signature = signature.withReturnType(DateTimeV2Type.MICRO);
return signature;
}

@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitMicroSecondsSub(this, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public class MilliSecondsAdd extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {

private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
FunctionSignature.ret(DateTimeV2Type.MILLI)
.args(DateTimeV2Type.MILLI, IntegerType.INSTANCE));

public MilliSecondsAdd(Expression arg0, Expression arg1) {
super("milliseconds_add", arg0, arg1);
Expand All @@ -57,6 +56,14 @@ public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}

@Override
public FunctionSignature computeSignature(FunctionSignature signature) {
signature = super.computeSignature(signature);
signature.withArgumentType(0, DateTimeV2Type.MILLI);
signature = signature.withReturnType(DateTimeV2Type.MILLI);
return signature;
}

@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitMilliSecondsAdd(this, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public class MilliSecondsSub extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {

private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT)
.args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE)
);
FunctionSignature.ret(DateTimeV2Type.MILLI)
.args(DateTimeV2Type.MILLI, IntegerType.INSTANCE));

public MilliSecondsSub(Expression arg0, Expression arg1) {
super("milliseconds_sub", arg0, arg1);
Expand All @@ -57,6 +56,14 @@ public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}

@Override
public FunctionSignature computeSignature(FunctionSignature signature) {
signature = super.computeSignature(signature);
signature.withArgumentType(0, DateTimeV2Type.MILLI);
signature = signature.withReturnType(DateTimeV2Type.MILLI);
return signature;
}

@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitMilliSecondsSub(this, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public class DateTimeV2Type extends DateLikeType {
public static final DateTimeV2Type SYSTEM_DEFAULT = new DateTimeV2Type(0);
public static final DateTimeV2Type MAX = new DateTimeV2Type(MAX_SCALE);

public static final DateTimeV2Type MICRO = new DateTimeV2Type(MAX_SCALE);

public static final DateTimeV2Type MILLI = new DateTimeV2Type(3);

private static final int WIDTH = 8;

private final int scale;
Expand Down

0 comments on commit 2a47ae1

Please sign in to comment.