Package com.facebook.presto.testing

Examples of com.facebook.presto.testing.MaterializedResult$Builder


    }

    @Test
    public void testWindowLastValueFunction()
    {
        MaterializedResult actual = computeActual("" +
                "SELECT * FROM (\n" +
                "  SELECT orderkey, orderstatus\n" +
                "    , last_value(orderkey + 1000) OVER (PARTITION BY orderstatus ORDER BY orderkey) as lvalue\n" +
                "    FROM (SELECT * FROM orders ORDER BY orderkey LIMIT 10) x\n" +
                "  ) x\n" +
                "ORDER BY orderkey LIMIT 5");

        MaterializedResult expected = resultBuilder(getSession(), BIGINT, VARCHAR, BIGINT)
                .row(1, "O", 1034)
                .row(2, "O", 1034)
                .row(3, "F", 1033)
                .row(4, "O", 1034)
                .row(5, "F", 1033)
View Full Code Here


    }

    @Test
    public void testWindowNthValueFunction()
    {
        MaterializedResult actual = computeActual("" +
                "SELECT * FROM (\n" +
                "  SELECT orderkey, orderstatus\n" +
                "    , nth_value(orderkey + 1000, 2) OVER (PARTITION BY orderstatus ORDER BY orderkey) as lvalue\n" +
                "    FROM (SELECT * FROM orders ORDER BY orderkey LIMIT 10) x\n" +
                "  ) x\n" +
                "ORDER BY orderkey LIMIT 5");

        MaterializedResult expected = resultBuilder(getSession(), BIGINT, VARCHAR, BIGINT)
                .row(1, "O", 1002)
                .row(2, "O", 1002)
                .row(3, "F", 1005)
                .row(4, "O", 1002)
                .row(5, "F", 1005)
View Full Code Here

    }

    @Test
    public void testWindowLagValueFunction()
    {
        MaterializedResult actual = computeActual("" +
                "SELECT * FROM (\n" +
                "  SELECT orderkey, orderstatus\n" +
                "    , lag(orderkey + 1000, 1, 0) OVER (PARTITION BY orderstatus ORDER BY orderkey) as lvalue\n" +
                "    FROM (SELECT * FROM orders ORDER BY orderkey LIMIT 10) x\n" +
                "  ) x\n" +
                "ORDER BY orderkey LIMIT 5");

        MaterializedResult expected = resultBuilder(getSession(), BIGINT, VARCHAR, BIGINT)
                .row(1, "O", 0)
                .row(2, "O", 1001)
                .row(3, "F", 0)
                .row(4, "O", 1002)
                .row(5, "F", 1003)
View Full Code Here

    }

    @Test
    public void testWindowLeadValueFunction()
    {
        MaterializedResult actual = computeActual("" +
                "SELECT * FROM (\n" +
                "  SELECT orderkey, orderstatus\n" +
                "    , lead(orderkey + 1000, 2, 0) OVER (PARTITION BY orderstatus ORDER BY orderkey) as lvalue\n" +
                "    FROM (SELECT * FROM orders ORDER BY orderkey LIMIT 10) x\n" +
                "  ) x\n" +
                "ORDER BY orderkey LIMIT 6");

        MaterializedResult expected = resultBuilder(getSession(), BIGINT, VARCHAR, BIGINT)
                .row(1, "O", 1004)
                .row(2, "O", 1007)
                .row(3, "F", 1006)
                .row(4, "O", 1032)
                .row(5, "F", 1033)
View Full Code Here

    @Test
    public void testDefaultExplainTextFormat()
    {
        String query = "SELECT 123";
        MaterializedResult result = computeActual("EXPLAIN " + query);
        String actual = Iterables.getOnlyElement(transform(result.getMaterializedRows(), onlyColumnGetter()));
        assertEquals(actual, getExplainPlan(query, LOGICAL));
    }
View Full Code Here

    @Test
    public void testDefaultExplainGraphvizFormat()
    {
        String query = "SELECT 123";
        MaterializedResult result = computeActual("EXPLAIN (FORMAT GRAPHVIZ) " + query);
        String actual = Iterables.getOnlyElement(transform(result.getMaterializedRows(), onlyColumnGetter()));
        assertEquals(actual, getGraphvizExplainPlan(query, LOGICAL));
    }
View Full Code Here

    @Test
    public void testLogicalExplain()
    {
        String query = "SELECT 123";
        MaterializedResult result = computeActual("EXPLAIN (TYPE LOGICAL) " + query);
        String actual = Iterables.getOnlyElement(transform(result.getMaterializedRows(), onlyColumnGetter()));
        assertEquals(actual, getExplainPlan(query, LOGICAL));
    }
View Full Code Here

    @Test
    public void testLogicalExplainTextFormat()
    {
        String query = "SELECT 123";
        MaterializedResult result = computeActual("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) " + query);
        String actual = Iterables.getOnlyElement(transform(result.getMaterializedRows(), onlyColumnGetter()));
        assertEquals(actual, getExplainPlan(query, LOGICAL));
    }
View Full Code Here

    @Test
    public void testLogicalExplainGraphvizFormat()
    {
        String query = "SELECT 123";
        MaterializedResult result = computeActual("EXPLAIN (TYPE LOGICAL, FORMAT GRAPHVIZ) " + query);
        String actual = Iterables.getOnlyElement(transform(result.getMaterializedRows(), onlyColumnGetter()));
        assertEquals(actual, getGraphvizExplainPlan(query, LOGICAL));
    }
View Full Code Here

    @Test
    public void testDistributedExplain()
    {
        String query = "SELECT 123";
        MaterializedResult result = computeActual("EXPLAIN (TYPE DISTRIBUTED) " + query);
        String actual = Iterables.getOnlyElement(transform(result.getMaterializedRows(), onlyColumnGetter()));
        assertEquals(actual, getExplainPlan(query, DISTRIBUTED));
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.testing.MaterializedResult$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.