public void addGroupExpr(SqlNode expr) { RexNode convExpr = bb.convertExpression(expr); final RexNode rex = lookupGroupExpr(expr); if (rex != null) { return; // don't add duplicates, in e.g. "GROUP BY x, y, x" } groupExprs.add(expr); String name = nameMap.get(expr.toString()); addExpr(convExpr, name); final RelDataType type = convExpr.getType(); inputRefs.add(rexBuilder.makeInputRef(type, inputRefs.size())); }
/** * 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; }
RelDataTypeField leftField = catalogReader.field(leftRowType, name); RexNode left = rexBuilder.makeInputRef( leftField.getType(), leftField.getIndex()); catalogReader.field(rightRowType, name); RexNode right = rexBuilder.makeInputRef( rightField.getType(), leftRowType.getFieldList().size() + rightField.getIndex());
rowType.getFieldCount() - orderExprList.size(); for (int i = 0; i < fieldCount; i++) { exprs.add(rexBuilder.makeInputRef(bb.root, i));
final RelDataType longType = typeFactory.createSqlType(SqlTypeName.BIGINT); final RexNode cRef = rexBuilder.makeInputRef(root, leftLeftCount); final RexNode ckRef = rexBuilder.makeInputRef(root, leftLeftCount + 1); final RexNode iRef = rexBuilder.makeInputRef(root, root.getRowType().getFieldCount() - 1); final JoinInfo joinInfo = join.analyzeCondition(); for (int leftKey : joinInfo.leftKeys) { final RexNode kRef = rexBuilder.makeInputRef(root, leftKey); args.add(rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL, kRef), unknownLiteral);
List<RexNode> newLeftInputExpr = Lists.newArrayList(); for (int i = 0; i < origLeftInputCount; i++) { newLeftInputExpr.add(rexBuilder.makeInputRef(root, i));
public RexNode get(int index) { final int pos = posList.get(index); return rexBuilder.makeInputRef(child, pos); } },
@Override public RexNode get(int index) { final int leftKey = leftKeys.get(index); final int rightKey = rightKeys.get(index); return rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, rexBuilder.makeInputRef(leftTypes.get(leftKey), leftKey), rexBuilder.makeInputRef(rightTypes.get(rightKey), leftTypes.size() + rightKey)); }
/** * Creates a reference to an aggregate call, checking for repeated calls. */ public RexNode addAggCall( AggregateCall aggCall, int groupCount, List<AggregateCall> aggCalls, Map<AggregateCall, RexNode> aggCallMapping) { RexNode rex = aggCallMapping.get(aggCall); if (rex == null) { int index = aggCalls.size() + groupCount; aggCalls.add(aggCall); rex = makeInputRef(aggCall.getType(), index); aggCallMapping.put(aggCall, rex); } return rex; }
/** * Creates a reference to a given field of the input relational expression. * * @param input Input relational expression * @param i Ordinal of field * @return Reference to field */ public RexInputRef makeInputRef(RelNode input, int i) { return makeInputRef(input.getRowType().getFieldList().get(i).getType(), i); }
private RexNode createCondition( RexBuilder builder, RelNode left, List<Integer> leftKeys, RelNode right, List<Integer> rightKeys ) { final List<RelDataType> leftTypes = RelOptUtil.getFieldTypeList( left.getRowType() ); final List<RelDataType> rightTypes = RelOptUtil.getFieldTypeList( right.getRowType() ); final List<RexNode> exprs = new ArrayList<RexNode>(); for( Pair<Integer, Integer> pair : Pair.zip( leftKeys, rightKeys ) ) exprs.add( builder.makeCall( SqlStdOperatorTable.equalsOperator, builder.makeInputRef( leftTypes.get( pair.left ), pair.left ), builder.makeInputRef( rightTypes.get( pair.right ), pair.right + leftTypes.size() ) ) ); return RexUtil.andRexNodeList( builder, exprs ); } }
public RexNode get(int index) { final int pos = posList.get(index); return child.getCluster().getRexBuilder().makeInputRef( child.getRowType().getFieldList().get(pos).getType(), pos); } },
public RexNode visitCall(RexCall call) { // if the expression corresponds to one that needs to be preserved, // convert it to a field reference; otherwise, convert the entire // expression int match = findExprInLists( call, preserveLeft, firstLeftRef, preserveRight, firstRightRef); if (match >= 0) { return rexBuilder.makeInputRef( destFields.get(match).getType(), match); } return super.visitCall(call); }
public void addGroupExpr(SqlNode expr) { RexNode convExpr = bb.convertExpression(expr); final RexNode rex = lookupGroupExpr(expr); if (rex != null) { return; // don't add duplicates, in e.g. "GROUP BY x, y, x" } groupExprs.add(expr); String name = nameMap.get(expr.toString()); addExpr(convExpr, name); final RelDataType type = convExpr.getType(); inputRefs.add(rexBuilder.makeInputRef(type, inputRefs.size())); }
public RexNode visitCall(RexCall call) { // if the expression corresponds to one that needs to be preserved, // convert it to a field reference; otherwise, convert the entire // expression int match = findExprInLists( call, preserveLeft, firstLeftRef, preserveRight, firstRightRef); if (match >= 0) { return rexBuilder.makeInputRef( destFields.get(match).getType(), match); } return super.visitCall(call); }
public void addGroupExpr(SqlNode expr) { RexNode convExpr = bb.convertExpression(expr); final RexNode rex = lookupGroupExpr(expr); if (rex != null) { return; // don't add duplicates, in e.g. "GROUP BY x, y, x" } groupExprs.add(expr); String name = nameMap.get(expr.toString()); addExpr(convExpr, name); final RelDataType type = convExpr.getType(); inputRefs.add(rexBuilder.makeInputRef(type, inputRefs.size())); }
/** * Creates a reference to an output field of a relational expression. * * @param rel Relational expression * @param i Field ordinal; if negative, counts from end, so -1 means the * last field */ public static RexNode createInputRef( RelNode rel, int i) { final List<RelDataTypeField> fields = rel.getRowType().getFieldList(); if (i < 0) { i = fields.size() + i; } return rel.getCluster().getRexBuilder().makeInputRef( fields.get(i).getType(), i); }
/** * 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; }
@Test public void testSimpleIdentifier() { RexNode node = rexBuilder.makeInputRef(boolRelDataType, 0); check(Boolean.TRUE, node, "=(IS TRUE($0), true)"); }
@Test public void testSimpleIdentifier() { RexNode node = rexBuilder.makeInputRef(boolRelDataType, 0); check(Boolean.TRUE, node, "=(IS TRUE($0), true)"); }