/** Creates an expression which references the <i>ordinal</i><sup>th</sup> input. */ public Expression translateInput(JavaRel rel, int ordinal) { final RelDataType rowType = rel.getRowType(); int fieldOffset = computeFieldOffset(rel, ordinal); return translate(rel, rexBuilder.makeRangeReference(rowType, fieldOffset, false)); }
/** * Creates an expression which references the <i> fieldOrdinal</i><sup>th</sup> field of the * <i>ordinal</i><sup>th</sup> input. * * <p>(We can potentially optimize the generation process, so we can access field values without * actually instantiating the row.) */ public Expression translateInputField(JavaRel rel, int ordinal, int fieldOrdinal) { assert ordinal >= 0; assert ordinal < rel.getInputs().size(); assert fieldOrdinal >= 0; assert fieldOrdinal < rel.getInput(ordinal).getRowType().getFieldList().size(); RelDataType rowType = rel.getRowType(); final RelDataTypeField[] fields = rowType.getFields(); final int fieldIndex = computeFieldOffset(rel, ordinal) + fieldOrdinal; assert fieldIndex >= 0; assert fieldIndex < fields.length; final RexNode expr = rexBuilder.makeInputRef(fields[fieldIndex].getType(), fieldIndex); return translate(rel, expr); }