@Override public boolean matches(RelOptRuleCall call) { LimitPrel limitPrel = call.rel(0); ProjectPrel projectPrel = call.rel(1); // pushdown only apply limit but not offset, // so if getFetch() return null no need to run this rule. // Do not push across Project containing CONVERT_FROMJSON for limit 0 queries. For limit 0 queries, this would // mess up the schema since Convert_FromJson() is different from other regular functions in that it only knows // the output schema after evaluation is performed. When input has 0 row, Drill essentially does not have a way // to know the output type. if (!limitPrel.isPushDown() && (limitPrel.getFetch() != null) && (!DrillRelOptUtil.isLimit0(limitPrel.getFetch()) || !DrillRelOptUtil.isProjectOutputSchemaUnknown(projectPrel))) { return true; } return false; } };
@Override public RelNode visit(LogicalSort sort) { if (DrillRelOptUtil.isLimit0(sort.fetch)) { contains = true; return sort; } return super.visit(sort); }
@Override public RelNode visit(RelNode other) { if (other instanceof DrillJoinRelBase || other instanceof DrillAggregateRelBase || other instanceof DrillUnionRelBase) { return other; } if (other instanceof DrillLimitRel) { if (DrillRelOptUtil.isLimit0(((DrillLimitRel) other).getFetch())) { contains = true; return other; } } return super.visit(other); }
@Override public boolean matches(RelOptRuleCall call) { LimitPrel limitPrel = call.rel(0); ProjectPrel projectPrel = call.rel(1); // pushdown only apply limit but not offset, // so if getFetch() return null no need to run this rule. // Do not push across Project containing CONVERT_FROMJSON for limit 0 queries. For limit 0 queries, this would // mess up the schema since Convert_FromJson() is different from other regular functions in that it only knows // the output schema after evaluation is performed. When input has 0 row, Drill essentially does not have a way // to know the output type. if (!limitPrel.isPushDown() && (limitPrel.getFetch() != null) && (!DrillRelOptUtil.isLimit0(limitPrel.getFetch()) || !DrillRelOptUtil.isProjectOutputSchemaUnknown(projectPrel))) { return true; } return false; } };
@Override public boolean matches(RelOptRuleCall call) { DrillLimitRel limitRel = call.rel(0); DrillProjectRel projectRel = call.rel(1); // pushdown only apply limit but not offset, // so if getFetch() return null no need to run this rule. // Do not push across Project containing CONVERT_FROMJSON for limit 0 queries. For limit 0 queries, this would // mess up the schema since Convert_FromJson() is different from other regular functions in that it only knows // the output schema after evaluation is performed. When input has 0 row, Drill essentially does not have a way // to know the output type. // Cannot pushdown limit and offset in to flatten as long as we don't know data distribution in flattened field if (!limitRel.isPushDown() && (limitRel.getFetch() != null) && (!DrillRelOptUtil.isLimit0(limitRel.getFetch()) || !DrillRelOptUtil.isProjectOutputSchemaUnknown(projectRel)) && !DrillRelOptUtil.isProjectOutputRowcountUnknown(projectRel)) { return true; } return false; }