use of io.prestosql.testing.MaterializedRow 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.MaterializedRow in project hetu-core by openlookeng.
the class AbstractTestAggregations method testGroupByNanRow.
@Test
public void testGroupByNanRow() {
MaterializedResult actual = computeActual("SELECT a, b, c FROM (VALUES ROW(nan(), 1, 2), ROW(nan(), 1, 2)) t(a, b, c) GROUP BY 1, 2, 3");
List<MaterializedRow> actualRows = actual.getMaterializedRows();
assertEquals(actualRows.size(), 1);
assertTrue(Double.isNaN((Double) actualRows.get(0).getField(0)));
assertEquals(actualRows.get(0).getField(1), 1);
assertEquals(actualRows.get(0).getField(2), 2);
}
use of io.prestosql.testing.MaterializedRow in project hetu-core by openlookeng.
the class AbstractTestAggregations method testGroupByNanArray.
@Test
public void testGroupByNanArray() {
MaterializedResult actual = computeActual("SELECT a FROM (VALUES (ARRAY[nan(), 2e0, 3e0]), (ARRAY[nan(), 2e0, 3e0])) t(a) GROUP BY a");
List<MaterializedRow> actualRows = actual.getMaterializedRows();
assertEquals(actualRows.size(), 1);
assertTrue(Double.isNaN(((List<Double>) actualRows.get(0).getField(0)).get(0)));
assertEquals(((List<Double>) actualRows.get(0).getField(0)).get(1), 2.0);
assertEquals(((List<Double>) actualRows.get(0).getField(0)).get(2), 3.0);
}
use of io.prestosql.testing.MaterializedRow in project hetu-core by openlookeng.
the class AbstractTestJoinQueries method testJoinWithNonDeterministicLessThan.
@Test
public void testJoinWithNonDeterministicLessThan() {
MaterializedRow actualRow = getOnlyElement(computeActual("SELECT count(*) FROM " + "customer c1 JOIN customer c2 ON c1.nationkey=c2.nationkey " + "WHERE c1.custkey - RANDOM(CAST(c1.custkey AS BIGINT)) < c2.custkey").getMaterializedRows());
assertEquals(actualRow.getFieldCount(), 1);
// this should be around ~69000
long actualCount = (Long) actualRow.getField(0);
MaterializedRow expectedAtLeastRow = getOnlyElement(computeActual("SELECT count(*) FROM " + "customer c1 JOIN customer c2 ON c1.nationkey=c2.nationkey " + "WHERE c1.custkey < c2.custkey").getMaterializedRows());
assertEquals(expectedAtLeastRow.getFieldCount(), 1);
// this is exactly 45022
long expectedAtLeastCount = (Long) expectedAtLeastRow.getField(0);
// Technically non-deterministic unit test but has hopefully a next to impossible chance of a false positive
assertTrue(actualCount > expectedAtLeastCount);
}
use of io.prestosql.testing.MaterializedRow in project hetu-core by openlookeng.
the class AbstractTestQueries method testValuesWithNonTrivialType.
@Test
public void testValuesWithNonTrivialType() {
MaterializedResult actual = computeActual("VALUES (0E0/0E0, 1E0/0E0, -1E0/0E0)");
List<MaterializedRow> rows = actual.getMaterializedRows();
assertEquals(rows.size(), 1);
MaterializedRow row = rows.get(0);
assertTrue(((Double) row.getField(0)).isNaN());
assertEquals(row.getField(1), Double.POSITIVE_INFINITY);
assertEquals(row.getField(2), Double.NEGATIVE_INFINITY);
}
Aggregations