@Override public double estimateRowCount(RelMetadataQuery mq) { return mq.getDistinctRowCount(this, groupSet, getCluster().getRexBuilder().makeLiteral(true)); }
@Override public double estimateRowCount(RelMetadataQuery mq) { return mq.getDistinctRowCount(this, groupSet, getCluster().getRexBuilder().makeLiteral(true)); }
@Override public Double getDistinctRowCount(Join rel, RelMetadataQuery mq, ImmutableBitSet groupKey, RexNode predicate) { if (rel instanceof HiveJoin) { HiveJoin hjRel = (HiveJoin) rel; //TODO: Improve this if (rel instanceof SemiJoin) { return mq.getDistinctRowCount(hjRel.getLeft(), groupKey, rel.getCluster().getRexBuilder().makeLiteral(true)); } else { return RelMdUtil.getJoinDistinctRowCount(mq, rel, rel.getJoinType(), groupKey, predicate, true); } } return mq.getDistinctRowCount(rel, groupKey, predicate); }
public static Double getDistinctRowCount(RelNode r, RelMetadataQuery mq, int indx) { ImmutableBitSet bitSetOfRqdProj = ImmutableBitSet.of(indx); return mq.getDistinctRowCount(r, bitSetOfRqdProj, r .getCluster().getRexBuilder().makeLiteral(true)); }
@Override public Double getDistinctRowCount(Join rel, RelMetadataQuery mq, ImmutableBitSet groupKey, RexNode predicate) { if (rel instanceof HiveJoin) { HiveJoin hjRel = (HiveJoin) rel; //TODO: Improve this if (rel instanceof SemiJoin) { return mq.getDistinctRowCount(hjRel.getLeft(), groupKey, rel.getCluster().getRexBuilder().makeLiteral(true)); } else { return RelMdUtil.getJoinDistinctRowCount(mq, rel, rel.getJoinType(), groupKey, predicate, true); } } return mq.getDistinctRowCount(rel, groupKey, predicate); }
public static Double getDistinctRowCount(RelNode r, RelMetadataQuery mq, int indx) { ImmutableBitSet bitSetOfRqdProj = ImmutableBitSet.of(indx); return mq.getDistinctRowCount(r, bitSetOfRqdProj, r .getCluster().getRexBuilder().makeLiteral(true)); }
RexNode rightPred = RexUtil.composeConjunction( rexBuilder, rightFilters, true); double leftNDV = isPKSideSimpleTree ? mq.getDistinctRowCount(left, lBitSet, leftPred) : -1; double rightNDV = isPKSideSimpleTree ? mq.getDistinctRowCount(right, rBitSet, rightPred) : -1;
boolean isPKSideSimpleTree = leftIsKey ? SimpleTreeOnJoinKey.check(false, left, lBitSet, mq).left : SimpleTreeOnJoinKey.check(false, right, rBitSet, mq).left; double leftNDV = isPKSideSimpleTree ? mq.getDistinctRowCount(left, lBitSet, leftPred) : -1; double rightNDV = isPKSideSimpleTree ? mq.getDistinctRowCount(right, rBitSet, rightPred) : -1;
pkSide == 0 ? leftColIdx : rightColIdx, mq) : false; double leftNDV = isPKSideSimpleTree ? mq.getDistinctRowCount(left, lBitSet, leftPred) : -1; double rightNDV = isPKSideSimpleTree ? mq.getDistinctRowCount(right, rBitSet, rightPred) : -1;
public Double getDistinctRowCount(Exchange rel, RelMetadataQuery mq, ImmutableBitSet groupKey, RexNode predicate) { return mq.getDistinctRowCount(rel.getInput(), groupKey, predicate); }
@Override public double getRows() { return RelMetadataQuery.getDistinctRowCount(this, groupSet, getCluster().getRexBuilder() .makeLiteral(true)); }
public Double getRowCount(Aggregate rel, RelMetadataQuery mq) { ImmutableBitSet groupKey = rel.getGroupSet(); // .range(rel.getGroupCount()); // rowCount is the cardinality of the group by columns Double distinctRowCount = mq.getDistinctRowCount(rel.getInput(), groupKey, null); if (distinctRowCount == null) { distinctRowCount = mq.getRowCount(rel.getInput()) / 10; } // Grouping sets multiply distinctRowCount *= rel.getGroupSets().size(); return distinctRowCount; }
public Double getRowCount(Aggregate rel, RelMetadataQuery mq) { ImmutableBitSet groupKey = rel.getGroupSet(); // .range(rel.getGroupCount()); // rowCount is the cardinality of the group by columns Double distinctRowCount = mq.getDistinctRowCount(rel.getInput(), groupKey, null); if (distinctRowCount == null) { distinctRowCount = mq.getRowCount(rel.getInput()) / 10; } // Grouping sets multiply distinctRowCount *= rel.getGroupSets().size(); return distinctRowCount; }
public static Double getDistinctRowCount(RelNode r, int indx) { ImmutableBitSet bitSetOfRqdProj = ImmutableBitSet.of(indx); return RelMetadataQuery.getDistinctRowCount(r, bitSetOfRqdProj, r .getCluster().getRexBuilder().makeLiteral(true)); }
public Double visitInputRef(RexInputRef var) { int index = var.getIndex(); ImmutableBitSet col = ImmutableBitSet.of(index); Double distinctRowCount = mq.getDistinctRowCount(rel.getInput(), col, null); if (distinctRowCount == null) { return null; } else { return numDistinctVals(distinctRowCount, mq.getRowCount(rel)); } }
public Double visitInputRef(RexInputRef var) { int index = var.getIndex(); ImmutableBitSet col = ImmutableBitSet.of(index); Double distinctRowCount = mq.getDistinctRowCount(rel.getInput(), col, null); if (distinctRowCount == null) { return null; } else { return numDistinctVals(distinctRowCount, mq.getRowCount(rel)); } }
@Test public void testDistinctRowCountTableEmptyKey() { RelNode rel = convertSql("select * from emp where deptno = 10"); ImmutableBitSet groupKey = ImmutableBitSet.of(); // empty key final RelMetadataQuery mq = RelMetadataQuery.instance(); Double result = mq.getDistinctRowCount(rel, groupKey, null); assertThat(result, is(1D)); }
@Test public void testDistinctRowCountTableEmptyKey() { RelNode rel = convertSql("select * from emp where deptno = 10"); ImmutableBitSet groupKey = ImmutableBitSet.of(); // empty key final RelMetadataQuery mq = RelMetadataQuery.instance(); Double result = mq.getDistinctRowCount(rel, groupKey, null); assertThat(result, is(1D)); }
@Test public void testDistinctRowCountTable() { // no unique key information is available so return null RelNode rel = convertSql("select * from emp where deptno = 10"); final RelMetadataQuery mq = RelMetadataQuery.instance(); ImmutableBitSet groupKey = ImmutableBitSet.of(rel.getRowType().getFieldNames().indexOf("DEPTNO")); Double result = mq.getDistinctRowCount(rel, groupKey, null); assertThat(result, nullValue()); }
@Test public void testDistinctRowCountTable() { // no unique key information is available so return null RelNode rel = convertSql("select * from emp where deptno = 10"); final RelMetadataQuery mq = RelMetadataQuery.instance(); ImmutableBitSet groupKey = ImmutableBitSet.of(rel.getRowType().getFieldNames().indexOf("DEPTNO")); Double result = mq.getDistinctRowCount(rel, groupKey, null); assertThat(result, nullValue()); }