Esempio n. 1
0
 /**
  * Generates a cast from one row type to another
  *
  * @param rexBuilder RexBuilder to use for constructing casts
  * @param lhsRowType target row type
  * @param rhsRowType source row type; fields must be 1-to-1 with lhsRowType, in same order
  * @return cast expressions
  */
 public static RexNode[] generateCastExpressions(
     RexBuilder rexBuilder, RelDataType lhsRowType, RelDataType rhsRowType) {
   int n = rhsRowType.getFieldCount();
   assert n == lhsRowType.getFieldCount()
       : "field count: lhs [" + lhsRowType + "] rhs [" + rhsRowType + "]";
   RexNode[] rhsExps = new RexNode[n];
   for (int i = 0; i < n; ++i) {
     rhsExps[i] = rexBuilder.makeInputRef(rhsRowType.getFields()[i].getType(), i);
   }
   return generateCastExpressions(rexBuilder, lhsRowType, rhsExps);
 }
Esempio n. 2
0
 public Void visitInputRef(RexInputRef inputRef) {
   super.visitInputRef(inputRef);
   if (inputRef.getIndex() >= inputRowType.getFieldCount()) {
     throw new IllegalForwardRefException();
   }
   return null;
 }