use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class CreateTableAsSelect method testCreateTableAsSelect.
@Requires(ImmutableNationTable.class)
@Test(groups = { JDBC, MYSQL })
public void testCreateTableAsSelect() {
QueryResult queryResult = query(format("CREATE TABLE mysql.%s AS SELECT * FROM nation", TABLE_NAME));
assertThat(queryResult).containsOnly(row(25));
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class TestCsv method assertSelect.
private static void assertSelect(String query, String tableName) {
QueryResult expected = query(format(query, "tpch." + TPCH_SCHEMA + ".lineitem"));
List<Row> expectedRows = expected.rows().stream().map((columns) -> row(columns.toArray())).collect(toImmutableList());
QueryResult actual = query(format(query, tableName));
List<Row> actualRows = actual.rows().stream().map((columns) -> row(columns.toArray())).collect(toImmutableList());
assertThat(actual).hasColumns(expected.getColumnTypes()).containsOnly(expectedRows);
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
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(query("SHOW COLUMNS FROM " + tableName).project(1, 2)).containsExactly(row("int_to_bigint", "bigint"), row("float_to_double", "double"), row("id", "bigint"));
QueryResult queryResult = query("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.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class TestHivePartitionsTable method testShowPartitionsFromHiveTable.
@Test(groups = { HIVE_PARTITIONING })
public void testShowPartitionsFromHiveTable() {
String tableNameInDatabase = tablesState.get(PARTITIONED_TABLE).getNameInDatabase();
String partitionsTable = "\"" + tableNameInDatabase + "$partitions\"";
QueryResult partitionListResult;
partitionListResult = query("SELECT * FROM " + partitionsTable);
assertThat(partitionListResult).containsExactly(row(1), row(2));
assertColumnNames(partitionListResult, "part_col");
partitionListResult = query(format("SELECT * FROM %s WHERE part_col = 1", partitionsTable));
assertThat(partitionListResult).containsExactly(row(1));
assertColumnNames(partitionListResult, "part_col");
assertThat(() -> query(format("SELECT * FROM %s WHERE no_such_column = 1", partitionsTable))).failsWithMessage("Column 'no_such_column' cannot be resolved");
assertThat(() -> query(format("SELECT * FROM %s WHERE col = 1", partitionsTable))).failsWithMessage("Column 'col' cannot be resolved");
}
use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.
the class TestHivePartitionsTable method testShowPartitionsFromHiveTableWithTooManyPartitions.
@Test(groups = { HIVE_PARTITIONING })
public void testShowPartitionsFromHiveTableWithTooManyPartitions() {
String tableName = tablesState.get(PARTITIONED_TABLE_WITH_VARIABLE_PARTITIONS).getNameInDatabase();
String partitionsTable = "\"" + tableName + "$partitions\"";
createPartitions(tableName, TOO_MANY_PARTITIONS);
// Verify we created enough partitions for the test to be meaningful
assertThatThrownBy(() -> query("SELECT * FROM " + tableName)).hasMessageMatching(".*: Query over table '\\S+' can potentially read more than \\d+ partitions");
QueryResult partitionListResult;
partitionListResult = query(format("SELECT * FROM %s WHERE part_col < 7", partitionsTable));
assertThat(partitionListResult).containsExactly(row(0), row(1), row(2), row(3), row(4), row(5), row(6));
assertColumnNames(partitionListResult, "part_col");
partitionListResult = query(format("SELECT * FROM %s WHERE part_col < -10", partitionsTable));
assertThat(partitionListResult).hasNoRows();
partitionListResult = query(format("SELECT * FROM %s ORDER BY part_col LIMIT 7", partitionsTable));
assertThat(partitionListResult).containsExactly(row(0), row(1), row(2), row(3), row(4), row(5), row(6));
}
Aggregations