Java Code Examples for org.apache.calcite.rex.RexFieldAccess#getReferenceExpr()
The following examples show how to use
org.apache.calcite.rex.RexFieldAccess#getReferenceExpr() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelDecorrelator.java From Bats with Apache License 2.0 | 6 votes |
private boolean references(RexNode e, CorRef correlation) { switch (e.getKind()) { case CAST: final RexNode operand = ((RexCall) e).getOperands().get(0); if (isWidening(e.getType(), operand.getType())) { return references(operand, correlation); } return false; case FIELD_ACCESS: final RexFieldAccess f = (RexFieldAccess) e; if (f.getField().getIndex() == correlation.field && f.getReferenceExpr() instanceof RexCorrelVariable) { if (((RexCorrelVariable) f.getReferenceExpr()).getCorrelationId() == correlation.corr) { return true; } } // fall through default: return false; } }
Example 2
Source File: RelDecorrelator.java From flink with Apache License 2.0 | 6 votes |
private boolean references(RexNode e, CorRef correlation) { switch (e.getKind()) { case CAST: final RexNode operand = ((RexCall) e).getOperands().get(0); if (isWidening(e.getType(), operand.getType())) { return references(operand, correlation); } return false; case FIELD_ACCESS: final RexFieldAccess f = (RexFieldAccess) e; if (f.getField().getIndex() == correlation.field && f.getReferenceExpr() instanceof RexCorrelVariable) { if (((RexCorrelVariable) f.getReferenceExpr()).id == correlation.corr) { return true; } } // fall through default: return false; } }
Example 3
Source File: RelDecorrelator.java From flink with Apache License 2.0 | 6 votes |
private boolean references(RexNode e, CorRef correlation) { switch (e.getKind()) { case CAST: final RexNode operand = ((RexCall) e).getOperands().get(0); if (isWidening(e.getType(), operand.getType())) { return references(operand, correlation); } return false; case FIELD_ACCESS: final RexFieldAccess f = (RexFieldAccess) e; if (f.getField().getIndex() == correlation.field && f.getReferenceExpr() instanceof RexCorrelVariable) { if (((RexCorrelVariable) f.getReferenceExpr()).id == correlation.corr) { return true; } } // fall through default: return false; } }
Example 4
Source File: RelDecorrelator.java From calcite with Apache License 2.0 | 6 votes |
private boolean references(RexNode e, CorRef correlation) { switch (e.getKind()) { case CAST: final RexNode operand = ((RexCall) e).getOperands().get(0); if (isWidening(e.getType(), operand.getType())) { return references(operand, correlation); } return false; case FIELD_ACCESS: final RexFieldAccess f = (RexFieldAccess) e; if (f.getField().getIndex() == correlation.field && f.getReferenceExpr() instanceof RexCorrelVariable) { if (((RexCorrelVariable) f.getReferenceExpr()).id == correlation.corr) { return true; } } // fall through default: return false; } }
Example 5
Source File: CorrelationReferenceFinder.java From Bats with Apache License 2.0 | 5 votes |
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { if (fieldAccess.getReferenceExpr() instanceof RexCorrelVariable) { return finder.handle(fieldAccess); } return super.visitFieldAccess(fieldAccess); }
Example 6
Source File: RelDecorrelator.java From Bats with Apache License 2.0 | 5 votes |
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) { return new RexVisitorImpl<Void>(true) { @Override public Void visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode ref = fieldAccess.getReferenceExpr(); if (ref instanceof RexCorrelVariable) { final RexCorrelVariable var = (RexCorrelVariable) ref; if (mapFieldAccessToCorVar.containsKey(fieldAccess)) { // for cases where different Rel nodes are referring to // same correlation var (e.g. in case of NOT IN) // avoid generating another correlation var // and record the 'rel' is using the same correlation mapRefRelToCorRef.put(rel, mapFieldAccessToCorVar.get(fieldAccess)); } else { final CorRef correlation = new CorRef(var.getCorrelationId(), fieldAccess.getField().getIndex(), corrIdGenerator++); mapFieldAccessToCorVar.put(fieldAccess, correlation); mapRefRelToCorRef.put(rel, correlation); } } return super.visitFieldAccess(fieldAccess); } @Override public Void visitSubQuery(RexSubQuery subQuery) { subQuery.getRel().accept(CorelMapBuilder.this); return super.visitSubQuery(subQuery); } }; }
Example 7
Source File: RelOptUtil.java From Bats with Apache License 2.0 | 5 votes |
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { if (fieldAccess.getReferenceExpr() instanceof RexCorrelVariable) { final RexCorrelVariable v = (RexCorrelVariable) fieldAccess.getReferenceExpr(); variableFields.put(v.getCorrelationId(), fieldAccess.getField().getIndex()); } return super.visitFieldAccess(fieldAccess); }
Example 8
Source File: RelDecorrelator.java From flink with Apache License 2.0 | 5 votes |
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) { return new RexVisitorImpl<Void>(true) { @Override public Void visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode ref = fieldAccess.getReferenceExpr(); if (ref instanceof RexCorrelVariable) { final RexCorrelVariable var = (RexCorrelVariable) ref; if (mapFieldAccessToCorVar.containsKey(fieldAccess)) { // for cases where different Rel nodes are referring to // same correlation var (e.g. in case of NOT IN) // avoid generating another correlation var // and record the 'rel' is using the same correlation mapRefRelToCorRef.put(rel, mapFieldAccessToCorVar.get(fieldAccess)); } else { final CorRef correlation = new CorRef(var.id, fieldAccess.getField().getIndex(), corrIdGenerator++); mapFieldAccessToCorVar.put(fieldAccess, correlation); mapRefRelToCorRef.put(rel, correlation); } } return super.visitFieldAccess(fieldAccess); } @Override public Void visitSubQuery(RexSubQuery subQuery) { subQuery.rel.accept(CorelMapBuilder.this); return super.visitSubQuery(subQuery); } }; }
Example 9
Source File: RelDecorrelator.java From flink with Apache License 2.0 | 5 votes |
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) { return new RexVisitorImpl<Void>(true) { @Override public Void visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode ref = fieldAccess.getReferenceExpr(); if (ref instanceof RexCorrelVariable) { final RexCorrelVariable var = (RexCorrelVariable) ref; if (mapFieldAccessToCorVar.containsKey(fieldAccess)) { // for cases where different Rel nodes are referring to // same correlation var (e.g. in case of NOT IN) // avoid generating another correlation var // and record the 'rel' is using the same correlation mapRefRelToCorRef.put(rel, mapFieldAccessToCorVar.get(fieldAccess)); } else { final CorRef correlation = new CorRef(var.id, fieldAccess.getField().getIndex(), corrIdGenerator++); mapFieldAccessToCorVar.put(fieldAccess, correlation); mapRefRelToCorRef.put(rel, correlation); } } return super.visitFieldAccess(fieldAccess); } @Override public Void visitSubQuery(RexSubQuery subQuery) { subQuery.rel.accept(CorelMapBuilder.this); return super.visitSubQuery(subQuery); } }; }
Example 10
Source File: PigToSqlAggregateRule.java From calcite with Apache License 2.0 | 5 votes |
private int getGroupRefIndex(RexNode rex) { if (rex instanceof RexFieldAccess) { final RexFieldAccess fieldAccess = (RexFieldAccess) rex; if (fieldAccess.getReferenceExpr() instanceof RexInputRef) { final RexInputRef inputRef = (RexInputRef) fieldAccess.getReferenceExpr(); if (inputRef.getIndex() == 0) { // Project from 'group' column return fieldAccess.getField().getIndex(); } } } return -1; }
Example 11
Source File: RelDecorrelator.java From calcite with Apache License 2.0 | 5 votes |
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) { return new RexVisitorImpl<Void>(true) { @Override public Void visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode ref = fieldAccess.getReferenceExpr(); if (ref instanceof RexCorrelVariable) { final RexCorrelVariable var = (RexCorrelVariable) ref; if (mapFieldAccessToCorVar.containsKey(fieldAccess)) { // for cases where different Rel nodes are referring to // same correlation var (e.g. in case of NOT IN) // avoid generating another correlation var // and record the 'rel' is using the same correlation mapRefRelToCorRef.put(rel, mapFieldAccessToCorVar.get(fieldAccess)); } else { final CorRef correlation = new CorRef(var.id, fieldAccess.getField().getIndex(), corrIdGenerator++); mapFieldAccessToCorVar.put(fieldAccess, correlation); mapRefRelToCorRef.put(rel, correlation); } } return super.visitFieldAccess(fieldAccess); } @Override public Void visitSubQuery(RexSubQuery subQuery) { subQuery.rel.accept(CorelMapBuilder.this); return super.visitSubQuery(subQuery); } }; }
Example 12
Source File: RelOptUtil.java From calcite with Apache License 2.0 | 5 votes |
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { if (fieldAccess.getReferenceExpr() instanceof RexCorrelVariable) { final RexCorrelVariable v = (RexCorrelVariable) fieldAccess.getReferenceExpr(); variableFields.put(v.id, fieldAccess.getField().getIndex()); } return super.visitFieldAccess(fieldAccess); }
Example 13
Source File: IndexableExprMarker.java From Bats with Apache License 2.0 | 4 votes |
@Override public Boolean visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode expr = fieldAccess.getReferenceExpr(); return expr.accept(this); }
Example 14
Source File: SubQueryDecorrelator.java From flink with Apache License 2.0 | 4 votes |
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) { return new RexVisitorImpl<Void>(true) { @Override public Void visitSubQuery(RexSubQuery subQuery) { hasAggregateNode = false; // reset to default value hasOverNode = false; // reset to default value subQuery.rel.accept(CorelMapBuilder.this); return super.visitSubQuery(subQuery); } @Override public Void visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode ref = fieldAccess.getReferenceExpr(); if (ref instanceof RexCorrelVariable) { final RexCorrelVariable var = (RexCorrelVariable) ref; // check the scope of correlation id // we do not support nested correlation variables in SubQuery, such as: // select * from t1 where exists (select * from t2 where t1.a = t2.c and // t2.d in (select t3.d from t3 where t1.b = t3.e) if (!hasUnsupportedCorCondition) { hasUnsupportedCorCondition = !mapSubQueryNodeToCorSet.containsKey(rel); } if (!hasNestedCorScope && mapSubQueryNodeToCorSet.containsKey(rel)) { hasNestedCorScope = !mapSubQueryNodeToCorSet.get(rel).contains(var.id); } if (mapFieldAccessToCorVar.containsKey(fieldAccess)) { // for cases where different Rel nodes are referring to // same correlation var (e.g. in case of NOT IN) // avoid generating another correlation var // and record the 'rel' is using the same correlation mapRefRelToCorRef.put(rel, mapFieldAccessToCorVar.get(fieldAccess)); } else { final CorRef correlation = new CorRef( var.id, fieldAccess.getField().getIndex(), corrIdGenerator++); mapFieldAccessToCorVar.put(fieldAccess, correlation); mapRefRelToCorRef.put(rel, correlation); } } return super.visitFieldAccess(fieldAccess); } }; }
Example 15
Source File: SubQueryDecorrelator.java From flink with Apache License 2.0 | 4 votes |
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) { return new RexVisitorImpl<Void>(true) { @Override public Void visitSubQuery(RexSubQuery subQuery) { hasAggregateNode = false; // reset to default value hasOverNode = false; // reset to default value subQuery.rel.accept(CorelMapBuilder.this); return super.visitSubQuery(subQuery); } @Override public Void visitFieldAccess(RexFieldAccess fieldAccess) { final RexNode ref = fieldAccess.getReferenceExpr(); if (ref instanceof RexCorrelVariable) { final RexCorrelVariable var = (RexCorrelVariable) ref; // check the scope of correlation id // we do not support nested correlation variables in SubQuery, such as: // select * from t1 where exists (select * from t2 where t1.a = t2.c and // t2.d in (select t3.d from t3 where t1.b = t3.e) if (!hasUnsupportedCorCondition) { hasUnsupportedCorCondition = !mapSubQueryNodeToCorSet.containsKey(rel); } if (!hasNestedCorScope && mapSubQueryNodeToCorSet.containsKey(rel)) { hasNestedCorScope = !mapSubQueryNodeToCorSet.get(rel).contains(var.id); } if (mapFieldAccessToCorVar.containsKey(fieldAccess)) { // for cases where different Rel nodes are referring to // same correlation var (e.g. in case of NOT IN) // avoid generating another correlation var // and record the 'rel' is using the same correlation mapRefRelToCorRef.put(rel, mapFieldAccessToCorVar.get(fieldAccess)); } else { final CorRef correlation = new CorRef( var.id, fieldAccess.getField().getIndex(), corrIdGenerator++); mapFieldAccessToCorVar.put(fieldAccess, correlation); mapRefRelToCorRef.put(rel, correlation); } } return super.visitFieldAccess(fieldAccess); } }; }
Example 16
Source File: CorrelationReferenceFinder.java From calcite with Apache License 2.0 | 4 votes |
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { if (fieldAccess.getReferenceExpr() instanceof RexCorrelVariable) { return finder.handle(fieldAccess); } return super.visitFieldAccess(fieldAccess); }