use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamIOSourceRelTest method testBoundedNodeStats.
@Test
public void testBoundedNodeStats() {
String sql = "SELECT * FROM ORDER_DETAILS_BOUNDED";
RelNode root = env.parseQuery(sql);
while (!(root instanceof BeamIOSourceRel)) {
root = root.getInput(0);
}
NodeStats estimate = BeamSqlRelUtils.getNodeStats(root, ((BeamRelMetadataQuery) root.getCluster().getMetadataQuery()));
Assert.assertEquals(5d, estimate.getRowCount(), 0.01);
Assert.assertEquals(0d, estimate.getRate(), 0.01);
Assert.assertEquals(5d, estimate.getWindow(), 0.01);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamIOSourceRelTest method testUnboundedNodeStats.
@Test
public void testUnboundedNodeStats() {
String sql = "SELECT * FROM ORDER_DETAILS_UNBOUNDED";
RelNode root = env.parseQuery(sql);
while (!(root instanceof BeamIOSourceRel)) {
root = root.getInput(0);
}
NodeStats estimate = BeamSqlRelUtils.getNodeStats(root, ((BeamRelMetadataQuery) root.getCluster().getMetadataQuery()));
Assert.assertEquals(0d, estimate.getRowCount(), 0.01);
Assert.assertEquals(2d, estimate.getRate(), 0.01);
Assert.assertEquals(BeamIOSourceRel.CONSTANT_WINDOW_SIZE, estimate.getWindow(), 0.01);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamMinusRelTest method testNodeStatsEstimationUnbounded.
@Test
public void testNodeStatsEstimationUnbounded() {
String sql = "SELECT * " + "FROM " + "(select order_id FROM ORDER_DETAILS_UNBOUNDED " + " GROUP BY order_id, TUMBLE(order_time, INTERVAL '1' HOUR)) o1 " + " EXCEPT ALL " + " select order_id FROM ORDER_DETAILS_UNBOUNDED " + " GROUP BY order_id, TUMBLE(order_time, INTERVAL '1' HOUR) ";
RelNode root = env.parseQuery(sql);
while (!(root instanceof BeamMinusRel)) {
root = root.getInput(0);
}
NodeStats estimate = BeamSqlRelUtils.getNodeStats(root, ((BeamRelMetadataQuery) root.getCluster().getMetadataQuery()));
// note that we have group by
Assert.assertEquals(4d / 2 - 4d / 4, estimate.getRate(), 0.01);
Assert.assertEquals(0d, estimate.getRowCount(), 0.01);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamAggregationRelTest method testNodeStatsUnboundedWindow.
@Test
public void testNodeStatsUnboundedWindow() {
String sql = "select order_id, sum(site_id) as sum_site_id FROM ORDER_DETAILS_UNBOUNDED " + " GROUP BY order_id, TUMBLE(order_time, INTERVAL '1' HOUR)";
NodeStats estimate1 = getEstimateOf(sql);
Assert.assertEquals(1d, estimate1.getRate(), 0.01);
Assert.assertEquals(BeamIOSourceRel.CONSTANT_WINDOW_SIZE / 2, estimate1.getWindow(), 0.01);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamCoGBKJoinRelBoundedVsBoundedTest method testNodeStatsOfMoreConditions.
@Test
public void testNodeStatsOfMoreConditions() {
String sql1 = "SELECT * " + " FROM ORDER_DETAILS1 o1 " + " JOIN ORDER_DETAILS2 o2 " + " on " + " o1.order_id=o2.site_id ";
String sql2 = "SELECT * " + " FROM ORDER_DETAILS1 o1 " + " JOIN ORDER_DETAILS2 o2 " + " on " + " o1.order_id=o2.site_id AND o2.price=o1.site_id";
RelNode root1 = env.parseQuery(sql1);
while (!(root1 instanceof BeamCoGBKJoinRel)) {
root1 = root1.getInput(0);
}
RelNode root2 = env.parseQuery(sql2);
while (!(root2 instanceof BeamCoGBKJoinRel)) {
root2 = root2.getInput(0);
}
NodeStats estimate1 = BeamSqlRelUtils.getNodeStats(root1, ((BeamRelMetadataQuery) root1.getCluster().getMetadataQuery()));
NodeStats estimate2 = BeamSqlRelUtils.getNodeStats(root2, ((BeamRelMetadataQuery) root1.getCluster().getMetadataQuery()));
Assert.assertNotEquals(0d, estimate2.getRowCount(), 0.001);
// A join with two conditions should have lower estimate.
Assert.assertTrue(estimate2.getRowCount() < estimate1.getRowCount());
}
Aggregations