/** * Adds an expression, deducing an appropriate name if possible. * * @param expr Expression * @param name Suggested name */ private void addExpr(RexNode expr, String name) { convertedInputExprs.add(expr); if ((name == null) && (expr instanceof RexInputRef)) { final int i = ((RexInputRef) expr).getIndex(); name = bb.root.getRowType().getFieldList().get(i).getName(); } if (convertedInputExprNames.contains(name)) { // In case like 'SELECT ... GROUP BY x, y, x', don't add // name 'x' twice. name = null; } convertedInputExprNames.add(name); }
RelDataTypeField getRootField(RexInputRef inputRef) { int fieldOffset = inputRef.getIndex(); for (RelNode input : inputs) { RelDataType rowType = input.getRowType(); if (rowType == null) { // TODO: remove this once leastRestrictive // is correctly implemented return null; } if (fieldOffset < rowType.getFieldCount()) { return rowType.getFieldList().get(fieldOffset); } fieldOffset -= rowType.getFieldCount(); } throw new AssertionError(); }
/** * Adjusts the type of a reference to an input field to account for nulls * introduced by outer joins; and adjusts the offset to match the physical * implementation. * * @param bb Blackboard * @param inputRef Input ref * @return Adjusted input ref */ protected RexNode adjustInputRef( Blackboard bb, RexInputRef inputRef) { RelDataTypeField field = bb.getRootField(inputRef); if (field != null) { return rexBuilder.makeInputRef( field.getType(), inputRef.getIndex()); } return inputRef; }
&& (level1InsertExprs.get(level1Idx) instanceof RexInputRef)) { int level2Idx = ((RexInputRef) level1InsertExprs.get(level1Idx)).getIndex(); projects.add(level2InsertExprs.get(level2Idx)); } else {
public Void visitInputRef(RexInputRef inputRef) { refCounts[inputRef.getIndex()]++; return null; } }
private boolean isRealRexInputRef(RexInputRef inputRef) { if (lowerRexInputIdx < 0 && upperRexInputIdx < 0) { return true; } int idx = inputRef.getIndex(); return idx < lowerRexInputIdx || idx >= upperRexInputIdx; }
public Void visitInputRef(RexInputRef inputRef) { rexRefSet.set(inputRef.getIndex()); return null; }
private static boolean isStar(List<RexNode> exps, RelDataType inputRowType) { int i = 0; for (RexNode ref : exps) { if (!(ref instanceof RexInputRef)) { return false; } else if (((RexInputRef) ref).getIndex() != i++) { return false; } } return i == inputRowType.getFieldCount(); }
public static Boolean areColumnsUnique( RelNode rel, List<RexInputRef> columnRefs) { BitSet colMask = new BitSet(); for (RexInputRef columnRef : columnRefs) { colMask.set(columnRef.getIndex()); } return RelMetadataQuery.areColumnsUnique(rel, colMask); }
public static Boolean areColumnsUniqueWhenNullsFiltered( RelNode rel, List<RexInputRef> columnRefs) { BitSet colMask = new BitSet(); for (RexInputRef columnRef : columnRefs) { colMask.set(columnRef.getIndex()); } return RelMetadataQuery.areColumnsUnique(rel, colMask, true); }
public static Boolean areColumnsUnique( RelNode rel, List<RexInputRef> columnRefs) { BitSet colMask = new BitSet(); for (int i = 0; i < columnRefs.size(); i++) { colMask.set(columnRefs.get(i).getIndex()); } return RelMetadataQuery.areColumnsUnique(rel, colMask); }
public Void visitInputRef(RexInputRef inputRef) { Set<RelColumnOrigin> inputSet = invokeGetColumnOrigins( child, inputRef.getIndex()); if (inputSet != null) { set.addAll(inputSet); } return null; } };
public static Boolean areColumnsUniqueWhenNullsFiltered( RelNode rel, List<RexInputRef> columnRefs) { BitSet colMask = new BitSet(); for (int i = 0; i < columnRefs.size(); i++) { colMask.set(columnRefs.get(i).getIndex()); } return RelMetadataQuery.areColumnsUnique(rel, colMask, true); }
public Void visitInputRef(RexInputRef inputRef) { Set<RelColumnOrigin> inputSet = invokeGetColumnOrigins( child, inputRef.getIndex()); if (inputSet != null) { set.addAll(inputSet); } return null; } };
public RexNode visitInputRef(RexInputRef input) { final int index = exprInverseOrdinals[input.getIndex()]; assert index >= 0; return new RexLocalRef( index, input.getType()); }
public RexNode visitInputRef(RexInputRef input) { final int index = exprInverseOrdinals[input.getIndex()]; assert index >= 0; return new RexLocalRef( index, input.getType()); }
@Override public RexNode visitInputRef(RexInputRef input) { final int index = input.getIndex(); if (index < start) { return input; } return new RexInputRef(index + offset, input.getType()); } });
@Override public RexNode visitInputRef(RexInputRef local) { final int index = local.getIndex(); int target = mapping.getTarget(index); return new RexInputRef( target, local.getType()); }
public Void visitInputRef(RexInputRef inputRef) { super.visitInputRef(inputRef); if (inputRef.getIndex() >= inputRowType.getFieldCount()) { throw new IllegalForwardRefException(); } return null; }
public RexNode visitInputRef(RexInputRef input) { final int oldIndex = input.getIndex(); final int newIndex = getNewForOldInput(oldIndex); // FIXME: jhyde, 2005/12/3: Once indicator fields have been // introduced, the new field type may be very different to the // old field type. We should look at the actual flattened types, // rather than trying to deduce the type from the current type. RelDataType fieldType = removeDistinct(input.getType()); RexInputRef newInput = new RexInputRef(newIndex, fieldType); return newInput; }