@Test
public void testTimeZoneDuplicate()
{
assertFunction("TIMESTAMP '2013-10-27 00:05' + INTERVAL '1' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 1, 5, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2013-10-27 00:05' + INTERVAL '2' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 2, 5, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
// we need to manipulate millis directly here because 2 am has two representations in out time zone, and we need the second one
assertFunction("TIMESTAMP '2013-10-27 00:05' + INTERVAL '3' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 0, 5, 0, 0, TIME_ZONE).getMillis() + HOURS.toMillis(3), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2013-10-27 00:05' + INTERVAL '4' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 3, 5, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2013-10-27 03:05' - INTERVAL '4' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 0, 5, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2013-10-27 02:05' - INTERVAL '2' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 0, 5, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2013-10-27 01:05' - INTERVAL '1' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 0, 5, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2013-10-27 03:05' - INTERVAL '1' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 0, 5, 0, 0, TIME_ZONE).getMillis() + HOURS.toMillis(3), TIME_ZONE_KEY));
assertFunction("TIMESTAMP '2013-10-27 03:05' - INTERVAL '2' hour",
new SqlTimestamp(new DateTime(2013, 10, 27, 2, 5, 0, 0, TIME_ZONE).getMillis(), TIME_ZONE_KEY));
}