use of org.apache.beam.sdk.extensions.sql.impl.planner.BeamRelMetadataQuery in project beam by apache.
the class BeamCalcRelTest method testFilterNodeStats.
@Test
public void testFilterNodeStats() {
String sql = "SELECT * FROM ORDER_DETAILS_BOUNDED where order_id=1";
RelNode root = env.parseQuery(sql);
Assert.assertTrue(root instanceof BeamCalcRel);
NodeStats estimate = BeamSqlRelUtils.getNodeStats(root, ((BeamRelMetadataQuery) root.getCluster().getMetadataQuery()));
Assert.assertTrue(5d > estimate.getRowCount());
Assert.assertTrue(5d > estimate.getWindow());
Assert.assertEquals(0., estimate.getRate(), 0.001);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.BeamRelMetadataQuery in project beam by apache.
the class BeamCalcRelTest method testProjectionNodeStats.
@Test
public void testProjectionNodeStats() {
String sql = "SELECT order_id FROM ORDER_DETAILS_BOUNDED";
RelNode root = env.parseQuery(sql);
Assert.assertTrue(root instanceof BeamCalcRel);
NodeStats estimate = BeamSqlRelUtils.getNodeStats(root, ((BeamRelMetadataQuery) root.getCluster().getMetadataQuery()));
Assert.assertEquals(5d, estimate.getRowCount(), 0.001);
Assert.assertEquals(5d, estimate.getWindow(), 0.001);
Assert.assertEquals(0., estimate.getRate(), 0.001);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.BeamRelMetadataQuery 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.BeamRelMetadataQuery 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.BeamRelMetadataQuery 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);
}
Aggregations