protected RexNode convert(ExprNodeColumnDesc col) throws SemanticException { //if this is co-rrelated we need to make RexCorrelVariable(with id and type) // id and type should be retrieved from outerRR InputCtx ic = getInputCtx(col); if(ic == null) { // we have correlated column, build data type from outer rr RelDataType rowType = TypeConverter.getType(cluster, this.outerRR, null); if (this.outerNameToPosMap.get(col.getColumn()) == null) { throw new SemanticException(ErrorMsg.INVALID_COLUMN_NAME.getMsg(col.getColumn())); } int pos = this.outerNameToPosMap.get(col.getColumn()); CorrelationId colCorr = new CorrelationId(this.correlatedId); RexNode corExpr = cluster.getRexBuilder().makeCorrel(rowType, colCorr); return cluster.getRexBuilder().makeFieldAccess(corExpr, pos); } int pos = ic.hiveNameToPosMap.get(col.getColumn()); return cluster.getRexBuilder().makeInputRef( ic.calciteInpDataType.getFieldList().get(pos).getType(), pos + ic.offsetInCalciteSchema); }
@Override public String toString() { return corr.getName() + '.' + field; }
public int compareTo(@Nonnull CorDef o) { int c = corr.compareTo(o.corr); if (c != 0) { return c; } return Integer.compare(field, o.field); }
protected RexNode handle(RexFieldAccess fieldAccess) { final RexCorrelVariable v = (RexCorrelVariable) fieldAccess.getReferenceExpr(); if (v.id.equals(correlation)) { fieldsUsedBuilder.set(fieldAccess.getField().getIndex()); } return fieldAccess; } });
public EquiJoin(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, RexNode condition, ImmutableIntList leftKeys, ImmutableIntList rightKeys, JoinRelType joinType, Set<String> variablesStopped) { super(cluster, traits, left, right, condition, leftKeys, rightKeys, CorrelationId.setOf(variablesStopped), joinType); } }
private Object toJson(CorrelationId node) { return node.getId(); }
@SuppressWarnings("deprecation") public final Set<String> getVariablesStopped() { return CorrelationId.names(getVariablesSet()); }
: new ArrayList<>(corDefOutputs.entrySet())) { final CorDef corDef = rightOutput.getKey(); if (!corDef.corr.equals(rel.getCorrelationId())) { continue;
public EquiJoin(RelOptCluster cluster, RelTraitSet traits, RelNode left, RelNode right, RexNode condition, ImmutableIntList leftKeys, ImmutableIntList rightKeys, JoinRelType joinType, Set<String> variablesStopped) { super(cluster, traits, left, right, condition, leftKeys, rightKeys, CorrelationId.setOf(variablesStopped), joinType); } }
private Object toJson(CorrelationId node) { return node.getId(); }
@SuppressWarnings("deprecation") public final Set<String> getVariablesStopped() { return CorrelationId.names(getVariablesSet()); }
protected RexNode convert(ExprNodeColumnDesc col) throws SemanticException { //if this is co-rrelated we need to make RexCorrelVariable(with id and type) // id and type should be retrieved from outerRR InputCtx ic = getInputCtx(col); if(ic == null) { // we have correlated column, build data type from outer rr RelDataType rowType = TypeConverter.getType(cluster, this.outerRR, null); if (this.outerNameToPosMap.get(col.getColumn()) == null) { throw new SemanticException(ErrorMsg.INVALID_COLUMN_NAME.getMsg(col.getColumn())); } int pos = this.outerNameToPosMap.get(col.getColumn()); CorrelationId colCorr = new CorrelationId(this.correlatedId); RexNode corExpr = cluster.getRexBuilder().makeCorrel(rowType, colCorr); return cluster.getRexBuilder().makeFieldAccess(corExpr, pos); } int pos = ic.hiveNameToPosMap.get(col.getColumn()); return cluster.getRexBuilder().makeInputRef( ic.calciteInpDataType.getFieldList().get(pos).getType(), pos + ic.offsetInCalciteSchema); }
@Override public String toString() { return corr.getName() + '.' + field; }
: new ArrayList<>(corDefOutputs.entrySet())) { final CorDef corDef = rightOutput.getKey(); if (!corDef.corr.equals(rel.getCorrelationId())) { continue;
@Deprecated // to be removed before 2.0 protected BindableJoin(RelOptCluster cluster, RelTraitSet traitSet, RelNode left, RelNode right, RexNode condition, JoinRelType joinType, Set<String> variablesStopped) { this(cluster, traitSet, left, right, condition, CorrelationId.setOf(variablesStopped), joinType); }
public int compareTo(@Nonnull CorRef o) { int c = corr.compareTo(o.corr); if (c != 0) { return c; } c = Integer.compare(field, o.field); if (c != 0) { return c; } return Integer.compare(uniqueKey, o.uniqueKey); }
/** * Constructs a new id for a correlating variable. It is unique within the * whole query. */ public CorrelationId createCorrel() { return new CorrelationId(nextCorrel.getAndIncrement()); }
@Override public String toString() { return corr.getName() + '.' + field; }
/** Returns whether a {@link CorrelationId} is satisfied by at least one of a * collection of {@link CorDef}s. */ private boolean has(Collection<CorDef> corDefs, CorRef corr) { for (CorDef corDef : corDefs) { if (corDef.corr.equals(corr.corr) && corDef.field == corr.field) { return true; } } return false; }