use of io.trino.tempto.Requires in project trino by trinodb.
the class TestHiveCoercion method testHiveCoercionAvro.
@Requires(AvroRequirements.class)
@Test(groups = { HIVE_COERCION, JDBC })
public void testHiveCoercionAvro() {
String tableName = mutableTableInstanceOf(HIVE_COERCION_AVRO).getNameInDatabase();
onHive().executeQuery(format("INSERT INTO TABLE %s " + "PARTITION (id=1) " + "VALUES" + "(2323, 0.5)," + "(-2323, -1.5)", tableName));
onHive().executeQuery(format("ALTER TABLE %s CHANGE COLUMN int_to_bigint int_to_bigint bigint", tableName));
onHive().executeQuery(format("ALTER TABLE %s CHANGE COLUMN float_to_double float_to_double double", tableName));
assertThat(onTrino().executeQuery("SHOW COLUMNS FROM " + tableName).project(1, 2)).containsExactlyInOrder(row("int_to_bigint", "bigint"), row("float_to_double", "double"), row("id", "bigint"));
QueryResult queryResult = onTrino().executeQuery("SELECT * FROM " + tableName);
assertThat(queryResult).hasColumns(BIGINT, DOUBLE, BIGINT);
assertThat(queryResult).containsOnly(row(2323L, 0.5, 1), row(-2323L, -1.5, 1));
}
use of io.trino.tempto.Requires in project trino by trinodb.
the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesRcfile.
@Requires(RcfileRequirements.class)
@Test(groups = JDBC)
public void testSelectAllDatatypesRcfile() {
String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_RCFILE).getNameInDatabase();
populateDataToHiveTable(tableName);
assertProperAllDatatypesSchema(tableName);
QueryResult queryResult = onTrino().executeQuery(format("SELECT * FROM %s", tableName));
assertColumnTypes(queryResult);
assertThat(queryResult).containsOnly(row(127, 32767, 2147483647, 9223372036854775807L, 123.345f, 234.567, new BigDecimal("346"), new BigDecimal("345.67800"), Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)), Date.valueOf("2015-05-10"), "ala ma kota", "ala ma kot", "ala ma ", true, "kot binarny".getBytes(UTF_8)));
}
use of io.trino.tempto.Requires in project trino by trinodb.
the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesOrc.
@Requires(OrcRequirements.class)
@Test(groups = JDBC)
public void testSelectAllDatatypesOrc() {
String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_ORC).getNameInDatabase();
populateDataToHiveTable(tableName);
assertProperAllDatatypesSchema(tableName);
QueryResult queryResult = onTrino().executeQuery(format("SELECT * FROM %s", tableName));
assertColumnTypes(queryResult);
assertThat(queryResult).containsOnly(row(127, 32767, 2147483647, 9223372036854775807L, 123.345f, 234.567, new BigDecimal("346"), new BigDecimal("345.67800"), Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)), Date.valueOf("2015-05-10"), "ala ma kota", "ala ma kot", "ala ma ", true, "kot binarny".getBytes(UTF_8)));
}
use of io.trino.tempto.Requires in project trino by trinodb.
the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesAvro.
@Requires(AvroRequirements.class)
@Test(groups = JDBC)
public void testSelectAllDatatypesAvro() {
String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_AVRO).getNameInDatabase();
onHive().executeQuery(format("INSERT INTO %s VALUES(" + "2147483647," + "9223372036854775807," + "123.345," + "234.567," + "346," + "345.67800," + "'" + Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)).toString() + "'," + "'" + Date.valueOf("2015-05-10") + "'," + "'ala ma kota'," + "'ala ma kot'," + "'ala ma '," + "true," + "'kot binarny'" + ")", tableName));
assertThat(onTrino().executeQuery("SHOW COLUMNS FROM " + tableName).project(1, 2)).containsExactlyInOrder(row("c_int", "integer"), row("c_bigint", "bigint"), row("c_float", "real"), row("c_double", "double"), row("c_decimal", "decimal(10,0)"), row("c_decimal_w_params", "decimal(10,5)"), row("c_timestamp", "timestamp(3)"), row("c_date", "date"), row("c_string", "varchar"), row("c_varchar", "varchar(10)"), row("c_char", "char(10)"), row("c_boolean", "boolean"), row("c_binary", "varbinary"));
QueryResult queryResult = onTrino().executeQuery("SELECT * FROM " + tableName);
assertThat(queryResult).hasColumns(INTEGER, BIGINT, REAL, DOUBLE, DECIMAL, DECIMAL, TIMESTAMP, DATE, VARCHAR, VARCHAR, CHAR, BOOLEAN, VARBINARY);
assertThat(queryResult).containsOnly(row(2147483647, 9223372036854775807L, 123.345f, 234.567, new BigDecimal("346"), new BigDecimal("345.67800"), isHiveWithBrokenAvroTimestamps() ? // TODO (https://github.com/trinodb/trino/issues/1218) requires https://issues.apache.org/jira/browse/HIVE-21002
Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 18, 0, 35, 123_000_000)) : Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)), Date.valueOf("2015-05-10"), "ala ma kota", "ala ma kot", "ala ma ", true, "kot binarny".getBytes(UTF_8)));
}
use of io.trino.tempto.Requires in project trino by trinodb.
the class TestJdbc method shouldGetColumns.
@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldGetColumns() throws SQLException {
QueryResult result = QueryResult.forResultSet(metaData().getColumns("hive", "default", "nation", null));
assertThat(result).matches(sqlResultDescriptorForResource("io/trino/tests/product/jdbc/get_nation_columns.result"));
}
Aggregations