use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.
the class TestStatistics method testUsingStatistics.
@Test
public void testUsingStatistics() {
assertQuerySucceeds("CREATE TABLE test_orders AS SELECT * FROM tpch.tiny.orders");
assertQuerySucceeds("CREATE TABLE test_nation AS SELECT * FROM tpch.tiny.nation");
assertQuerySucceeds("CREATE TABLE test_customer AS SELECT * FROM tpch.tiny.customer");
assertQuerySucceeds("CREATE TABLE test_lineitem AS SELECT * FROM tpch.tiny.lineitem");
String query = "select count(*) from test_customer, test_lineitem, test_nation, test_orders where test_nation.nationkey=5";
MaterializedResult result1 = computeActual(query);
assertQuerySucceeds("ANALYZE test_orders");
assertQuerySucceeds("ANALYZE test_nation");
assertQuerySucceeds("ANALYZE test_customer");
assertQuerySucceeds("ANALYZE test_customer");
MaterializedResult result2 = computeActual(query);
assertEquals(result1, result2);
}
use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.
the class TestMySqlIntegrationSmokeTest method testMySqlTinyint1.
@Test
public void testMySqlTinyint1() throws Exception {
execute("CREATE TABLE tpch.mysql_test_tinyint1 (c_tinyint tinyint(1))");
MaterializedResult actual = computeActual("SHOW COLUMNS FROM mysql_test_tinyint1");
MaterializedResult expected = MaterializedResult.resultBuilder(getSession(), VARCHAR, VARCHAR, VARCHAR, VARCHAR).row("c_tinyint", "tinyint", "", "").build();
assertEquals(actual, expected);
execute("INSERT INTO tpch.mysql_test_tinyint1 VALUES (127), (-128)");
MaterializedResult materializedRows = computeActual("SELECT * FROM tpch.mysql_test_tinyint1 WHERE c_tinyint = 127");
assertEquals(materializedRows.getRowCount(), 1);
MaterializedRow row = getOnlyElement(materializedRows);
assertEquals(row.getFields().size(), 1);
assertEquals(row.getField(0), (byte) 127);
assertUpdate("DROP TABLE mysql_test_tinyint1");
}
use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.
the class TestMySqlIntegrationSmokeTest method testDescribeTable.
@Override
public void testDescribeTable() {
// we need specific implementation of this tests due to specific Presto<->Mysql varchar length mapping.
MaterializedResult actualColumns = computeActual("DESC ORDERS").toTestTypes();
MaterializedResult expectedColumns = MaterializedResult.resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR, VARCHAR, VARCHAR, VARCHAR).row("orderkey", "bigint", "", "").row("custkey", "bigint", "", "").row("orderstatus", "varchar(255)", "", "").row("totalprice", "double", "", "").row("orderdate", "date", "", "").row("orderpriority", "varchar(255)", "", "").row("clerk", "varchar(255)", "", "").row("shippriority", "integer", "", "").row("comment", "varchar(255)", "", "").build();
assertEquals(actualColumns, expectedColumns);
}
use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.
the class TestTpcds method testSelect.
@Test
public void testSelect() {
MaterializedResult actual = computeActual("SELECT c_first_name, c_last_name, ca_address_sk, ca_gmt_offset " + "FROM customer JOIN customer_address ON c_current_addr_sk = ca_address_sk " + "WHERE ca_address_sk = 4");
MaterializedResult expected = resultBuilder(getSession(), actual.getTypes()).row("James ", "Brown ", 4L, new BigDecimal("-7.00")).build();
assertEquals(expected, actual);
actual = computeActual("SELECT c_first_name, c_last_name " + "FROM customer JOIN customer_address ON c_current_addr_sk = ca_address_sk " + "WHERE ca_address_sk = 4 AND ca_gmt_offset = DECIMAL '-7.00'");
expected = resultBuilder(getSession(), actual.getTypes()).row("James ", "Brown ").build();
assertEquals(expected, actual);
}
use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.
the class TestMergeSortedPages method testMultipleStreams.
@Test
public void testMultipleStreams() {
List<Type> types = ImmutableList.of(INTEGER, INTEGER, INTEGER);
MaterializedResult actual = mergeSortedPages(types, ImmutableList.of(0, 1), ImmutableList.of(ASC_NULLS_FIRST, DESC_NULLS_FIRST), ImmutableList.of(rowPagesBuilder(types).row(1, 1, 2).pageBreak().pageBreak().row(8, 1, 1).row(19, 1, 3).row(27, 1, 4).row(41, 2, 5).pageBreak().row(55, 1, 2).row(89, 1, 3).row(100, 2, 6).row(100, 2, 8).row(101, 1, 4).row(202, 1, 3).row(399, 2, 2).pageBreak().row(400, 1, 1).row(401, 1, 7).pageBreak().row(402, 1, 6).build(), rowPagesBuilder(types).pageBreak().row(2, 1, 2).row(8, 1, 1).row(19, 1, 3).row(25, 1, 4).row(26, 2, 5).pageBreak().row(56, 1, 2).row(66, 1, 3).row(77, 1, 4).row(88, 1, 3).row(99, 1, 1).pageBreak().row(99, 2, 2).row(100, 1, 7).build(), rowPagesBuilder(types).row(8, 1, 1).row(88, 1, 3).pageBreak().row(89, 1, 3).pageBreak().row(90, 1, 3).pageBreak().row(91, 1, 4).row(92, 2, 5).pageBreak().row(93, 1, 2).row(94, 1, 3).row(95, 1, 4).row(97, 1, 3).row(98, 2, 2).row(100, 1, 7).build()));
MaterializedResult expected = resultBuilder(TEST_SESSION, types).row(1, 1, 2).row(2, 1, 2).row(8, 1, 1).row(8, 1, 1).row(8, 1, 1).row(19, 1, 3).row(19, 1, 3).row(25, 1, 4).row(26, 2, 5).row(27, 1, 4).row(41, 2, 5).row(55, 1, 2).row(56, 1, 2).row(66, 1, 3).row(77, 1, 4).row(88, 1, 3).row(88, 1, 3).row(89, 1, 3).row(89, 1, 3).row(90, 1, 3).row(91, 1, 4).row(92, 2, 5).row(93, 1, 2).row(94, 1, 3).row(95, 1, 4).row(97, 1, 3).row(98, 2, 2).row(99, 1, 1).row(99, 2, 2).row(100, 2, 6).row(100, 2, 8).row(100, 1, 7).row(100, 1, 7).row(101, 1, 4).row(202, 1, 3).row(399, 2, 2).row(400, 1, 1).row(401, 1, 7).row(402, 1, 6).build();
assertEquals(actual, expected);
}
Aggregations