Search in sources :

Example 21 with MaterializedResult

use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.

the class AbstractTestDistributedQueries method testDefectCase.

@Test
public void testDefectCase() {
    if (!supportsViews()) {
        return;
    }
    assertUpdate("create table error(t int, u int)");
    String sql = "select *\n" + "from error\n" + "where\n" + "(t=51 and u=-4)\n" + "or (t=52 and u=-10)\t\t\n" + "or (t=46 and u=-2)\n" + "or (t=46 and u=-1)\n" + "or (t=43 and u=3)\n" + "or (t=39 and u=-7)\n" + "or (t=48 and u=-4)\n" + "or (t=42 and u=-8)\n" + "or (t=43 and u=-6)\n" + "or (t=44 and u=4)\n" + "or (t=37 and u=-6)\n" + "or (t=38 and u=-8)\n" + "or (t=46 and u=12)\n" + "or (t=39 and u=17)\n" + "or (t=42 and u=-9)\n" + "or (t=45 and u=9)\n" + "or (t=46 and u=3)\n" + "or (t=37 and u=-9)\n" + "or (t=47 and u=9)\n" + "or (t=40 and u=-6)\n" + "or (t=48 and u=20)\n" + "or (t=49 and u=12)\n" + "or (t=49 and u=17)\n" + "or (t=48 and u=1)\n" + "or (t=50 and u=11)\n" + "or (t=50 and u=22)\n" + "or (t=51 and u=1)\n" + "or (t=52 and u=-8)\n" + "or (t=47 and u=-2)\n" + "or (t=40 and u=0)\n" + "or (t=47 and u=-1)\n" + "or (t=51 and u=-5)\n" + "or (t=42 and u=15)\n" + "or (t=44 and u=-2)\n" + "or (t=44 and u=-1)\n" + "or (t=51 and u=12)\n" + "or (t=39 and u=-4)\n" + "or (t=47 and u=19)\n" + "or (t=42 and u=-3)\n" + "or (t=43 and u=-7)\n" + "or (t=46 and u=9)\n" + "or (t=37 and u=-3)\n" + "or (t=48 and u=14)\n" + "or (t=49 and u=15)\n" + "or (t=41 and u=-6)\n" + "or (t=47 and u=12)\n" + "or (t=45 and u=12)\n" + "or (t=48 and u=17)\n" + "or (t=50 and u=1)\n" + "or (t=50 and u=12)\n" + "or (t=40 and u=-9)\n" + "or (t=51 and u=19)\n" + "or (t=48 and u=-1)\n" + "or (t=52 and u=8)\n" + "or (t=52 and u=12)\n" + "or (t=51 and u=22)\n" + "or (t=52 and u=-3)\n" + "or (t=47 and u=-3)\n" + "or (t=45 and u=-2)\n" + "or (t=42 and u=0)\n" + "or (t=39 and u=-10)\n" + "or (t=40 and u=16)\n" + "or (t=38 and u=15)\n" + "or (t=45 and u=-1)\n" + "or (t=44 and u=3)\n" + "or (t=43 and u=13)\n" + "or (t=51 and u=21)\n" + "or (t=49 and u=5)\n" + "or (t=48 and u=11)\n" + "or (t=42 and u=-2)\n" + "or (t=42 and u=-1)\n" + "or (t=45 and u=2)\n" + "or (t=46 and u=10)\n" + "or (t=50 and u=2)\n" + "or (t=49 and u=10)\n" + "or (t=47 and u=3)\n" + "or (t=51 and u=6)\n" + "or (t=52 and u=1)\n" + "or (t=50 and u=17)\n" + "or (t=48 and u=5)\n" + "or (t=43 and u=-2)\n" + "or (t=43 and u=-1)\n" + "or (t=44 and u=0)\n" + "or (t=38 and u=-4)\n" + "or (t=49 and u=0)\n" + "or (t=47 and u=21)\n" + "or (t=46 and u=7)\n" + "or (t=45 and u=5)\n" + "or (t=48 and u=3)\n" + "or (t=48 and u=8)\n" + "or (t=50 and u=7)\n" + "or (t=40 and u=-2)\n" + "or (t=40 and u=-1)\n" + "or (t=47 and u=6)\n" + "or (t=49 and u=21)\n" + "or (t=51 and u=5)\n" + "or (t=51 and u=11)\n" + "or (t=50 and u=18)\n" + "or (t=52 and u=6)\n" + "or (t=40 and u=4)\n" + "or (t=51 and u=14)\n" + "or (t=52 and u=-9)\n" + "or (t=48 and u=-5)\n" + "or (t=43 and u=2)\n" + "or (t=39 and u=-8)\n" + "or (t=48 and u=-3)\n" + "or (t=42 and u=-7)\n" + "or (t=43 and u=-3)\n" + "or (t=44 and u=5)\n" + "or (t=37 and u=-7)\n" + "or (t=38 and u=-7)\n" + "or (t=46 and u=13)\n" + "or (t=41 and u=-2)\n" + "or (t=41 and u=-1)\n" + "or (t=45 and u=8)\n" + "or (t=46 and u=0)\n" + "or (t=47 and u=8)\n" + "or (t=48 and u=21)\n" + "or (t=40 and u=-5)\n" + "or (t=47 and u=5)\n" + "or (t=49 and u=3)\n" + "or (t=49 and u=16)\n" + "or (t=50 and u=8)\n" + "or (t=51 and u=0)\n" + "or (t=50 and u=23)\n" + "or (t=41 and u=15)\n" + "or (t=42 and u=12)\n" + "or (t=43 and u=-9)\n" + "or (t=43 and u=1)\n" + "or (t=38 and u=-9)\n" + "or (t=41 and u=17)\n" + "or (t=47 and u=18)\n" + "or (t=42 and u=-6)\n" + "or (t=43 and u=-8)\n" + "or (t=44 and u=10)\n" + "or (t=37 and u=-4)\n" + "or (t=38 and u=-6)\n" + "or (t=48 and u=15)\n" + "or (t=41 and u=-7)\n" + "or (t=47 and u=15)\n" + "or (t=45 and u=11)\n" + "or (t=48 and u=18)\n" + "or (t=49 and u=14)\n" + "or (t=50 and u=13)\n" + "or (t=40 and u=-8)\n" + "or (t=49 and u=19)\n" + "or (t=52 and u=13)\n" + "or (t=48 and u=0)\n" + "or (t=52 and u=-2)\n" + "or (t=52 and u=-1)\n" + "or (t=37 and u=15)\n" + "or (t=42 and u=1)\n" + "or (t=43 and u=12)\n" + "or (t=51 and u=20)\n" + "or (t=49 and u=4)\n" + "or (t=39 and u=9)\n" + "or (t=46 and u=11)\n" + "or (t=45 and u=1)\n" + "or (t=47 and u=17)\n" + "or (t=48 and u=12)\n" + "or (t=50 and u=3)\n" + "or (t=49 and u=9)\n" + "or (t=47 and u=2)\n" + "or (t=51 and u=9)\n" + "or (t=51 and u=13)\n" + "or (t=52 and u=2)\n" + "or (t=50 and u=14)\n" + "or (t=51 and u=16)\n" + "or (t=52 and u=15)\n" + "or (t=42 and u=2)\n" + "or (t=48 and u=6)\n" + "or (t=44 and u=1)\n" + "or (t=43 and u=11)\n" + "or (t=38 and u=-3)\n" + "or (t=49 and u=7)\n" + "or (t=47 and u=20)\n" + "or (t=46 and u=4)\n" + "or (t=45 and u=4)\n" + "or (t=44 and u=12)\n" + "or (t=48 and u=9)\n" + "or (t=50 and u=4)\n" + "or (t=49 and u=20)\n" + "or (t=41 and u=-9)\n" + "or (t=47 and u=1)\n" + "or (t=51 and u=4)\n" + "or (t=52 and u=7)\n" + "or (t=52 and u=17)\n" + "or (t=50 and u=19)\n" + "or (t=52 and u=16)\n" + "or (t=51 and u=-2)\n" + "or (t=51 and u=-1)\n" + "or (t=41 and u=0)\n" + "or (t=39 and u=-5)\n" + "or (t=48 and u=-2)\n" + "or (t=46 and u=18)\n" + "or (t=43 and u=-4)\n" + "or (t=44 and u=6)\n" + "or (t=37 and u=-8)\n" + "or (t=38 and u=-1)\n" + "or (t=38 and u=-2)\n" + "or (t=41 and u=-3)\n" + "or (t=46 and u=1)\n" + "or (t=45 and u=7)\n" + "or (t=47 and u=11)\n" + "or (t=48 and u=22)\n" + "or (t=49 and u=2)\n" + "or (t=40 and u=-4)\n" + "or (t=47 and u=4)\n" + "or (t=48 and u=2)\n" + "or (t=50 and u=9)\n" + "or (t=51 and u=3)\n" + "or (t=52 and u=4)\n" + "or (t=50 and u=20)\n" + "or (t=41 and u=14)\n" + "or (t=51 and u=-3)\n" + "or (t=42 and u=13)\n" + "or (t=51 and u=15)\n" + "or (t=49 and u=-2)\n" + "or (t=49 and u=-1)\n" + "or (t=43 and u=-10)\n" + "or (t=43 and u=0)\n" + "or (t=39 and u=-2)\n" + "or (t=39 and u=-1)\n" + "or (t=41 and u=16)\n" + "or (t=42 and u=-5)\n" + "or (t=43 and u=-5)\n" + "or (t=37 and u=-5)\n" + "or (t=38 and u=-5)\n" + "or (t=44 and u=11)\n" + "or (t=41 and u=-8)\n" + "or (t=46 and u=2)\n" + "or (t=45 and u=10)\n" + "or (t=47 and u=14)\n" + "or (t=48 and u=19)\n" + "or (t=49 and u=13)\n" + "or (t=40 and u=-7)\n" + "or (t=49 and u=18)\n" + "or (t=50 and u=10)\n" + "or (t=52 and u=9)\n" + "or (t=52 and u=14)\n" + "or (t=41 and u=9)\n" + "or (t=42 and u=14)\n" + "or (t=38 and u=13)\n" + "or (t=51 and u=23)\n" + "or (t=39 and u=-3)\n" + "or (t=47 and u=16)\n" + "or (t=38 and u=16)\n" + "or (t=42 and u=-4)\n" + "or (t=44 and u=8)\n" + "or (t=37 and u=-2)\n" + "or (t=45 and u=0)\n" + "or (t=46 and u=8)\n" + "or (t=41 and u=-5)\n" + "or (t=47 and u=13)\n" + "or (t=48 and u=13)\n" + "or (t=48 and u=16)\n" + "or (t=49 and u=8)\n" + "or (t=50 and u=15)\n" + "or (t=51 and u=8)\n" + "or (t=52 and u=3)\n" + "or (t=40 and u=9)\n" + "or (t=52 and u=-4)\n" + "or (t=42 and u=3)\n" + "or (t=39 and u=-9)\n" + "or (t=48 and u=7)\n" + "or (t=38 and u=14)\n" + "or (t=44 and u=2)\n" + "or (t=51 and u=18)\n" + "or (t=49 and u=6)\n" + "or (t=48 and u=10)\n" + "or (t=46 and u=5)\n" + "or (t=45 and u=3)\n" + "or (t=51 and u=7)\n" + "or (t=50 and u=5)\n" + "or (t=49 and u=11)\n" + "or (t=47 and u=0)\n" + "or (t=51 and u=10)\n" + "or (t=52 and u=0)\n" + "or (t=50 and u=16)\n" + "or (t=42 and u=9)\n" + "or (t=39 and u=-6)\n" + "or (t=48 and u=4)\n" + "or (t=46 and u=19)\n" + "or (t=44 and u=7)\n" + "or (t=51 and u=17)\n" + "or (t=52 and u=11)\n" + "or (t=49 and u=1)\n" + "or (t=41 and u=-4)\n" + "or (t=46 and u=6)\n" + "or (t=45 and u=6)\n" + "or (t=47 and u=10)\n" + "or (t=51 and u=2)\n" + "or (t=50 and u=6)\n" + "or (t=40 and u=-3)\n" + "or (t=47 and u=7)\n" + "or (t=49 and u=22)\n" + "or (t=52 and u=10) " + "or (t=52 and u=5) " + "or (t=50 and u=21) " + "or (t=52 and u=-5)";
    MaterializedResult result = computeActual(sql);
    System.out.println("Query Output: " + result);
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 22 with MaterializedResult

use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.

the class AbstractTestDistributedQueries method testResetSession.

@Test
public void testResetSession() {
    MaterializedResult result = computeActual(getSession(), "RESET SESSION test_string");
    assertTrue((Boolean) getOnlyElement(result).getField(0));
    assertEquals(result.getResetSessionProperties(), ImmutableSet.of("test_string"));
    result = computeActual(getSession(), format("RESET SESSION %s.connector_string", TESTING_CATALOG));
    assertTrue((Boolean) getOnlyElement(result).getField(0));
    assertEquals(result.getResetSessionProperties(), ImmutableSet.of(TESTING_CATALOG + ".connector_string"));
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 23 with MaterializedResult

use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.

the class AbstractTestDistributedQueries method testLargeFilterExpression.

@Test
public void testLargeFilterExpression() {
    String sql = "SELECT * FROM orders WHERE (custkey=1 AND shippriority=1)" + " OR (custkey=2 AND shippriority= 2)" + " OR (custkey=3 AND shippriority= 3)" + " OR (custkey=4 AND shippriority= 4)" + " OR (custkey=5 AND shippriority= 5)" + " OR (custkey=6 AND shippriority= 6)" + " OR (custkey=7 AND shippriority= 7)" + " OR (custkey=8 AND shippriority= 8)" + " OR (custkey=9 AND shippriority= 9)" + " OR (custkey=10 AND shippriority= 10)" + " OR (custkey=11 AND shippriority= 11)" + " OR (custkey=12 AND shippriority= 12)" + " OR (custkey=13 AND shippriority= 13)" + " OR (custkey=14 AND shippriority= 14)" + " OR (custkey=15 AND shippriority= 15)" + " OR (custkey=16 AND shippriority= 16)" + " OR (custkey=17 AND shippriority= 17)" + " OR (custkey=18 AND shippriority= 18)" + " OR (custkey=19 AND shippriority= 19)" + " OR (custkey=20 AND shippriority= 20)" + " OR (custkey=21 AND shippriority= 21)" + " OR (custkey=22 AND shippriority= 22)" + " OR (custkey=23 AND shippriority= 23)" + " OR (custkey=24 AND shippriority= 24)" + " OR (custkey=25 AND shippriority= 25)" + " OR (custkey=26 AND shippriority= 26)" + " OR (custkey=27 AND shippriority= 27)" + " OR (custkey=28 AND shippriority= 28)" + " OR (custkey=29 AND shippriority= 29)" + " OR (custkey=30 AND shippriority= 30)" + " OR (custkey=31 AND shippriority= 31)" + " OR (custkey=32 AND shippriority= 32)";
    MaterializedResult result = computeActual(sql);
    System.out.println("Query Output: " + result);
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 24 with MaterializedResult

use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.

the class AbstractTestDistributedQueries method testPushdownCacheFilterKey.

@Test
public void testPushdownCacheFilterKey() {
    if (supportsPushdown()) {
        assertUpdate("DROP TABLE IF EXISTS test_cache_predicate");
        assertUpdate("CREATE TABLE test_cache_predicate (id int, name varchar, p1 int) WITH (partitioned_by=ARRAY['p1'])");
        assertTrue(getQueryRunner().tableExists(getSession(), "test_cache_predicate"));
        assertTableColumnNames("test_cache_predicate", "id", "name", "p1");
        assertUpdate("INSERT INTO test_cache_predicate VALUES (1,'---',1), (2,'---',1), (3,'abc',1)", 3);
        Session sessionPushdown = Session.builder(getSession()).setCatalogSessionProperty(getSession().getCatalog().get(), "orc_predicate_pushdown_enabled", "true").setCatalogSessionProperty(getSession().getCatalog().get(), "orc_row_data_cache_enabled", "false").build();
        Session sessionCachePushdown = Session.builder(getSession()).setCatalogSessionProperty(getSession().getCatalog().get(), "orc_predicate_pushdown_enabled", "true").setCatalogSessionProperty(getSession().getCatalog().get(), "orc_row_data_cache_enabled", "true").build();
        MaterializedResult resultNormal;
        MaterializedResult resultPushdown;
        MaterializedResult resultCachePushdown;
        String sql = "SELECT * FROM test_cache_predicate WHERE id=3 AND name='abc'";
        resultNormal = computeActual(sql);
        resultPushdown = computeActual(sessionPushdown, sql);
        assertQuery("CACHE TABLE test_cache_predicate WHERE p1 <> 0", "VALUES('OK')");
        resultCachePushdown = computeActual(sessionCachePushdown, sql);
        assertEquals(resultNormal.getMaterializedRows(), resultPushdown.getMaterializedRows());
        assertEquals(resultNormal.getMaterializedRows(), resultCachePushdown.getMaterializedRows());
    }
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) TestingSession(io.prestosql.testing.TestingSession) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Example 25 with MaterializedResult

use of io.prestosql.testing.MaterializedResult in project hetu-core by openlookeng.

the class AbstractTestDistributedQueries method testDisjunctPredicateWithPartitionKey.

@Test
public void testDisjunctPredicateWithPartitionKey() {
    if (supportsPushdown()) {
        assertUpdate("CREATE TABLE test_partition_predicate (id int, p1 char, p2 int) WITH (partitioned_by=ARRAY['p2'])");
        assertTrue(getQueryRunner().tableExists(getSession(), "test_partition_predicate"));
        assertTableColumnNames("test_partition_predicate", "id", "p1", "p2");
        assertUpdate("INSERT INTO test_partition_predicate VALUES (1,'a',1), (2,'b',2), (3,'c',3)", 3);
        assertUpdate("INSERT INTO test_partition_predicate VALUES (4,'d',4), (5,'e',5), (6,'f',6)", 3);
        assertUpdate("INSERT INTO test_partition_predicate VALUES (7,'g',7), (8,'h',8), (9,'i',9)", 3);
        String sql = "SELECT id, p1, p2 FROM test_partition_predicate WHERE id > 0 and (p1='b' or p2>3) ORDER BY id";
        assertQuery(getSession(), sql, "VALUES (2,'b',2), (4,'d',4), (5,'e',5), (6,'f',6), (7,'g',7), (8,'h',8), (9,'i',9)");
        Session session1 = Session.builder(getSession()).setCatalogSessionProperty(getSession().getCatalog().get(), "orc_predicate_pushdown_enabled", "true").setCatalogSessionProperty(getSession().getCatalog().get(), "orc_row_data_cache_enabled", "false").build();
        assertQuery(session1, sql, "VALUES (2,'b',2), (4,'d',4), (5,'e',5), (6,'f',6), (7,'g',7), (8,'h',8), (9,'i',9)");
        assertUpdate("INSERT INTO test_partition_predicate VALUES (10,'j',10)", 1);
        assertQuery(session1, sql, "VALUES (2,'b',2), (4,'d',4), (5,'e',5), (6,'f',6), (7,'g',7), (8,'h',8), (9,'i',9), (10,'j',10)");
        assertUpdate("INSERT INTO test_partition_predicate VALUES (11,NULL,11), (12,NULL,NULL), (NULL,NULL,NULL)", 3);
        /* NUlls Excluded */
        MaterializedResult resultNormal = computeActual(sql);
        MaterializedResult resultPushdown = computeActual(session1, sql);
        assertEquals(resultNormal.getMaterializedRows(), resultPushdown.getMaterializedRows());
        /* NUlls Included */
        sql = "SELECT id, p1, p2 FROM test_partition_predicate WHERE id > 0 and (p1 IS NULL or p2<3) ORDER BY id, p1";
        resultPushdown = computeActual(session1, sql);
        resultNormal = computeActual(sql);
        assertEquals(resultNormal.getMaterializedRows(), resultPushdown.getMaterializedRows());
        /* Query Test with Cache */
        Session session2 = Session.builder(getSession()).setCatalogSessionProperty(getSession().getCatalog().get(), "orc_predicate_pushdown_enabled", "true").setCatalogSessionProperty(getSession().getCatalog().get(), "orc_row_data_cache_enabled", "true").build();
        assertQuery(session2, "CACHE TABLE test_partition_predicate WHERE p2 > 0", "VALUES ('OK')");
        MaterializedResult resultCachePushdown = computeActual(session2, sql);
        assertEquals(resultNormal.getMaterializedRows(), resultCachePushdown.getMaterializedRows());
        sql = "SELECT id, p1, p2 FROM test_partition_predicate WHERE id > 0 and (p1 IS NULL or p2 IS NULL) ORDER BY id";
        resultNormal = computeActual(sql);
        resultPushdown = computeActual(session1, sql);
        resultCachePushdown = computeActual(session2, sql);
        assertEquals(resultNormal.getMaterializedRows(), resultPushdown.getMaterializedRows());
        assertEquals(resultNormal.getMaterializedRows(), resultCachePushdown.getMaterializedRows());
        sql = "SELECT id, p1, p2 FROM test_partition_predicate WHERE id > 0 and (p1 IS NOT NULL or p2 IS NULL) ORDER BY id";
        resultNormal = computeActual(sql);
        resultPushdown = computeActual(session1, sql);
        resultCachePushdown = computeActual(session2, sql);
        assertEquals(resultNormal.getMaterializedRows(), resultPushdown.getMaterializedRows());
        assertEquals(resultNormal.getMaterializedRows(), resultCachePushdown.getMaterializedRows());
        sql = "SELECT id, p1, p2 FROM test_partition_predicate WHERE id > 0 and (p1 > 'e' OR p2 IS NULL) ORDER BY id";
        resultNormal = computeActual(sql);
        resultPushdown = computeActual(session1, sql);
        resultCachePushdown = computeActual(session2, sql);
        assertEquals(resultNormal.getMaterializedRows(), resultPushdown.getMaterializedRows());
        assertEquals(resultNormal.getMaterializedRows(), resultCachePushdown.getMaterializedRows());
    }
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) TestingSession(io.prestosql.testing.TestingSession) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Aggregations

MaterializedResult (io.prestosql.testing.MaterializedResult)562 Test (org.testng.annotations.Test)474 Page (io.prestosql.spi.Page)139 AbstractTestIntegrationSmokeTest (io.prestosql.tests.AbstractTestIntegrationSmokeTest)97 MaterializedRow (io.prestosql.testing.MaterializedRow)95 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)74 RowPagesBuilder (io.prestosql.RowPagesBuilder)63 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)63 Type (io.prestosql.spi.type.Type)61 MarkerPage (io.prestosql.spi.snapshot.MarkerPage)58 Session (io.prestosql.Session)52 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)46 TestingConnectorSession (io.prestosql.testing.TestingConnectorSession)44 ConnectorTableHandle (io.prestosql.spi.connector.ConnectorTableHandle)42 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)38 ConnectorMetadata (io.prestosql.spi.connector.ConnectorMetadata)38 TestingTaskContext (io.prestosql.testing.TestingTaskContext)38 ImmutableList (com.google.common.collect.ImmutableList)34 HiveColumnHandle.bucketColumnHandle (io.prestosql.plugin.hive.HiveColumnHandle.bucketColumnHandle)34 List (java.util.List)32