Search in sources :

Example 1 with MaterializedRow

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");
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) MaterializedRow(io.prestosql.testing.MaterializedRow) Test(org.testng.annotations.Test) AbstractTestIntegrationSmokeTest(io.prestosql.tests.AbstractTestIntegrationSmokeTest)

Example 2 with MaterializedRow

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);
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) MaterializedRow(io.prestosql.testing.MaterializedRow) Test(org.testng.annotations.Test)

Example 3 with MaterializedRow

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);
}
Also used : List(java.util.List) MaterializedResult(io.prestosql.testing.MaterializedResult) MaterializedRow(io.prestosql.testing.MaterializedRow) Test(org.testng.annotations.Test)

Example 4 with MaterializedRow

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);
}
Also used : MaterializedRow(io.prestosql.testing.MaterializedRow) Test(org.testng.annotations.Test)

Example 5 with MaterializedRow

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);
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) MaterializedRow(io.prestosql.testing.MaterializedRow) Test(org.testng.annotations.Test)

Aggregations

MaterializedRow (io.prestosql.testing.MaterializedRow)70 MaterializedResult (io.prestosql.testing.MaterializedResult)62 Test (org.testng.annotations.Test)45 ImmutableList (com.google.common.collect.ImmutableList)10 List (java.util.List)10 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)9 ConnectorTableHandle (io.prestosql.spi.connector.ConnectorTableHandle)8 Plan (io.prestosql.sql.planner.Plan)8 AbstractTestIntegrationSmokeTest (io.prestosql.tests.AbstractTestIntegrationSmokeTest)8 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)7 ImmutableMap (com.google.common.collect.ImmutableMap)7 Session (io.prestosql.Session)7 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)7 ConnectorMetadata (io.prestosql.spi.connector.ConnectorMetadata)7 Constraint (io.prestosql.spi.connector.Constraint)7 TestingConnectorSession (io.prestosql.testing.TestingConnectorSession)7 ArrayList (java.util.ArrayList)7 Language (org.intellij.lang.annotations.Language)7 Assert.assertTrue (org.testng.Assert.assertTrue)7 HiveColumnHandle.bucketColumnHandle (io.prestosql.plugin.hive.HiveColumnHandle.bucketColumnHandle)6