@Override public String toString() { return "ref for:" + node.toString(); } }
public String apply(RexNode r) { return r.toString(); } };
public String apply(RexNode r) { return r.toString(); } };
@Override public int hashCode() { return node.toString().hashCode(); }
@Override public int hashCode() { return Objects.hash(left, right, condition.toString(), joinType); }
@Override public int hashCode() { return Objects.hash(input, condition.toString()); }
/** * Finds the ordinal of an element in a list, or adds it. * * @param list List * @param element Element to lookup or add * @return Ordinal of element in list */ private static int lookupOrAdd(List<RexNode> list, RexNode element) { for (int ordinal = 0; ordinal < list.size(); ordinal++) { if (list.get(ordinal).toString().equals(element.toString())) { return ordinal; } } list.add(element); return list.size() - 1; }
private static List<RexNode> getNotNullConditions(RelOptCluster cluster, RexBuilder rexBuilder, List<RexNode> inputJoinExprs, Set<String> pushedPredicates) { final List<RexNode> newConditions = Lists.newArrayList(); for (RexNode rexNode : inputJoinExprs) { RexNode cond = rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL, rexNode); String digest = cond.toString(); if (pushedPredicates.add(digest)) { newConditions.add(cond); } } return newConditions; }
public Iterator<Mapping> iterator() { ImmutableBitSet fields = exprFields.get(predicate.toString()); if (fields.cardinality() == 0) { return Collections.emptyIterator(); } return new ExprsItr(fields); } };
private void getInputRefMapping(RexNode condition, RelDataType rowType, HashMap<String, String> mapping) { if (condition instanceof RexCall) { for (RexNode op : ((RexCall) condition).getOperands()) { getInputRefMapping(op, rowType, mapping); } } else if (condition instanceof RexInputRef) { mapping.put(condition.toString(), rowType.getFieldNames().get(condition.hashCode())); } }
private RexNode visit(final RexNode call) { RexNode replacement = replacements.get(call.toString()); if (replacement == null) { return null; } if (replacement.getType().equals(call.getType())) { return replacement; } return rexBuilder.makeCast(call.getType(), replacement, true); } }
public Iterator<Mapping> iterator() { ImmutableBitSet fields = exprFields.get(predicate.toString()); if (fields.cardinality() == 0) { return Iterators.emptyIterator(); } return new ExprsItr(fields); } };
private RexNode visit(final RexNode call) { RexNode replacement = replacements.get(call.toString()); if (replacement == null) { return null; } if (replacement.getType().equals(call.getType())) { return replacement; } return rexBuilder.makeCast(call.getType(), replacement, true); } }
protected static String generateInvalidSchemaMessage(Project topLevelProj, List<FieldSchema> resultSchema, int fieldsForOB) { String errorDesc = "Result Schema didn't match Calcite Optimized Op Tree; schema: "; for (FieldSchema fs : resultSchema) { errorDesc += "[" + fs.getName() + ":" + fs.getType() + "], "; } errorDesc += " projection fields: "; for (RexNode exp : topLevelProj.getChildExps()) { errorDesc += "[" + exp.toString() + ":" + exp.getType() + "], "; } if (fieldsForOB != 0) { errorDesc += fieldsForOB + " fields removed due to ORDER BY "; } return errorDesc.substring(0, errorDesc.length() - 2); }
@Override public void onMatch(RelOptRuleCall call) { final Filter filter = call.rel(0); final RexBuilder rexBuilder = filter.getCluster().getRexBuilder(); final RexNode condition = RexUtil.pullFactors(rexBuilder, filter.getCondition()); RexNode newCondition = analyzeRexNode(rexBuilder, condition); // If we could not transform anything, we bail out if (newCondition.toString().equals(condition.toString())) { return; } RelNode newNode = filter.copy(filter.getTraitSet(), filter.getInput(), newCondition); call.transformTo(newNode); } }
@Override public void onMatch(RelOptRuleCall call) { final Filter filter = call.rel(0); final RexBuilder rexBuilder = filter.getCluster().getRexBuilder(); final RelMetadataQuery metadataProvider = call.getMetadataQuery(); // 1. Recompose filter possibly by pulling out common elements from DNF // expressions RexNode newFilterCondition = RexUtil.pullFactors(rexBuilder, filter.getCondition()); // 2. Reduce filter with stats information RexReplacer replacer = new RexReplacer(filter, rexBuilder, metadataProvider); newFilterCondition = replacer.apply(newFilterCondition); // 3. Transform if we have created a new filter operator if (!filter.getCondition().toString().equals(newFilterCondition.toString())) { Filter newFilter = filter.copy(filter.getTraitSet(), filter.getInput(), newFilterCondition); call.transformTo(newFilter); } }
@Override public void onMatch(RelOptRuleCall call) { final Join join = call.rel(0); final RexBuilder rexBuilder = join.getCluster().getRexBuilder(); final RexNode condition = RexUtil.pullFactors(rexBuilder, join.getCondition()); RexNode newCondition = analyzeRexNode(rexBuilder, condition); // If we could not transform anything, we bail out if (newCondition.toString().equals(condition.toString())) { return; } RelNode newNode = join.copy(join.getTraitSet(), newCondition, join.getLeft(), join.getRight(), join.getJoinType(), join.isSemiJoinDone()); call.transformTo(newNode); } }