Skip to content

Commit

Permalink
Convert oracle timestamp test to SqlDataTypeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
brandboat authored and hashhar committed Jun 9, 2021
1 parent 4af5702 commit dc83efc
Showing 1 changed file with 22 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -707,51 +707,41 @@ public void testDate()
}

@Test(dataProvider = "testTimestampDataProvider")
public void testTimestamp(boolean insertWithTrino, ZoneId sessionZone)
public void testTimestamp(ZoneId sessionZone)
{
// using two non-JVM zones so that we don't need to worry what Oracle system zone is
DataTypeTest tests = DataTypeTest.create()
.addRoundTrip(timestampDataType(), beforeEpoch)
.addRoundTrip(timestampDataType(), afterEpoch)
.addRoundTrip(timestampDataType(), timeDoubledInJvmZone)
.addRoundTrip(timestampDataType(), timeDoubledInVilnius)
.addRoundTrip(timestampDataType(), epoch) // epoch also is a gap in JVM zone
.addRoundTrip(timestampDataType(), timeGapInJvmZone1)
.addRoundTrip(timestampDataType(), timeGapInJvmZone2)
.addRoundTrip(timestampDataType(), timeGapInVilnius)
.addRoundTrip(timestampDataType(), timeGapInKathmandu);
SqlDataTypeTest tests = SqlDataTypeTest.create()
// before epoch
.addRoundTrip("timestamp", "TIMESTAMP '1958-01-01 13:18:03.123'", TIMESTAMP_MILLIS, "TIMESTAMP '1958-01-01 13:18:03.123'")
// after epoch
.addRoundTrip("timestamp", "TIMESTAMP '2019-03-18 10:01:17.987'", TIMESTAMP_MILLIS, "TIMESTAMP '2019-03-18 10:01:17.987'")
// epoch, epoch also is a gap in JVM zone
.addRoundTrip("timestamp", "TIMESTAMP '1970-01-01 00:00:00.000'", TIMESTAMP_MILLIS, "TIMESTAMP '1970-01-01 00:00:00.000'")
.addRoundTrip("timestamp", timestampDataType(3).toLiteral(timeDoubledInJvmZone), TIMESTAMP_MILLIS, timestampDataType(3).toLiteral(timeDoubledInJvmZone))
.addRoundTrip("timestamp", timestampDataType(3).toLiteral(timeDoubledInVilnius), TIMESTAMP_MILLIS, timestampDataType(3).toLiteral(timeDoubledInVilnius))
.addRoundTrip("timestamp", timestampDataType(3).toLiteral(timeGapInJvmZone1), TIMESTAMP_MILLIS, timestampDataType(3).toLiteral(timeGapInJvmZone1))
.addRoundTrip("timestamp", timestampDataType(3).toLiteral(timeGapInJvmZone2), TIMESTAMP_MILLIS, timestampDataType(3).toLiteral(timeGapInJvmZone2))
.addRoundTrip("timestamp", timestampDataType(3).toLiteral(timeGapInVilnius), TIMESTAMP_MILLIS, timestampDataType(3).toLiteral(timeGapInVilnius))
.addRoundTrip("timestamp", timestampDataType(3).toLiteral(timeGapInKathmandu), TIMESTAMP_MILLIS, timestampDataType(3).toLiteral(timeGapInKathmandu));

Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
.build();

if (insertWithTrino) {
tests.execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_timestamp"));
}
else {
tests.execute(getQueryRunner(), session, oracleCreateAndInsert("test_timestamp"));
}
tests.execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_timestamp"));
tests.execute(getQueryRunner(), session, trinoCreateAndInsert("test_timestamp"));
tests.execute(getQueryRunner(), session, oracleCreateAndInsert("test_timestamp"));
}

@DataProvider
public Object[][] testTimestampDataProvider()
{
return new Object[][] {
{true, UTC},
{false, UTC},

{true, jvmZone},
{false, jvmZone},

{UTC},
{jvmZone},
// using two non-JVM zones so that we don't need to worry what Oracle system zone is
{true, vilnius},
{false, vilnius},

{true, kathmandu},
{false, kathmandu},

{true, ZoneId.of(TestingSession.DEFAULT_TIME_ZONE_KEY.getId())},
{false, ZoneId.of(TestingSession.DEFAULT_TIME_ZONE_KEY.getId())},
{vilnius},
{kathmandu},
{ZoneId.of(TestingSession.DEFAULT_TIME_ZONE_KEY.getId())},
};
}

Expand Down

0 comments on commit dc83efc

Please sign in to comment.