Java Code Examples for org.apache.calcite.rex.RexBuilder#makeFieldAccess()
The following examples show how to use
org.apache.calcite.rex.RexBuilder#makeFieldAccess() .
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: AdjustOperatorsSchemaVisitor.java From Bats with Apache License 2.0 | 6 votes |
@Override public Prel visitUnnest(UnnestPrel prel, Void value) throws RuntimeException { Preconditions.checkArgument(registeredPrel != null && registeredPrel instanceof LateralJoinPrel); Preconditions.checkArgument(prel.getRowType().getFieldCount() == 1); RexBuilder builder = prel.getCluster().getRexBuilder(); LateralJoinPrel lateralJoinPrel = (LateralJoinPrel) getRegisteredPrel(); int correlationIndex = lateralJoinPrel.getRequiredColumns().nextSetBit(0); String correlationColumnName = lateralJoinPrel.getLeft().getRowType().getFieldNames().get(correlationIndex); RexNode corrRef = builder.makeCorrel(lateralJoinPrel.getLeft().getRowType(), lateralJoinPrel.getCorrelationId()); RexNode fieldAccess = builder.makeFieldAccess(corrRef, correlationColumnName, false); List<String> fieldNames = new ArrayList<>(); List<RelDataType> fieldTypes = new ArrayList<>(); for (RelDataTypeField field : prel.getRowType().getFieldList()) { fieldNames.add(correlationColumnName); fieldTypes.add(field.getType()); } UnnestPrel unnestPrel = new UnnestPrel(prel.getCluster(), prel.getTraitSet(), prel.getCluster().getTypeFactory().createStructType(fieldTypes, fieldNames), fieldAccess); return unnestPrel; }
Example 2
Source File: RelBuilder.java From Bats with Apache License 2.0 | 5 votes |
@Override public RexNode visitInputRef(RexInputRef inputRef) { final RelDataType leftRowType = left.getRowType(); final RexBuilder rexBuilder = getRexBuilder(); final int leftCount = leftRowType.getFieldCount(); if (inputRef.getIndex() < leftCount) { final RexNode v = rexBuilder.makeCorrel(leftRowType, id); return rexBuilder.makeFieldAccess(v, inputRef.getIndex()); } else { return rexBuilder.makeInputRef(right, inputRef.getIndex() - leftCount); } }
Example 3
Source File: RelBuilder.java From calcite with Apache License 2.0 | 5 votes |
public RexNode visitInputRef(RexInputRef inputRef) { final RelDataType leftRowType = left.getRowType(); final RexBuilder rexBuilder = getRexBuilder(); final int leftCount = leftRowType.getFieldCount(); if (inputRef.getIndex() < leftCount) { final RexNode v = rexBuilder.makeCorrel(leftRowType, id); return rexBuilder.makeFieldAccess(v, inputRef.getIndex()); } else { return rexBuilder.makeInputRef(right, inputRef.getIndex() - leftCount); } }
Example 4
Source File: RelBuilder.java From Bats with Apache License 2.0 | 4 votes |
/** Creates an access to a field by name. */ public RexNode dot(RexNode node, String fieldName) { final RexBuilder builder = cluster.getRexBuilder(); return builder.makeFieldAccess(node, fieldName, true); }
Example 5
Source File: RelBuilder.java From Bats with Apache License 2.0 | 4 votes |
/** Creates an access to a field by ordinal. */ public RexNode dot(RexNode node, int fieldOrdinal) { final RexBuilder builder = cluster.getRexBuilder(); return builder.makeFieldAccess(node, fieldOrdinal); }
Example 6
Source File: RelBuilder.java From calcite with Apache License 2.0 | 4 votes |
/** Creates an access to a field by name. */ public RexNode dot(RexNode node, String fieldName) { final RexBuilder builder = cluster.getRexBuilder(); return builder.makeFieldAccess(node, fieldName, true); }
Example 7
Source File: RelBuilder.java From calcite with Apache License 2.0 | 4 votes |
/** Creates an access to a field by ordinal. */ public RexNode dot(RexNode node, int fieldOrdinal) { final RexBuilder builder = cluster.getRexBuilder(); return builder.makeFieldAccess(node, fieldOrdinal); }