Search in sources :

Example 1 with MaterializedResult

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

the class QueryAssertions method execute.

public MaterializedResult execute(Session session, @Language("SQL") String query) {
    MaterializedResult actualResults;
    actualResults = runner.execute(session, query).toTestTypes();
    return actualResults;
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult)

Example 2 with MaterializedResult

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

the class TestQueuesDb method testQuerySystemTableResourceGroup.

@Test(timeOut = 60_000)
public void testQuerySystemTableResourceGroup() throws Exception {
    QueryId firstQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
    waitForQueryState(queryRunner, firstQuery, RUNNING);
    MaterializedResult result = queryRunner.execute("SELECT resource_group_id FROM system.runtime.queries WHERE source = 'dashboard'");
    assertEquals(result.getOnlyValue(), ImmutableList.of("global", "user-user", "dashboard-user"));
}
Also used : QueryId(io.prestosql.spi.QueryId) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 3 with MaterializedResult

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

the class TestTpchDistributedQueries method testIOExplain.

@Test
@Override
public void testIOExplain() {
    String query = "SELECT * FROM orders";
    MaterializedResult result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) " + query);
    IoPlanPrinter.IoPlan.TableColumnInfo input = new IoPlanPrinter.IoPlan.TableColumnInfo(new CatalogSchemaTableName("tpch", "sf0.01", "orders"), ImmutableSet.of(new IoPlanPrinter.ColumnConstraint("orderstatus", createVarcharType(1).getTypeSignature(), new IoPlanPrinter.FormattedDomain(false, ImmutableSet.of(new IoPlanPrinter.FormattedRange(new IoPlanPrinter.FormattedMarker(Optional.of("F"), EXACTLY), new IoPlanPrinter.FormattedMarker(Optional.of("F"), EXACTLY)), new IoPlanPrinter.FormattedRange(new IoPlanPrinter.FormattedMarker(Optional.of("O"), EXACTLY), new IoPlanPrinter.FormattedMarker(Optional.of("O"), EXACTLY)), new IoPlanPrinter.FormattedRange(new IoPlanPrinter.FormattedMarker(Optional.of("P"), EXACTLY), new IoPlanPrinter.FormattedMarker(Optional.of("P"), EXACTLY)))))));
    assertEquals(jsonCodec(IoPlanPrinter.IoPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())), new IoPlanPrinter.IoPlan(ImmutableSet.of(input), Optional.empty()));
}
Also used : IoPlanPrinter(io.prestosql.sql.planner.planprinter.IoPlanPrinter) MaterializedResult(io.prestosql.testing.MaterializedResult) CatalogSchemaTableName(io.prestosql.spi.connector.CatalogSchemaTableName) Test(org.testng.annotations.Test)

Example 4 with MaterializedResult

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

the class TestLocalQueries method testShowColumnStats.

@Test
public void testShowColumnStats() {
    // FIXME Add tests for more complex scenario with more stats
    MaterializedResult result = computeActual("SHOW STATS FOR nation");
    MaterializedResult expectedStatistics = resultBuilder(getSession(), VARCHAR, DOUBLE, DOUBLE, DOUBLE, DOUBLE, VARCHAR, VARCHAR).row("nationkey", null, 25.0, 0.0, null, "0", "24").row("name", 177.0, 25.0, 0.0, null, null, null).row("regionkey", null, 5.0, 0.0, null, "0", "4").row("comment", 1857.0, 25.0, 0.0, null, null, null).row(null, null, null, null, 25.0, null, null).build();
    assertEquals(result, expectedStatistics);
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 5 with MaterializedResult

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

the class TestH2QueryRunner method testDateToTimestampCoercion.

@Test
public void testDateToTimestampCoercion() {
    // allow running tests with a connector that supports TIMESTAMP but not DATE
    // ordinary date
    MaterializedResult rows = h2QueryRunner.execute(TEST_SESSION, "SELECT DATE '2018-01-13'", ImmutableList.of(TIMESTAMP));
    assertEquals(rows.getOnlyValue(), LocalDate.of(2018, 1, 13).atStartOfDay());
    // date, which midnight was skipped in JVM zone
    LocalDate forwardOffsetChangeAtMidnightInJvmZone = LocalDate.of(1970, 1, 1);
    checkState(ZoneId.systemDefault().getRules().getValidOffsets(forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay()).size() == 0, "This test assumes certain JVM time zone");
    rows = h2QueryRunner.execute(TEST_SESSION, DateTimeFormatter.ofPattern("'SELECT DATE '''uuuu-MM-dd''").format(forwardOffsetChangeAtMidnightInJvmZone), ImmutableList.of(TIMESTAMP));
    assertEquals(rows.getOnlyValue(), forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay());
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Aggregations

MaterializedResult (io.prestosql.testing.MaterializedResult)481 Test (org.testng.annotations.Test)413 Page (io.prestosql.spi.Page)134 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)74 MaterializedRow (io.prestosql.testing.MaterializedRow)74 RowPagesBuilder (io.prestosql.RowPagesBuilder)63 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)63 MarkerPage (io.prestosql.spi.snapshot.MarkerPage)58 Type (io.prestosql.spi.type.Type)53 AbstractTestIntegrationSmokeTest (io.prestosql.tests.AbstractTestIntegrationSmokeTest)53 Session (io.prestosql.Session)46 TestingTaskContext (io.prestosql.testing.TestingTaskContext)38 ImmutableList (com.google.common.collect.ImmutableList)27 WindowOperatorFactory (io.prestosql.operator.WindowOperator.WindowOperatorFactory)26 List (java.util.List)26 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)23 Assert.assertTrue (org.testng.Assert.assertTrue)23 TestingConnectorSession (io.prestosql.testing.TestingConnectorSession)22 DataSize (io.airlift.units.DataSize)21 ConnectorTableHandle (io.prestosql.spi.connector.ConnectorTableHandle)21