use of io.trino.tempto.query.QueryResult 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.query.QueryResult 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.query.QueryResult in project trino by trinodb.
the class TestAvroSchemaUrl method isOnHdp.
private boolean isOnHdp() {
try {
QueryResult queryResult = onHive().executeQuery("SET system:hdp.version");
String hdpVersion = (String) queryResult.row(0).get(0);
return !isNullOrEmpty(hdpVersion);
} catch (QueryExecutionException e) {
return false;
}
}
use of io.trino.tempto.query.QueryResult in project trino by trinodb.
the class TestComments method testCommentTable.
@Test(groups = COMMENT)
public void testCommentTable() {
String createTableSql = format("" + "CREATE TABLE hive.default.%s (\n" + " c1 bigint\n" + ")\n" + "COMMENT 'old comment'\n" + "WITH (\n" + " format = 'RCBINARY'\n" + ")", COMMENT_TABLE_NAME);
onTrino().executeQuery(createTableSql);
QueryResult actualResult = onTrino().executeQuery("SHOW CREATE TABLE " + COMMENT_TABLE_NAME);
assertThat((String) actualResult.row(0).get(0)).matches(tableWithCommentPattern(COMMENT_TABLE_NAME, Optional.of("old comment")));
onTrino().executeQuery(format("COMMENT ON TABLE %s IS 'new comment'", COMMENT_TABLE_NAME));
actualResult = onTrino().executeQuery("SHOW CREATE TABLE " + COMMENT_TABLE_NAME);
assertThat((String) actualResult.row(0).get(0)).matches(tableWithCommentPattern(COMMENT_TABLE_NAME, Optional.of("new comment")));
onTrino().executeQuery(format("COMMENT ON TABLE %s IS ''", COMMENT_TABLE_NAME));
actualResult = onTrino().executeQuery("SHOW CREATE TABLE " + COMMENT_TABLE_NAME);
assertThat((String) actualResult.row(0).get(0)).matches(tableWithCommentPattern(COMMENT_TABLE_NAME, Optional.of("")));
onTrino().executeQuery(format("COMMENT ON TABLE %s IS NULL", COMMENT_TABLE_NAME));
actualResult = onTrino().executeQuery("SHOW CREATE TABLE " + COMMENT_TABLE_NAME);
assertThat((String) actualResult.row(0).get(0)).matches(tableWithCommentPattern(COMMENT_TABLE_NAME, Optional.empty()));
}
use of io.trino.tempto.query.QueryResult in project trino by trinodb.
the class TestHiveTransactionalTable method verifyOriginalFiles.
private void verifyOriginalFiles(String tableName, String whereClause) {
QueryResult result = onTrino().executeQuery(format("SELECT DISTINCT \"$path\" FROM %s %s", tableName, whereClause));
String path = (String) result.row(0).get(0);
checkArgument(ORIGINAL_FILE_MATCHER.matcher(path).matches(), "Path should be original file path, but isn't, path: %s", path);
}
Aggregations