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;
}
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"));
}
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()));
}
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);
}
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());
}
Aggregations