use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamMatchRel method estimateNodeStats.
@Override
public NodeStats estimateNodeStats(BeamRelMetadataQuery mq) {
// a simple way of getting some estimate data
// to be examined further
NodeStats inputEstimate = BeamSqlRelUtils.getNodeStats(input, mq);
double numRows = inputEstimate.getRowCount();
double winSize = inputEstimate.getWindow();
double rate = inputEstimate.getRate();
return NodeStats.create(numRows, rate, winSize).multiply(0.5);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamAggregationRel method estimateNodeStats.
@Override
public NodeStats estimateNodeStats(BeamRelMetadataQuery mq) {
NodeStats inputEstimate = BeamSqlRelUtils.getNodeStats(this.input, mq);
inputEstimate = computeWindowingCostEffect(inputEstimate);
// groupCount shows how many columns do we have in group by. One of them might be the windowing.
int groupCount = groupSet.cardinality() - (windowFn == null ? 0 : 1);
// preserved.
return (groupCount == 0) ? NodeStats.create(Math.min(inputEstimate.getRowCount(), 1d), inputEstimate.getRate() / inputEstimate.getWindow(), 1d) : inputEstimate.multiply(1.0 - Math.pow(.5, groupCount));
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamIntersectRel method estimateNodeStats.
@Override
public NodeStats estimateNodeStats(BeamRelMetadataQuery mq) {
// This takes the minimum of the inputs for all the estimate factors.
double minimumRows = Double.POSITIVE_INFINITY;
double minimumWindowSize = Double.POSITIVE_INFINITY;
double minimumRate = Double.POSITIVE_INFINITY;
for (RelNode input : inputs) {
NodeStats inputEstimates = BeamSqlRelUtils.getNodeStats(input, mq);
minimumRows = Math.min(minimumRows, inputEstimates.getRowCount());
minimumRate = Math.min(minimumRate, inputEstimates.getRate());
minimumWindowSize = Math.min(minimumWindowSize, inputEstimates.getWindow());
}
return NodeStats.create(minimumRows, minimumRate, minimumWindowSize).multiply(0.5);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamWindowRel method beamComputeSelfCost.
/**
* A dummy cost computation based on a fixed multiplier.
*
* <p>Since, there are not additional LogicalWindow to BeamWindowRel strategies, the result of
* this cost computation has no impact in the query execution plan.
*/
@Override
public BeamCostModel beamComputeSelfCost(RelOptPlanner planner, BeamRelMetadataQuery mq) {
NodeStats inputStat = BeamSqlRelUtils.getNodeStats(this.input, mq);
float multiplier = 1f + 0.125f;
return BeamCostModel.FACTORY.makeCost(inputStat.getRowCount() * multiplier, inputStat.getRate() * multiplier);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamAggregationRelTest method testNodeStatsEffectOfGroupSet.
@Test
public void testNodeStatsEffectOfGroupSet() {
String sql1 = "SELECT order_id FROM ORDER_DETAILS_BOUNDED " + " GROUP BY order_id ";
String sql2 = "SELECT order_id, site_id FROM ORDER_DETAILS_BOUNDED " + " GROUP BY order_id, site_id ";
NodeStats estimate1 = getEstimateOf(sql1);
NodeStats estimate2 = getEstimateOf(sql2);
Assert.assertTrue(estimate1.getRowCount() < estimate2.getRowCount());
Assert.assertTrue(estimate1.getWindow() < estimate2.getWindow());
}
Aggregations