public Double getMaxRowCount(Union rel, RelMetadataQuery mq) { double rowCount = 0.0; for (RelNode input : rel.getInputs()) { Double partialRowCount = mq.getMaxRowCount(input); if (partialRowCount == null) { return null; } rowCount += partialRowCount; } return rowCount; }
public Double getMaxRowCount(Union rel, RelMetadataQuery mq) { double rowCount = 0.0; for (RelNode input : rel.getInputs()) { Double partialRowCount = mq.getMaxRowCount(input); if (partialRowCount == null) { return null; } rowCount += partialRowCount; } return rowCount; }
public Double getMaxRowCount(Intersect rel, RelMetadataQuery mq) { // max row count is the smallest of the inputs Double rowCount = null; for (RelNode input : rel.getInputs()) { Double partialRowCount = mq.getMaxRowCount(input); if (rowCount == null || partialRowCount != null && partialRowCount < rowCount) { rowCount = partialRowCount; } } return rowCount; }
public Double getMaxRowCount(Aggregate rel, RelMetadataQuery mq) { if (ProjectableSqlAggFunctions.isProjectableAggregate(rel)) { return mq.getMaxRowCount(rel); } // try the next handler return null; }
public Double getMaxRowCount(Intersect rel, RelMetadataQuery mq) { // max row count is the smallest of the inputs Double rowCount = null; for (RelNode input : rel.getInputs()) { Double partialRowCount = mq.getMaxRowCount(input); if (rowCount == null || partialRowCount != null && partialRowCount < rowCount) { rowCount = partialRowCount; } } return rowCount; }
public Double getMaxRowCount(Minus rel, RelMetadataQuery mq) { return mq.getMaxRowCount(rel.getInput(0)); }
public Double getMaxRowCount(Project rel, RelMetadataQuery mq) { return mq.getMaxRowCount(rel.getInput()); }
public Double getMaxRowCount(Minus rel, RelMetadataQuery mq) { return mq.getMaxRowCount(rel.getInput(0)); }
public Double getMaxRowCount(Project rel, RelMetadataQuery mq) { return mq.getMaxRowCount(rel.getInput()); }
public Double getMaxRowCount(EnumerableLimit rel, RelMetadataQuery mq) { Double rowCount = mq.getMaxRowCount(rel.getInput()); if (rowCount == null) { rowCount = Double.POSITIVE_INFINITY; } final int offset = rel.offset == null ? 0 : RexLiteral.intValue(rel.offset); rowCount = Math.max(rowCount - offset, 0D); if (rel.fetch != null) { final int limit = RexLiteral.intValue(rel.fetch); if (limit < rowCount) { return (double) limit; } } return rowCount; }
public Double getMaxRowCount(Sort rel, RelMetadataQuery mq) { Double rowCount = mq.getMaxRowCount(rel.getInput()); if (rowCount == null) { rowCount = Double.POSITIVE_INFINITY; } final int offset = rel.offset == null ? 0 : RexLiteral.intValue(rel.offset); rowCount = Math.max(rowCount - offset, 0D); if (rel.fetch != null) { final int limit = RexLiteral.intValue(rel.fetch); if (limit < rowCount) { return (double) limit; } } return rowCount; }
public Double getMaxRowCount(EnumerableLimit rel, RelMetadataQuery mq) { Double rowCount = mq.getMaxRowCount(rel.getInput()); if (rowCount == null) { rowCount = Double.POSITIVE_INFINITY; } final int offset = rel.offset == null ? 0 : RexLiteral.intValue(rel.offset); rowCount = Math.max(rowCount - offset, 0D); if (rel.fetch != null) { final int limit = RexLiteral.intValue(rel.fetch); if (limit < rowCount) { return (double) limit; } } return rowCount; }
public Double getMaxRowCount(Aggregate rel, RelMetadataQuery mq) { if (rel.getGroupSet().isEmpty()) { // Aggregate with no GROUP BY always returns 1 row (even on empty table). return 1D; } final Double rowCount = mq.getMaxRowCount(rel.getInput()); if (rowCount == null) { return null; } return rowCount * rel.getGroupSets().size(); }
public Double getMaxRowCount(Filter rel, RelMetadataQuery mq) { if (rel.getCondition().isAlwaysFalse()) { return 0D; } return mq.getMaxRowCount(rel.getInput()); }
public Double getMaxRowCount(Aggregate rel, RelMetadataQuery mq) { if (rel.getGroupSet().isEmpty()) { // Aggregate with no GROUP BY always returns 1 row (even on empty table). return 1D; } final Double rowCount = mq.getMaxRowCount(rel.getInput()); if (rowCount == null) { return null; } return rowCount * rel.getGroupSets().size(); }
public Double getMaxRowCount(Filter rel, RelMetadataQuery mq) { if (rel.getCondition().isAlwaysFalse()) { return 0D; } return mq.getMaxRowCount(rel.getInput()); }
public Double getMaxRowCount(Join rel, RelMetadataQuery mq) { Double left = mq.getMaxRowCount(rel.getLeft()); Double right = mq.getMaxRowCount(rel.getRight()); if (left == null || right == null) { return null; } if (left < 1D && rel.getJoinType().generatesNullsOnLeft()) { left = 1D; } if (right < 1D && rel.getJoinType().generatesNullsOnRight()) { right = 1D; } return left * right; }
public Double getMaxRowCount(Join rel, RelMetadataQuery mq) { Double left = mq.getMaxRowCount(rel.getLeft()); Double right = mq.getMaxRowCount(rel.getRight()); if (left == null || right == null) { return null; } if (left < 1D && rel.getJoinType().generatesNullsOnLeft()) { left = 1D; } if (right < 1D && rel.getJoinType().generatesNullsOnRight()) { right = 1D; } return left * right; }
private void checkRowCount(String sql, double expected, double expectedMin, double expectedMax) { RelNode rel = convertSql(sql); final RelMetadataQuery mq = RelMetadataQuery.instance(); final Double result = mq.getRowCount(rel); assertThat(result, notNullValue()); assertEquals(expected, result, 0d); final Double max = mq.getMaxRowCount(rel); assertThat(max, notNullValue()); assertEquals(expectedMax, max, 0d); final Double min = mq.getMinRowCount(rel); assertThat(max, notNullValue()); assertEquals(expectedMin, min, 0d); }
private void checkRowCount(String sql, double expected, double expectedMin, double expectedMax) { RelNode rel = convertSql(sql); final RelMetadataQuery mq = RelMetadataQuery.instance(); final Double result = mq.getRowCount(rel); assertThat(result, notNullValue()); assertEquals(expected, result, 0d); final Double max = mq.getMaxRowCount(rel); assertThat(max, notNullValue()); assertEquals(expectedMax, max, 0d); final Double min = mq.getMinRowCount(rel); assertThat(max, notNullValue()); assertEquals(expectedMin, min, 0d); }