use of io.trino.testing.sql.TestTable in project trino by trinodb.
the class TestJdbcConnectorTest method testUnknownTypeAsIgnored.
@Test
public void testUnknownTypeAsIgnored() {
try (TestTable table = new TestTable(onRemoteDatabase(), "tpch.test_failure_on_unknown_type_as_ignored", "(int_column int, geometry_column GEOMETRY)", ImmutableList.of("1, NULL", "2, 'POINT(7 52)'"))) {
Session ignoreUnsupportedType = unsupportedTypeHandling(IGNORE);
assertQuery(ignoreUnsupportedType, "SELECT int_column FROM " + table.getName(), "VALUES 1, 2");
assertQuery(ignoreUnsupportedType, "SELECT * FROM " + table.getName(), "VALUES 1, 2");
assertQuery(ignoreUnsupportedType, "SELECT column_name, data_type FROM information_schema.columns WHERE table_name LIKE 'test_failure_on_unknown_type_as_ignored%'", "VALUES ('int_column', 'integer')");
assertQuery(ignoreUnsupportedType, "DESCRIBE " + table.getName(), "VALUES ('int_column', 'integer', '', '')");
assertUpdate(ignoreUnsupportedType, format("INSERT INTO %s (int_column) VALUES (3)", table.getName()), 1);
assertQuery(ignoreUnsupportedType, "SELECT * FROM " + table.getName(), "VALUES 1, 2, 3");
}
}
use of io.trino.testing.sql.TestTable in project trino by trinodb.
the class TestBigQueryConnectorTest method testColumnPositionMismatch.
/**
* https://github.com/trinodb/trino/issues/8183
*/
@Test
public void testColumnPositionMismatch() {
try (TestTable table = new TestTable(getQueryRunner()::execute, "test.test_column_position_mismatch", "(c_varchar VARCHAR, c_int INT, c_date DATE)")) {
onBigQuery("INSERT INTO " + table.getName() + " VALUES ('a', 1, '2021-01-01')");
// Adding a CAST makes BigQuery return columns in a different order
assertQuery("SELECT c_varchar, CAST(c_int AS SMALLINT), c_date FROM " + table.getName(), "VALUES ('a', 1, '2021-01-01')");
}
}
use of io.trino.testing.sql.TestTable in project trino by trinodb.
the class TestClickHouseTypeMapping method testUnsupportedTimestamp.
@Test
public void testUnsupportedTimestamp() {
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_unsupported_timestamp", "(dt timestamp(0))")) {
assertQueryFails(format("INSERT INTO %s VALUES (TIMESTAMP '-9999-12-31 23:59:59')", table.getName()), "Timestamp must be between 1970-01-01 00:00:00 and 2105-12-31 23:59:59 in ClickHouse: -9999-12-31 23:59:59");
assertQueryFails(format("INSERT INTO %s VALUES (TIMESTAMP '1969-12-31 23:59:59')", table.getName()), "Timestamp must be between 1970-01-01 00:00:00 and 2105-12-31 23:59:59 in ClickHouse: 1969-12-31 23:59:59");
assertQueryFails(format("INSERT INTO %s VALUES (TIMESTAMP '2106-01-01 00:00:00')", table.getName()), "Timestamp must be between 1970-01-01 00:00:00 and 2105-12-31 23:59:59 in ClickHouse: 2106-01-01 00:00:00");
assertQueryFails(format("INSERT INTO %s VALUES (TIMESTAMP '9999-12-31 23:59:59')", table.getName()), "Timestamp must be between 1970-01-01 00:00:00 and 2105-12-31 23:59:59 in ClickHouse: 9999-12-31 23:59:59");
}
}
use of io.trino.testing.sql.TestTable in project trino by trinodb.
the class TestClickHouseTypeMapping method testUnsupportedUint32.
@Test
public void testUnsupportedUint32() {
// ClickHouse stores incorrect results when the values are out of supported range. This test should be fixed when ClickHouse changes the behavior.
SqlDataTypeTest.create().addRoundTrip("UInt32", "-1", BIGINT, "BIGINT '4294967295'").addRoundTrip("UInt32", "4294967296", BIGINT, "BIGINT '0'").execute(getQueryRunner(), clickhouseCreateAndInsert("tpch.test_unsupported_uint32"));
// Prevent writing incorrect results in the connector
try (TestTable table = new TestTable(clickhouseServer::execute, "tpch.test_unsupported_uint32", "(value UInt32) ENGINE=Log")) {
assertQueryFails(format("INSERT INTO %s VALUES (CAST('-1' AS BIGINT))", table.getName()), "Value must be between 0 and 4294967295 in ClickHouse: -1");
assertQueryFails(format("INSERT INTO %s VALUES (CAST('4294967296' AS BIGINT))", table.getName()), "Value must be between 0 and 4294967295 in ClickHouse: 4294967296");
}
}
use of io.trino.testing.sql.TestTable in project trino by trinodb.
the class TestClickHouseTypeMapping method testUnsupportedUint64.
@Test
public void testUnsupportedUint64() {
// ClickHouse stores incorrect results when the values are out of supported range. This test should be fixed when ClickHouse changes the behavior.
SqlDataTypeTest.create().addRoundTrip("UInt64", "-1", createDecimalType(20), "CAST('18446744073709551615' AS decimal(20, 0))").addRoundTrip("UInt64", "18446744073709551616", createDecimalType(20), "CAST('0' AS decimal(20, 0))").execute(getQueryRunner(), clickhouseCreateAndInsert("tpch.test_unsupported_uint64"));
// Prevent writing incorrect results in the connector
try (TestTable table = new TestTable(clickhouseServer::execute, "tpch.test_unsupported_uint64", "(value UInt64) ENGINE=Log")) {
assertQueryFails(format("INSERT INTO %s VALUES (CAST('-1' AS decimal(20, 0)))", table.getName()), "Value must be between 0 and 18446744073709551615 in ClickHouse: -1");
assertQueryFails(format("INSERT INTO %s VALUES (CAST('18446744073709551616' AS decimal(20, 0)))", table.getName()), "Value must be between 0 and 18446744073709551615 in ClickHouse: 18446744073709551616");
}
}
Aggregations