org.apache.calcite.rex.RexInputRef.of()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.calcite.rex.RexInputRef.of方法的一些代码示例,展示了RexInputRef.of的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RexInputRef.of方法的具体详情如下:
包路径:org.apache.calcite.rex.RexInputRef
类名称:RexInputRef
方法名:of

RexInputRef.of介绍

[英]Creates a reference to a given field in a list of fields.
[中]创建对字段列表中给定字段的引用。

代码示例

代码示例来源:origin: apache/drill

public RexNode get(int index) {
  final int pos = posList.get(index);
  return RexInputRef.of(pos, rowType);
 }
});

代码示例来源:origin: apache/hive

@Override public RexNode visitInputRef(RexInputRef inputRef) {
  return RexInputRef.of(inputRef.getIndex(), input.getRowType());
 }
}

代码示例来源:origin: apache/incubator-druid

/**
 * Translate a field access, possibly through a projection, to an underlying Druid dataSource.
 *
 * @param rowSignature row signature of underlying Druid dataSource
 * @param project      projection, or null
 * @param fieldNumber  number of the field to access
 *
 * @return row expression
 */
public static RexNode fromFieldAccess(
  final RowSignature rowSignature,
  final Project project,
  final int fieldNumber
)
{
 if (project == null) {
  // I don't think the factory impl matters here.
  return RexInputRef.of(fieldNumber, rowSignature.getRelDataType(new JavaTypeFactoryImpl()));
 } else {
  return project.getChildExps().get(fieldNumber);
 }
}

代码示例来源:origin: apache/incubator-druid

listBuilder.add(RexInputRef.of(key, leftPartialQuery.getRowType()));

代码示例来源:origin: apache/hive

belowProjectExprs.add(project.getChildExps().get(i));
belowProjectColumnNames.add(project.getRowType().getFieldNames().get(i));
topProjectExprs.add(RexInputRef.of(i, project.getRowType()));

代码示例来源:origin: apache/drill

protected MutableRel invert(MutableRel model, MutableRel input,
   MutableProject project) {
  LOGGER.trace("SubstitutionVisitor: invert:\nmodel: {}\ninput: {}\nproject: {}\n",
    model, input, project);
  if (project.getProjects().size() < model.getRowType().getFieldCount()) {
   throw MatchFailed.INSTANCE;
  }
  final List<RexNode> exprList = new ArrayList<>();
  final RexBuilder rexBuilder = model.cluster.getRexBuilder();
  for (RelDataTypeField field : model.getRowType().getFieldList()) {
   exprList.add(rexBuilder.makeZeroLiteral(field.getType()));
  }
  for (Ord<RexNode> expr : Ord.zip(project.getProjects())) {
   if (expr.e instanceof RexInputRef) {
    final int target = ((RexInputRef) expr.e).getIndex();
    exprList.set(target,
      rexBuilder.ensureType(expr.e.getType(),
        RexInputRef.of(expr.i, input.rowType),
        false));
   } else {
    throw MatchFailed.INSTANCE;
   }
  }
  return MutableProject.of(model.rowType, input, exprList);
 }
}

代码示例来源:origin: apache/drill

belowProjectExprs.add(project.getChildExps().get(i));
belowProjectColumnNames.add(project.getRowType().getFieldNames().get(i));
topProjectExprs.add(RexInputRef.of(i, project.getRowType()));

代码示例来源:origin: apache/hive

conditions.add(
  rexBuilder.makeCall(callOp,
    RexInputRef.of(newLeftPos, newLeftOutput),
    new RexInputRef(newLeftFieldCount + newRightPos,
      newRightOutput.get(newRightPos).getType())));
    new RexInputRef(newLeftFieldCount + newRightPos,
      newRightOutput.get(newRightPos).getType()),
    RexInputRef.of(newLeftPos, newLeftOutput)));

代码示例来源:origin: apache/drill

conditions.add(
    rexBuilder.makeCall(SqlStdOperatorTable.EQUALS,
        RexInputRef.of(newLeftPos, newLeftOutput),
        new RexInputRef(newLeftFieldCount + newRightPos,
            newRightOutput.get(newRightPos).getType())));

代码示例来源:origin: org.apache.calcite/calcite-core

public RexNode get(int index) {
  final int pos = posList.get(index);
  return RexInputRef.of(pos, rowType);
 }
});

代码示例来源:origin: Qihoo360/Quicksql

/**
 * Creates a reference to a given field in a row type.
 */
public static RexInputRef of(int index, RelDataType rowType) {
 return of(index, rowType.getFieldList());
}

代码示例来源:origin: Qihoo360/Quicksql

public RexNode rexFilterArgument() {
 return agg.call.filterArg < 0
   ? null
   : RexInputRef.of(agg.call.filterArg,
     inputPhysType.getRowType());
}

代码示例来源:origin: dremio/dremio-oss

@Override
 public RexNode get(int index) {
  if (index < originalFieldSize) {
   return RexInputRef.of(index, inputRowType.getFieldList());
  } else {
   return colRefStarExprs.get(index - originalFieldSize);
  }
 }
};

代码示例来源:origin: com.alibaba.blink/flink-table

@Override
  public RexNode visitInputRef(RexInputRef inputRef) {
    assert mapOldToNewIndex.containsKey(inputRef.getIndex());
    int newIndex = mapOldToNewIndex.get(inputRef.getIndex());
    final RexInputRef ref = RexInputRef.of(newIndex, rowType);
    if (ref.getIndex() == inputRef.getIndex() && ref.getType() == inputRef.getType()) {
      return inputRef; // re-use old object, to prevent needless expr cloning
    } else {
      return ref;
    }
  }
});

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testExpressionLineageInnerJoinRight() {
 // ename is column 0 in catalog.sales.bonus
 final RelNode rel = convertSql("select bonus.ename from emp join bonus using (ename)");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 assertThat(r.size(), is(1));
 final RexTableInputRef result = (RexTableInputRef) r.iterator().next();
 assertTrue(result.getQualifiedName().equals(ImmutableList.of("CATALOG", "SALES", "BONUS")));
 assertThat(result.getIndex(), is(0));
}

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testExpressionLineageInnerJoinLeft() {
 // ename is column 1 in catalog.sales.emp
 final RelNode rel = convertSql("select ename from emp,dept");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 assertThat(r.size(), is(1));
 final RexTableInputRef result = (RexTableInputRef) r.iterator().next();
 assertTrue(result.getQualifiedName().equals(EMP_QNAME));
 assertThat(result.getIndex(), is(1));
}

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testExpressionLineageStar() {
 // All columns in output
 final RelNode tableRel = convertSql("select * from emp");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(4, tableRel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(tableRel, ref);
 final String inputRef = RexInputRef.of(4, tableRel.getRowType().getFieldList()).toString();
 assertThat(r.size(), is(1));
 final String resultString = r.iterator().next().toString();
 assertThat(resultString, startsWith(EMP_QNAME.toString()));
 assertThat(resultString, endsWith(inputRef));
}

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testExpressionLineageAggregateAggColumn() {
 // lineage cannot be determined
 final RelNode rel = convertSql("select deptno, count(*) from emp where deptno > 10 "
   + "group by deptno having count(*) = 0");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(1, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 assertNull(r);
}

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testExpressionLineageValues() {
 // lineage cannot be determined
 final RelNode rel = convertSql("select * from (values (1), (2)) as t(c)");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 assertNull(r);
}

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testExpressionLineageOuterJoin() {
 // lineage cannot be determined
 final RelNode rel = convertSql("select name as dname from emp left outer join dept"
   + " on emp.deptno = dept.deptno");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 assertNull(r);
}

相关文章