Java Code Examples for org.apache.calcite.rex.RexFieldAccess#getType()

The following examples show how to use org.apache.calcite.rex.RexFieldAccess#getType() . 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 flink with Apache License 2.0 6 votes vote down vote up
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) {
  if (cm.mapFieldAccessToCorRef.containsKey(fieldAccess)) {
    // if it is a corVar, change it to be input ref.
    CorRef corVar = cm.mapFieldAccessToCorRef.get(fieldAccess);

    // corVar offset should point to the leftInput of currentRel,
    // which is the Correlate.
    RexNode newRexNode =
        new RexInputRef(corVar.field, fieldAccess.getType());

    if (projectPulledAboveLeftCorrelator
        && (nullIndicator != null)) {
      // need to enforce nullability by applying an additional
      // cast operator over the transformed expression.
      newRexNode =
          createCaseExpression(
              nullIndicator,
              rexBuilder.constantNull(),
              newRexNode);
    }
    return newRexNode;
  }
  return fieldAccess;
}
 
Example 2
Source File: RelDecorrelator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) {
  if (cm.mapFieldAccessToCorRef.containsKey(fieldAccess)) {
    // if it is a corVar, change it to be input ref.
    CorRef corVar = cm.mapFieldAccessToCorRef.get(fieldAccess);

    // corVar offset should point to the leftInput of currentRel,
    // which is the Correlate.
    RexNode newRexNode =
        new RexInputRef(corVar.field, fieldAccess.getType());

    if (projectPulledAboveLeftCorrelator
        && (nullIndicator != null)) {
      // need to enforce nullability by applying an additional
      // cast operator over the transformed expression.
      newRexNode =
          createCaseExpression(
              nullIndicator,
              rexBuilder.constantNull(),
              newRexNode);
    }
    return newRexNode;
  }
  return fieldAccess;
}
 
Example 3
Source File: RelDecorrelator.java    From calcite with Apache License 2.0 6 votes vote down vote up
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) {
  if (cm.mapFieldAccessToCorRef.containsKey(fieldAccess)) {
    // if it is a corVar, change it to be input ref.
    CorRef corVar = cm.mapFieldAccessToCorRef.get(fieldAccess);

    // corVar offset should point to the leftInput of currentRel,
    // which is the Correlate.
    RexNode newRexNode =
        new RexInputRef(corVar.field, fieldAccess.getType());

    if (projectPulledAboveLeftCorrelator
        && (nullIndicator != null)) {
      // need to enforce nullability by applying an additional
      // cast operator over the transformed expression.
      newRexNode =
          createCaseExpression(nullIndicator, null, newRexNode);
    }
    return newRexNode;
  }
  return fieldAccess;
}
 
Example 4
Source File: RexToTestCodeShuttle.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public String visitFieldAccess(RexFieldAccess fieldAccess) {
  StringBuilder sb = new StringBuilder();
  sb.append("v");
  RelDataType type = fieldAccess.getType();
  appendSqlType(sb, type);
  if (!type.isNullable()) {
    sb.append("NotNull");
  }
  sb.append("(");
  sb.append(fieldAccess.getField().getIndex() % 10);
  sb.append(")");
  return sb.toString();
}