use of io.trino.testing.datatype.SqlDataTypeTest in project trino by trinodb.
the class AbstractTestOracleTypeMapping method testDate.
@Test
public void testDate() {
// Note: these test cases are duplicates of those for PostgreSQL and MySQL.
LocalDate dateOfLocalTimeChangeForwardAtMidnightInJvmZone = LocalDate.of(1970, 1, 1);
verify(jvmZone.getRules().getValidOffsets(dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()).isEmpty());
ZoneId someZone = ZoneId.of("Europe/Vilnius");
LocalDate dateOfLocalTimeChangeForwardAtMidnightInSomeZone = LocalDate.of(1983, 4, 1);
verify(someZone.getRules().getValidOffsets(dateOfLocalTimeChangeForwardAtMidnightInSomeZone.atStartOfDay()).isEmpty());
LocalDate dateOfLocalTimeChangeBackwardAtMidnightInSomeZone = LocalDate.of(1983, 10, 1);
verify(someZone.getRules().getValidOffsets(dateOfLocalTimeChangeBackwardAtMidnightInSomeZone.atStartOfDay().minusMinutes(1)).size() == 2);
SqlDataTypeTest dateTests = SqlDataTypeTest.create().addRoundTrip("DATE", "DATE '-4712-01-01'", TIMESTAMP_SECONDS, "TIMESTAMP '-4712-01-01 00:00:00'").addRoundTrip("DATE", "DATE '-0001-01-01'", TIMESTAMP_SECONDS, "TIMESTAMP '-0001-01-01 00:00:00'").addRoundTrip("DATE", "DATE '0001-01-01'", TIMESTAMP_SECONDS, "TIMESTAMP '0001-01-01 00:00:00'").addRoundTrip("DATE", "DATE '1582-10-04'", TIMESTAMP_SECONDS, "TIMESTAMP '1582-10-04 00:00:00'").addRoundTrip("DATE", "DATE '1582-10-15'", TIMESTAMP_SECONDS, "TIMESTAMP '1582-10-15 00:00:00'").addRoundTrip("DATE", "DATE '1952-04-03'", TIMESTAMP_SECONDS, "TIMESTAMP '1952-04-03 00:00:00'").addRoundTrip("DATE", "DATE '1970-01-01'", TIMESTAMP_SECONDS, "TIMESTAMP '1970-01-01 00:00:00'").addRoundTrip("DATE", "DATE '1970-02-03'", TIMESTAMP_SECONDS, "TIMESTAMP '1970-02-03 00:00:00'").addRoundTrip("DATE", "DATE '2017-07-01'", TIMESTAMP_SECONDS, "TIMESTAMP '2017-07-01 00:00:00'").addRoundTrip("DATE", "DATE '2017-01-01'", TIMESTAMP_SECONDS, "TIMESTAMP '2017-01-01 00:00:00'").addRoundTrip("DATE", "DATE '1983-04-01'", TIMESTAMP_SECONDS, "TIMESTAMP '1983-04-01 00:00:00'").addRoundTrip("DATE", "DATE '1983-10-01'", TIMESTAMP_SECONDS, "TIMESTAMP '1983-10-01 00:00:00'").addRoundTrip("DATE", "DATE '9999-12-31'", TIMESTAMP_SECONDS, "TIMESTAMP '9999-12-31 00:00:00'");
for (String timeZoneId : ImmutableList.of(UTC_KEY.getId(), ZoneId.systemDefault().getId(), ZoneId.of("Europe/Vilnius").getId())) {
Session session = Session.builder(getSession()).setTimeZoneKey(getTimeZoneKey(timeZoneId)).build();
dateTests.execute(getQueryRunner(), session, oracleCreateAndInsert("test_date"));
dateTests.execute(getQueryRunner(), session, trinoCreateAsSelect("test_date"));
dateTests.execute(getQueryRunner(), session, trinoCreateAndInsert("test_date"));
}
}
use of io.trino.testing.datatype.SqlDataTypeTest in project trino by trinodb.
the class AbstractTestOracleTypeMapping method testTimestamp.
@Test(dataProvider = "sessionZonesDataProvider")
public void testTimestamp(ZoneId sessionZone) {
// using two non-JVM zones so that we don't need to worry what Oracle system zone is
SqlDataTypeTest tests = SqlDataTypeTest.create().addRoundTrip("timestamp", "TIMESTAMP '-4712-01-01 00:00:00.000'", TIMESTAMP_MILLIS, "TIMESTAMP '-4712-01-01 00:00:00.000'").addRoundTrip("timestamp", "TIMESTAMP '-0001-01-01 00:00:00.000'", TIMESTAMP_MILLIS, "TIMESTAMP '-0001-01-01 00:00:00.000'").addRoundTrip("timestamp", "TIMESTAMP '1582-10-04 00:00:00.000'", TIMESTAMP_MILLIS, "TIMESTAMP '1582-10-04 00:00:00.000'").addRoundTrip("timestamp", "TIMESTAMP '1582-10-15 00:00:00.000'", TIMESTAMP_MILLIS, "TIMESTAMP '1582-10-15 00:00:00.000'").addRoundTrip("timestamp", "TIMESTAMP '1958-01-01 13:18:03.123'", TIMESTAMP_MILLIS, "TIMESTAMP '1958-01-01 13:18:03.123'").addRoundTrip("timestamp", "TIMESTAMP '2019-03-18 10:01:17.987'", TIMESTAMP_MILLIS, "TIMESTAMP '2019-03-18 10:01:17.987'").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)).addRoundTrip("timestamp", "TIMESTAMP '9999-12-31 00:00:00.000'", TIMESTAMP_MILLIS, "TIMESTAMP '9999-12-31 00:00:00.000'");
Session session = Session.builder(getSession()).setTimeZoneKey(getTimeZoneKey(sessionZone.getId())).build();
tests.execute(getQueryRunner(), session, trinoCreateAsSelect(session, "test_timestamp"));
tests.execute(getQueryRunner(), session, trinoCreateAndInsert("test_timestamp"));
tests.execute(getQueryRunner(), session, oracleCreateAndInsert("test_timestamp"));
}
use of io.trino.testing.datatype.SqlDataTypeTest in project trino by trinodb.
the class TestPostgreSqlTypeMapping method testArrayMultidimensional.
@Test
public void testArrayMultidimensional() {
// TODO: Migrate from DataTypeTest. SqlDataTypeTest fails when verifying predicates since we don't support comparing arrays containing NULLs, see https://github.com/trinodb/trino/issues/11397.
// for multidimensional arrays, PostgreSQL requires subarrays to have the same dimensions, including nulls
// e.g. [[1], [1, 2]] and [null, [1, 2]] are not allowed, but [[null, null], [1, 2]] is allowed
DataTypeTest.create().addRoundTrip(arrayDataType(arrayDataType(booleanDataType())), asList(asList(null, null, null))).addRoundTrip(arrayDataType(arrayDataType(booleanDataType())), asList(asList(true, null), asList(null, null), asList(false, false))).addRoundTrip(arrayDataType(arrayDataType(integerDataType())), asList(asList(1, 2), asList(null, null), asList(3, 4))).addRoundTrip(arrayDataType(arrayDataType(decimalDataType(3, 0))), asList(asList(new BigDecimal("193")), asList(new BigDecimal("19")), asList(new BigDecimal("-193")))).execute(getQueryRunner(), sessionWithArrayAsArray(), trinoCreateAsSelect(sessionWithArrayAsArray(), "test_array_2d")).execute(getQueryRunner(), sessionWithArrayAsArray(), trinoCreateAndInsert(sessionWithArrayAsArray(), "test_array_2d"));
DataTypeTest.create().addRoundTrip(arrayDataType(arrayDataType(arrayDataType(doubleDataType()))), asList(asList(asList(123.45d), asList(678.99d)), asList(asList(543.21d), asList(998.76d)), asList(asList(567.123d), asList(789.12d)))).addRoundTrip(arrayDataType(arrayDataType(arrayDataType(dateDataType()))), asList(asList(asList(LocalDate.of(1952, 4, 3), LocalDate.of(1970, 1, 1))), asList(asList(null, LocalDate.of(1970, 1, 1))), asList(asList(LocalDate.of(1970, 2, 3), LocalDate.of(2017, 7, 1))))).execute(getQueryRunner(), sessionWithArrayAsArray(), trinoCreateAsSelect(sessionWithArrayAsArray(), "test_array_3d")).execute(getQueryRunner(), sessionWithArrayAsArray(), trinoCreateAndInsert(sessionWithArrayAsArray(), "test_array_3d"));
}
Aggregations