NodeStats { public boolean isUnknown() { return Double.isInfinite(getRowCount()) || Double.isInfinite(getRate()) || Double.isInfinite(getWindow()); }  abstract double getRowCount(); abstract double getRate(); abstract double getWindow(); static NodeStats create(double rowCount, double rate, double window); static NodeStats create(double rowCount); boolean isUnknown(); NodeStats multiply(double factor); NodeStats plus(NodeStats that); NodeStats minus(NodeStats that); static final NodeStats UNKNOWN; }
@Test public void testUnknownRel() { String sql = " select * from ORDER_DETAILS1 "; RelNode root = env.parseQuery(sql); RelNode unknown = new UnknownRel(root.getCluster(), null, null); NodeStats nodeStats = unknown .metadata(NodeStatsMetadata.class, unknown.getCluster().getMetadataQuery()) .getNodeStats(); Assert.assertTrue(nodeStats.isUnknown()); }
@Test public void testKnownRel() { String sql = " select * from ORDER_DETAILS1 "; RelNode root = env.parseQuery(sql); NodeStats nodeStats = root.metadata(NodeStatsMetadata.class, root.getCluster().getMetadataQuery()).getNodeStats(); Assert.assertFalse(nodeStats.isUnknown()); }
@Test public void testSubsetHavingBest() { String sql = " select * from ORDER_DETAILS1 "; RelNode root = env.parseQuery(sql); root = root.getCluster().getPlanner().getRoot(); Assert.assertTrue(root instanceof RelSubset); NodeStats estimates = BeamSqlRelUtils.getNodeStats(root, root.getCluster().getMetadataQuery()); Assert.assertFalse(estimates.isUnknown()); }