public RexNode get(int index) { final RexNode operand = operands.get(index); if (operand instanceof RexInputRef) { return operand; } assert operand instanceof RexLocalRef; final RexLocalRef ref = (RexLocalRef) operand; return new RexInputRef(ref.getIndex(), ref.getType()); } };
public RexNode visitLocalRef(RexLocalRef localRef) { final int index = localRef.getIndex(); if (index < inputFieldCount) { // Reference to input field. return localRef; } return new RexLocalRef( flattenedAggCallList.size() + index, localRef.getType()); } };
public RexNode get(int index) { final RexNode operand = operands.get(index); if (operand instanceof RexInputRef) { return operand; } assert operand instanceof RexLocalRef; final RexLocalRef ref = (RexLocalRef) operand; return new RexInputRef(ref.getIndex(), ref.getType()); } };
public RexNode visitLocalRef(RexLocalRef localRef) { final int index = localRef.getIndex(); if (index < inputFieldCount) { // Reference to input field. return localRef; } return new RexLocalRef( flattenedAggCallList.size() + index, localRef.getType()); } };
/** Dereferences an expression if it is a * {@link org.apache.calcite.rex.RexLocalRef}. */ public RexNode deref(RexNode expr) { if (expr instanceof RexLocalRef) { RexLocalRef ref = (RexLocalRef) expr; final RexNode e2 = program.getExprList().get(ref.getIndex()); assert ref.getType().equals(e2.getType()); return e2; } else { return expr; } }
/** Dereferences an expression if it is a * {@link org.apache.calcite.rex.RexLocalRef}. */ public RexNode deref(RexNode expr) { if (expr instanceof RexLocalRef) { RexLocalRef ref = (RexLocalRef) expr; final RexNode e2 = program.getExprList().get(ref.getIndex()); assert ref.getType().equals(e2.getType()); return e2; } else { return expr; } }
@Override public RexNode visitLocalRef(RexLocalRef localRef) { return new RexInputRef(localRef.getIndex(), localRef.getType()); } };
@Override public RexNode visitLocalRef(RexLocalRef localRef) { return new RexInputRef(localRef.getIndex(), localRef.getType()); } };
public RexNode visitLocalRef(RexLocalRef local) { // A reference to a local variable becomes a reference to an input // if the local was computed at a previous level. final int localIndex = local.getIndex(); final int exprLevel = exprLevels[localIndex]; if (exprLevel < level) { if (allExprs[localIndex] instanceof RexLiteral) { // Expression is to be inlined. Use the original expression. return allExprs[localIndex]; } int inputIndex = indexOf(localIndex, inputExprOrdinals); assert inputIndex >= 0; return new RexLocalRef( inputIndex, local.getType()); } else { // It's a reference to what was a local expression at the // previous level, and was then projected. final int exprIndex = exprInverseOrdinals[localIndex]; return new RexLocalRef( exprIndex, local.getType()); } } }
public RexNode visitLocalRef(RexLocalRef local) { // A reference to a local variable becomes a reference to an input // if the local was computed at a previous level. final int localIndex = local.getIndex(); final int exprLevel = exprLevels[localIndex]; if (exprLevel < level) { if (allExprs[localIndex] instanceof RexLiteral) { // Expression is to be inlined. Use the original expression. return allExprs[localIndex]; } int inputIndex = indexOf(localIndex, inputExprOrdinals); assert inputIndex >= 0; return new RexLocalRef( inputIndex, local.getType()); } else { // It's a reference to what was a local expression at the // previous level, and was then projected. final int exprIndex = exprInverseOrdinals[localIndex]; return new RexLocalRef( exprIndex, local.getType()); } } }
public RexNode visitInputRef(RexInputRef input) { // This expression refers to the Nth project column. Lookup that // column and find out what common sub-expression IT refers to. final int index = input.getIndex(); final RexLocalRef local = projectRefList.get(index); assert RelOptUtil.eq( "type1", local.getType(), "type2", input.getType(), Litmus.THROW); return local; }
public RexNode visitInputRef(RexInputRef input) { // This expression refers to the Nth project column. Lookup that // column and find out what common sub-expression IT refers to. final int index = input.getIndex(); final RexLocalRef local = projectRefList.get(index); assert RelOptUtil.eq( "type1", local.getType(), "type2", input.getType(), Litmus.THROW); return local; }
public RexNode visitLocalRef(RexLocalRef local) { final int index = local.getIndex(); int target = permutation.getTarget(index); return new RexLocalRef( target, local.getType()); } }
public RexNode visitLocalRef(RexLocalRef local) { final int index = local.getIndex(); int target = permutation.getTarget(index); return new RexLocalRef( target, local.getType()); } }
@Override public RexNode visitLocalRef(RexLocalRef localRef) { return new RexInputRef(map.get(localRef.getIndex()), localRef.getType()); }
exprList.get(index).getType(), "ref type", local.getType(), Litmus.THROW);
exprList.get(index).getType(), "ref type", local.getType(), Litmus.THROW);
/** Overrides {@link RexChecker} method, because {@link RexLocalRef} is * is illegal in most rex expressions, but legal in a program. */ @Override public Boolean visitLocalRef(RexLocalRef localRef) { final int index = localRef.getIndex(); if ((index < 0) || (index >= internalExprTypeList.size())) { ++failCount; return litmus.fail(null); } if (!RelOptUtil.eq( "type1", localRef.getType(), "type2", internalExprTypeList.get(index), litmus)) { ++failCount; return litmus.fail(null); } return litmus.succeed(); } }
/** Overrides {@link RexChecker} method, because {@link RexLocalRef} is * is illegal in most rex expressions, but legal in a program. */ @Override public Boolean visitLocalRef(RexLocalRef localRef) { final int index = localRef.getIndex(); if ((index < 0) || (index >= internalExprTypeList.size())) { ++failCount; return litmus.fail(null); } if (!RelOptUtil.eq( "type1", localRef.getType(), "type2", internalExprTypeList.get(index), litmus)) { ++failCount; return litmus.fail(null); } return litmus.succeed(); } }
new Checker(inputRowType, RexUtil.types(exprs), null, litmus); if (condition != null) { if (!SqlTypeUtil.inBooleanFamily(condition.getType())) { return litmus.fail("condition must be boolean");