@ScalarOperator(ADD) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long intervalDayToSecondPlusTimestampWithTimeZone(@SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long left, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long right) { return updateMillisUtc(left + unpackMillisUtc(right), right); }
@ScalarOperator(SUBTRACT) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long timestampWithTimeZoneMinusIntervalDayToSecond(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long right) { return updateMillisUtc(unpackMillisUtc(left) - right, left); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long timestampWithTimeZonePlusIntervalDayToSecond(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long right) { return updateMillisUtc(unpackMillisUtc(left) + right, left); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long timestampWithTimeZonePlusIntervalDayToSecond(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long right) { return updateMillisUtc(unpackMillisUtc(left) + right, left); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long intervalDayToSecondPlusTimestampWithTimeZone(@SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long left, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long right) { return updateMillisUtc(left + unpackMillisUtc(right), right); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long timeWithTimeZonePlusIntervalDayToSecond(@SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long right) { return updateMillisUtc((long) modulo24Hour(unpackChronology(left), unpackMillisUtc(left) + right), left); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long intervalDayToSecondPlusTimeWithTimeZone(@SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long left, @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long right) { return updateMillisUtc((long) modulo24Hour(unpackChronology(right), left + unpackMillisUtc(right)), right); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long intervalDayToSecondPlusTimeWithTimeZone(@SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long left, @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long right) { return updateMillisUtc((long) modulo24Hour(unpackChronology(right), left + unpackMillisUtc(right)), right); }
@ScalarOperator(SUBTRACT) @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long timeWithTimeZoneMinusIntervalDayToSecond(@SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long right) { return updateMillisUtc((long) modulo24Hour(unpackChronology(left), unpackMillisUtc(left) - right), left); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long timeWithTimeZonePlusIntervalDayToSecond(@SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_DAY_TO_SECOND) long right) { return updateMillisUtc((long) modulo24Hour(unpackChronology(left), unpackMillisUtc(left) + right), left); }
@Description("add the specified amount of time to the given timestamp") @LiteralParameters("x") @ScalarFunction("date_add") @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long addFieldValueTimestampWithTimeZone( @SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { long millis = getTimestampField(unpackChronology(timestampWithTimeZone), unit).add(unpackMillisUtc(timestampWithTimeZone), toIntExact(value)); return updateMillisUtc(millis, timestampWithTimeZone); }
@Description("add the specified amount of time to the given timestamp") @LiteralParameters("x") @ScalarFunction("date_add") @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long addFieldValueTimestampWithTimeZone( @SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { long millis = getTimestampField(unpackChronology(timestampWithTimeZone), unit).add(unpackMillisUtc(timestampWithTimeZone), toIntExact(value)); return updateMillisUtc(millis, timestampWithTimeZone); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long timestampWithTimeZonePlusIntervalYearToMonth(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_YEAR_TO_MONTH) long right) { return updateMillisUtc(unpackChronology(left).monthOfYear().add(unpackMillisUtc(left), right), left); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long intervalYearToMonthPlusTimestampWithTimeZone(@SqlType(StandardTypes.INTERVAL_YEAR_TO_MONTH) long left, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long right) { return updateMillisUtc(unpackChronology(right).monthOfYear().add(unpackMillisUtc(right), left), right); }
@ScalarOperator(SUBTRACT) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long timestampWithTimeZoneMinusIntervalYearToMonth(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_YEAR_TO_MONTH) long right) { long dateTimeWithTimeZone = unpackChronology(left).monthOfYear().add(unpackMillisUtc(left), -right); return updateMillisUtc(dateTimeWithTimeZone, left); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long intervalYearToMonthPlusTimestampWithTimeZone(@SqlType(StandardTypes.INTERVAL_YEAR_TO_MONTH) long left, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long right) { return updateMillisUtc(unpackChronology(right).monthOfYear().add(unpackMillisUtc(right), left), right); }
@ScalarOperator(ADD) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long timestampWithTimeZonePlusIntervalYearToMonth(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long left, @SqlType(StandardTypes.INTERVAL_YEAR_TO_MONTH) long right) { return updateMillisUtc(unpackChronology(left).monthOfYear().add(unpackMillisUtc(left), right), left); }
@Description("truncate to the specified precision") @ScalarFunction("date_trunc") @LiteralParameters("x") @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long truncateTimestampWithTimezone(@SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { long millis = getTimestampField(unpackChronology(timestampWithTimeZone), unit).roundFloor(unpackMillisUtc(timestampWithTimeZone)); return updateMillisUtc(millis, timestampWithTimeZone); }
@Description("truncate to the specified precision") @ScalarFunction("date_trunc") @LiteralParameters("x") @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long truncateTimeWithTimeZone(@SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long timeWithTimeZone) { long millis = getTimeField(unpackChronology(timeWithTimeZone), unit).roundFloor(unpackMillisUtc(timeWithTimeZone)); return updateMillisUtc(millis, timeWithTimeZone); }
@Description("truncate to the specified precision") @ScalarFunction("date_trunc") @LiteralParameters("x") @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long truncateTimeWithTimeZone(@SqlType("varchar(x)") Slice unit, @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) long timeWithTimeZone) { long millis = getTimeField(unpackChronology(timeWithTimeZone), unit).roundFloor(unpackMillisUtc(timeWithTimeZone)); return updateMillisUtc(millis, timeWithTimeZone); }