@Test
public void testTimestampPlusInterval()
{
assertFunction("TIMESTAMP '2001-1-22 03:04:05.321' + INTERVAL '3' hour",
new SqlTimestamp(new DateTime(2001, 1, 22, 6, 4, 5, 321, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("INTERVAL '3' hour + TIMESTAMP '2001-1-22 03:04:05.321'",
new SqlTimestamp(new DateTime(2001, 1, 22, 6, 4, 5, 321, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2001-1-22 03:04:05.321' + INTERVAL '3' day",
new SqlTimestamp(new DateTime(2001, 1, 25, 3, 4, 5, 321, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("INTERVAL '3' day + TIMESTAMP '2001-1-22 03:04:05.321'",
new SqlTimestamp(new DateTime(2001, 1, 25, 3, 4, 5, 321, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2001-1-22 03:04:05.321' + INTERVAL '3' month",
new SqlTimestamp(new DateTime(2001, 4, 22, 3, 4, 5, 321, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("INTERVAL '3' month + TIMESTAMP '2001-1-22 03:04:05.321'",
new SqlTimestamp(new DateTime(2001, 4, 22, 3, 4, 5, 321, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2001-1-22 03:04:05.321' + INTERVAL '3' year",
new SqlTimestamp(new DateTime(2004, 1, 22, 3, 4, 5, 321, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("INTERVAL '3' year + TIMESTAMP '2001-1-22 03:04:05.321'",
new SqlTimestamp(new DateTime(2004, 1, 22, 3, 4, 5, 321, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2001-1-22 03:04:05.321 +05:09' + INTERVAL '3' hour",
new SqlTimestampWithTimeZone(new DateTime(2001, 1, 22, 6, 4, 5, 321, WEIRD_TIME_ZONE).getMillis(), WEIRD_TIME_ZONE_KEY));
assertFunction("INTERVAL '3' hour + TIMESTAMP '2001-1-22 03:04:05.321 +05:09'",
new SqlTimestampWithTimeZone(new DateTime(2001, 1, 22, 6, 4, 5, 321, WEIRD_TIME_ZONE).getMillis(), WEIRD_TIME_ZONE_KEY));