use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestQueries method testValueWindowFunctions.
@Test
public void testValueWindowFunctions() {
MaterializedResult actual = computeActual("SELECT * FROM (\n" + " SELECT orderkey, orderstatus\n" + " , first_value(orderkey + 1000) OVER (PARTITION BY orderstatus ORDER BY orderkey) fvalue\n" + " , nth_value(orderkey + 1000, 2) OVER (PARTITION BY orderstatus ORDER BY orderkey\n" + " ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) nvalue\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, BIGINT).row(1L, "O", 1001L, 1002L).row(2L, "O", 1001L, 1002L).row(3L, "F", 1003L, 1005L).row(4L, "O", 1001L, 1002L).row(5L, "F", 1003L, 1005L).build();
assertEquals(actual, expected);
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestQueries method testApproxSetGroupByWithNulls.
@Test
public void testApproxSetGroupByWithNulls() {
MaterializedResult actual = computeActual("" + "SELECT orderstatus, cardinality(approx_set(IF(custkey % 2 <> 0, custkey))) " + "FROM orders " + "GROUP BY orderstatus");
MaterializedResult expected = resultBuilder(getSession(), actual.getTypes()).row("O", 499L).row("F", 496L).row("P", 153L).build();
assertEqualsIgnoreOrder(actual.getMaterializedRows(), expected.getMaterializedRows());
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestQueries method testNonDeterministicProjection.
@Test
public void testNonDeterministicProjection() {
MaterializedResult materializedResult = computeActual("select r, r + 1 from (select rand(100) r from orders) limit 10");
assertEquals(materializedResult.getRowCount(), 10);
for (MaterializedRow materializedRow : materializedResult) {
assertEquals(materializedRow.getFieldCount(), 2);
assertEquals(((Number) materializedRow.getField(0)).intValue() + 1, materializedRow.getField(1));
}
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestQueries method assertExplainDdl.
private void assertExplainDdl(String query, String expected) {
MaterializedResult result = computeActual("EXPLAIN " + query);
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), expected);
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestQueries method testP4ApproxSetGroupByWithNulls.
@Test
public void testP4ApproxSetGroupByWithNulls() {
MaterializedResult actual = computeActual("" + "SELECT orderstatus, cardinality(cast(approx_set(IF(custkey % 2 <> 0, custkey)) AS P4HYPERLOGLOG)) " + "FROM orders " + "GROUP BY orderstatus");
MaterializedResult expected = resultBuilder(getSession(), actual.getTypes()).row("O", 495L).row("F", 491L).row("P", 153L).build();
assertEqualsIgnoreOrder(actual.getMaterializedRows(), expected.getMaterializedRows());
}
Aggregations