Skip to content

Commit

Permalink
fix seconds add
Browse files Browse the repository at this point in the history
  • Loading branch information
LiBinfeng-01 committed Sep 18, 2024
1 parent 3a187e2 commit 374dee2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ public static Expression secondsAdd(DateTimeV2Literal date, IntegerLiteral secon
return date.plusSeconds(second.getValue());
}

@ExecFunction(name = "seconds_add")
public static Expression secondsAdd(DateLiteral date, IntegerLiteral second) {
return date.plusSeconds(second.getValue());
}

@ExecFunction(name = "seconds_add")
public static Expression secondsAdd(DateV2Literal date, IntegerLiteral second) {
return date.plusSeconds(second.getValue());
}

/**
* datetime arithmetic function microseconds-add.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitDateV2Literal(this, context);
}

public Expression plusSeconds(long seconds) {
return fromJavaDateType(toJavaDateType().plusDays(seconds));
}

public Expression plusDays(long days) {
return fromJavaDateType(toJavaDateType().plusDays(days));
}
Expand Down

0 comments on commit 374dee2

Please sign in to comment.