public void fixSharedOlapTableScan(SingleRel parent) { OLAPTableScan copy = copyTableScanIfNeeded(parent.getInput()); if (copy != null) parent.replaceInput(0, copy); }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { return super.computeSelfCost(planner, mq).multiplyBy(.05); }
@Override public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw) .item("ctx", context == null ? "" : String.valueOf(context.id) + "@" + context.realization) .itemIf("offset", localOffset, localOffset != null).itemIf("fetch", localFetch, localFetch != null); }
public Double getRowCount(SingleRel rel, RelMetadataQuery mq) { return mq.getRowCount(rel.getInput()); }
private static RelNode createEmptyEmptyRelHelper(SingleRel input) { return LogicalSort.create(input.getInput(), RelCollations.EMPTY, input.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0)), input.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0))); } }
@Override public Double getRowCount(SingleRel rel, RelMetadataQuery mq) { return rel.estimateRowCount(mq); }
public boolean isValid(Litmus litmus, Context context) { return super.isValid(litmus, context) && litmus.check(Util.isDistinct(getRowType().getFieldNames()), "distinct field names: {}", getRowType()); }
public RelDistribution distribution(SingleRel rel, RelMetadataQuery mq) { return mq.distribution(rel.getInput()); }
/** * Derives the output type of a collect relational expression. * * @param rel relational expression * @param fieldName name of sole output field * @return output type of a collect relational expression */ public static RelDataType deriveCollectRowType( SingleRel rel, String fieldName) { RelDataType childType = rel.getInput().getRowType(); assert childType.isStruct(); final RelDataTypeFactory typeFactory = rel.getCluster().getTypeFactory(); RelDataType ret = SqlTypeUtil.createMultisetType( typeFactory, childType, false); ret = typeFactory.builder().add(fieldName, ret).build(); return typeFactory.createTypeWithNullability(ret, false); } }
@Override public double estimateRowCount(RelMetadataQuery mq) { // Assume that each sort column has 50% of the value count. // Therefore one sort column has .5 * rowCount, // 2 sort columns give .75 * rowCount. // Zero sort columns yields 1 row (or 0 if the input is empty). final int groupCount = groupSet.cardinality(); if (groupCount == 0) { return 1; } else { double rowCount = super.estimateRowCount(mq); rowCount *= 1.0 - Math.pow(.5, groupCount); return rowCount; } }
public boolean isValid(Litmus litmus, Context context) { return super.isValid(litmus, context) && litmus.check(Util.isDistinct(getRowType().getFieldNames()), "distinct field names: {}", getRowType()); }
public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw) .item("distribution", distribution); } }
public RelDistribution distribution(SingleRel rel, RelMetadataQuery mq) { return mq.distribution(rel.getInput()); }
/** * Derives the output type of a collect relational expression. * * @param rel relational expression * @param fieldName name of sole output field * @return output type of a collect relational expression */ public static RelDataType deriveCollectRowType( SingleRel rel, String fieldName) { RelDataType childType = rel.getInput().getRowType(); assert childType.isStruct(); final RelDataTypeFactory typeFactory = rel.getCluster().getTypeFactory(); RelDataType ret = SqlTypeUtil.createMultisetType( typeFactory, childType, false); ret = typeFactory.builder().add(fieldName, ret).build(); return typeFactory.createTypeWithNullability(ret, false); } }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { return super.computeSelfCost(planner, mq).multiplyBy(factor); }
public void fixSharedOlapTableScan(SingleRel parent) { OLAPTableScan copy = copyTableScanIfNeeded(parent.getInput()); if (copy != null) parent.replaceInput(0, copy); }
@Override public double estimateRowCount(RelMetadataQuery mq) { // Assume that each sort column has 50% of the value count. // Therefore one sort column has .5 * rowCount, // 2 sort columns give .75 * rowCount. // Zero sort columns yields 1 row (or 0 if the input is empty). final int groupCount = groupSet.cardinality(); if (groupCount == 0) { return 1; } else { double rowCount = super.estimateRowCount(mq); rowCount *= 1.0 - Math.pow(.5, groupCount); return rowCount; } }
public boolean isValid(Litmus litmus, Context context) { if (!super.isValid(litmus, context)) { return litmus.fail(null);
public RelWriter explainTerms(RelWriter pw) { return super.explainTerms(pw) .item("condition", condition); } }
public Double getRowCount(SingleRel rel, RelMetadataQuery mq) { return mq.getRowCount(rel.getInput()); }