use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class KafkaAvroSmokeTest method testSelectStructuralDataType.
@Test(groups = { KAFKA })
@Requires(StructuralDataTypeTable.class)
public void testSelectStructuralDataType() throws SQLException {
QueryResult queryResult = query(format("SELECT a[1], a[2], m['key1'] FROM (SELECT c_array as a, c_map as m FROM %s.%s) t", KAFKA_CATALOG, STRUCTURAL_AVRO_TABLE_NAME));
assertThat(queryResult).containsOnly(row(100, 102, "value1"));
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class TestRoles method testListRoles.
@Test(groups = { ROLES, AUTHORIZATION, PROFILE_SPECIFIC_TESTS })
public void testListRoles() {
onPresto().executeQuery(format("CREATE ROLE %s", ROLE1));
QueryResult expected = onHive().executeQuery("SHOW ROLES");
QueryResult actual = onPresto().executeQuery("SELECT * FROM hive.information_schema.roles");
assertThat(actual.rows()).containsOnly(expected.rows().toArray(new List[] {}));
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class TestTablePartitioningInsertInto method testQuerySplitsNumber.
private void testQuerySplitsNumber(String condition, int expectedProcessedSplits) throws Exception {
String partitionedNation = mutableTablesState().get(NATION_PARTITIONED_BY_BIGINT_REGIONKEY.getTableHandle()).getNameInDatabase();
String targetNation = mutableTablesState().get(TARGET_NATION_NAME).getNameInDatabase();
String query = String.format("INSERT INTO %s SELECT p_nationkey, p_name, p_regionkey, p_comment FROM %s WHERE %s", targetNation, partitionedNation, condition);
QueryResult queryResult = query(query);
long processedLinesCount = getProcessedLinesCount(query, queryResult);
int expectedLinesCount = expectedProcessedSplits * NATION_PARTITIONED_BY_REGIONKEY_NUMBER_OF_LINES_PER_SPLIT;
assertThat(processedLinesCount).isEqualTo(expectedLinesCount);
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class TestTablePartitioningSelect method testSelectPartitionedHiveTableDifferentFormats.
@Test
public void testSelectPartitionedHiveTableDifferentFormats() {
String tableNameInDatabase = tablesState.get(TABLE_NAME).getNameInDatabase();
String selectFromOnePartitionsSql = "SELECT * FROM " + tableNameInDatabase + " WHERE part_col = 2";
QueryResult onePartitionQueryResult = query(selectFromOnePartitionsSql);
assertThat(onePartitionQueryResult).containsOnly(row(42, 2));
try {
// This query should fail or return null values for invalid partition data
assertThat(query("SELECT * FROM " + tableNameInDatabase)).containsOnly(row(42, 2), row(null, 1));
} catch (QueryExecutionException expectedDueToInvalidPartitionData) {
}
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class TestSelect method testAllDatatypes.
@Test(groups = { SQL_SERVER, PROFILE_SPECIFIC_TESTS })
public void testAllDatatypes() {
String sql = format("SELECT bi, si, i, ti, f, r, c, vc, te, nc, nvc, nt, d, dt, dt2, sdt, pf30, pf22 " + "FROM %s", ALL_TYPES_TABLE_NAME);
QueryResult queryResult = onPresto().executeQuery(sql);
assertThat(queryResult).hasColumns(BIGINT, SMALLINT, INTEGER, TINYINT, DOUBLE, REAL, CHAR, VARCHAR, VARCHAR, CHAR, VARCHAR, VARCHAR, DATE, TIMESTAMP, TIMESTAMP, TIMESTAMP, DOUBLE, REAL).containsOnly(row(Long.MIN_VALUE, Short.MIN_VALUE, Integer.MIN_VALUE, Byte.MIN_VALUE, Double.MIN_VALUE, Float.valueOf("-3.40E+38"), "\0 ", "\0", "\0", "\0 ", "\0", "\0", Date.valueOf("0001-01-02"), Timestamp.valueOf("1753-01-01 00:00:00.000"), Timestamp.valueOf("0001-01-01 00:00:00.000"), Timestamp.valueOf("1900-01-01 00:00:00"), Double.MIN_VALUE, Float.valueOf("-3.40E+38")), row(Long.MAX_VALUE, Short.MAX_VALUE, Integer.MAX_VALUE, Byte.MAX_VALUE, Double.MAX_VALUE, Float.MAX_VALUE, "abcd", "abcdef", "abcd", "abcde", "abcdefg", "abcd", Date.valueOf("9999-12-31"), Timestamp.valueOf("9999-12-31 23:59:59.997"), Timestamp.valueOf("9999-12-31 23:59:59.999"), Timestamp.valueOf("2079-06-06 00:00:00"), Double.valueOf("12345678912.3456756"), Float.valueOf("12345678.6557")), row(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null));
}
Aggregations