/** Converts op(arg0, ..., argOrdinal, ..., argN) to op(arg0,..., node, ..., argN). */ protected static RexNode substitute(RexCall call, int ordinal, RexNode node) { final List<RexNode> newOperands = Lists.newArrayList(call.getOperands()); newOperands.set(ordinal, node); return call.clone(call.getType(), newOperands); }
/** Converts op(arg0, ..., argOrdinal, ..., argN) to op(arg0,..., node, ..., argN). */ protected static RexNode substitute(RexCall call, int ordinal, RexNode node) { final List<RexNode> newOperands = Lists.newArrayList(call.getOperands()); newOperands.set(ordinal, node); return call.clone(call.getType(), newOperands); }
public RexNode visitCall(RexCall call) { final List<RexNode> newOperands = new ArrayList<>(); for (RexNode operand : call.getOperands()) { newOperands.add(operand.accept(this)); } return call.clone(call.getType(), newOperands); }
public RexNode visitCall(RexCall call) { final List<RexNode> newOperands = new ArrayList<>(); for (RexNode operand : call.getOperands()) { newOperands.add(operand.accept(this)); } return call.clone(call.getType(), newOperands); }
public RexNode visitCall(final RexCall call) { boolean[] update = {false}; List<RexNode> clonedOperands = visitList(call.operands, update); if (update[0]) { // REVIEW jvs 8-Mar-2005: This doesn't take into account // the fact that a rewrite may have changed the result type. // To do that, we would need to take a RexBuilder and // watch out for special operators like CAST and NEW where // the type is embedded in the original call. return call.clone(call.getType(), clonedOperands); } else { return call; } }
private RexNode simplifyCoalesce(RexCall call) { final Set<String> digests = new HashSet<>(); final List<RexNode> operands = new ArrayList<>(); for (RexNode operand : call.getOperands()) { operand = simplify(operand, UNKNOWN); if (digests.add(operand.toString())) { operands.add(operand); } if (!operand.getType().isNullable()) { break; } } switch (operands.size()) { case 0: return rexBuilder.makeNullLiteral(call.type); case 1: return operands.get(0); default: if (operands.equals(call.operands)) { return call; } return call.clone(call.type, operands); } }
private RexNode simplifyCoalesce(RexCall call) { final Set<RexNode> operandSet = new HashSet<>(); final List<RexNode> operands = new ArrayList<>(); for (RexNode operand : call.getOperands()) { operand = simplify(operand, UNKNOWN); if (!RexUtil.isNull(operand) && operandSet.add(operand)) { operands.add(operand); } if (!operand.getType().isNullable()) { break; } } switch (operands.size()) { case 0: return rexBuilder.makeNullLiteral(call.type); case 1: return operands.get(0); default: if (operands.equals(call.operands)) { return call; } return call.clone(call.type, operands); } }
private static RexCall call2( boolean harmonize, RexToLixTranslator translator, RexCall call) { if (!harmonize) { return call; } final List<RexNode> operands2 = harmonize(translator, call.getOperands()); if (operands2.equals(call.getOperands())) { return call; } return call.clone(call.getType(), operands2); }
builder.add(go(operand)); return call.clone(call.getType(), builder.build()); } else if (rex instanceof RexInputRef) { RexInputRef var = (RexInputRef) rex;
private static RexNode convertCastCondition(RexNode node) { switch (node.getKind()) { case IS_NULL: case IS_NOT_NULL: case OR: case AND: case EQUALS: RexCall call = (RexCall) node; List<RexNode> list = Lists.newArrayList(); List<RexNode> operands = Lists.newArrayList(call.getOperands()); for (int i = 0; i < operands.size(); i++) { RexNode operand = operands.get(i); final RexNode e = convertCastCondition( operand); list.add(e); } if (!list.equals(call.getOperands())) { return call.clone(call.getType(), list); } return call; case CAST: call = (RexCall) node; operands = Lists.newArrayList(call.getOperands()); return operands.get(0); default: return node; } }
private static RexCall call2( boolean harmonize, RexToLixTranslator translator, RexCall call) { if (!harmonize) { return call; } final List<RexNode> operands2 = harmonize(translator, call.getOperands()); if (operands2.equals(call.getOperands())) { return call; } return call.clone(call.getType(), operands2); }
builder.add(go(operand)); return call.clone(call.getType(), builder.build()); } else if (rex instanceof RexInputRef) { RexInputRef var = (RexInputRef) rex;
public RexNode visitCall(RexCall call) { List<RexNode> normalizedOperands = new ArrayList<>(); int diffCount = 0; for (RexNode operand : call.getOperands()) { operand.accept(this); final RexNode normalizedOperand = lookup(operand); normalizedOperands.add(normalizedOperand); if (normalizedOperand != operand) { ++diffCount; } } if (diffCount > 0) { call = call.clone( call.getType(), normalizedOperands); } return register(call); }
@Override public RexNode visitCall(RexCall call) { String functionName = call.getOperator().getName(); List<RexNode> newOps = new ArrayList<>(); for (RexNode operand : call.operands) { newOps.add(operand.accept(this)); } if (funcReg.isFunctionComplexOutput(functionName)) { RexNode ret = builder.makeInputRef( factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true), lastUsedIndex); lastUsedIndex++; complexExprs.add(call.clone(factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true), newOps)); return ret; } return call.clone(call.getType(), newOps); }
public RexNode visitCall(RexCall call) { List<RexNode> normalizedOperands = new ArrayList<>(); int diffCount = 0; for (RexNode operand : call.getOperands()) { operand.accept(this); final RexNode normalizedOperand = lookup(operand); normalizedOperands.add(normalizedOperand); if (normalizedOperand != operand) { ++diffCount; } } if (diffCount > 0) { call = call.clone( call.getType(), normalizedOperands); } return register(call); }
@Override public RexNode visitCall(RexCall call) { String functionName = call.getOperator().getName(); List<RexNode> newOps = new ArrayList<>(); for (RexNode operand : call.operands) { newOps.add(operand.accept(this)); } if (funcReg.isFunctionComplexOutput(functionName) ) { RexBuilder builder = new RexBuilder(factory); RexNode ret = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), lastUsedIndex); lastUsedIndex++; complexExprs.add(call.clone(new RelDataTypeDrillImpl(new RelDataTypeHolder(),factory), newOps)); return ret; } return call.clone(call.getType(), newOps); }
public RexNode go(RexNode rex) { if (rex instanceof RexCall) { ImmutableList.Builder<RexNode> builder = ImmutableList.builder(); final RexCall call = (RexCall) rex; for (RexNode operand : call.operands) { builder.add(go(operand)); } return call.clone(call.getType(), builder.build()); } else if (rex instanceof RexInputRef) { RexInputRef var = (RexInputRef) rex; int index = var.getIndex(); return rexBuilder.makeInputRef(var.getType(), inputRefMap.get(index)); } else { return rex; } } }