本文整理了Java中org.apache.calcite.rex.RexInputRef.toString
方法的一些代码示例,展示了RexInputRef.toString
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RexInputRef.toString
方法的具体详情如下:
包路径:org.apache.calcite.rex.RexInputRef
类名称:RexInputRef
方法名:toString
暂无
代码示例来源:origin: apache/kylin
@Override
public TupleExpression visitInputRef(RexInputRef inputRef) {
int index = inputRef.getIndex();
// check it for rewrite count
if (index < inputRowType.size()) {
TblColRef column = inputRowType.getColumnByIndex(index);
TupleExpression tuple = new ColumnTupleExpression(column);
tuple.setDigest(inputRef.toString());
return tuple;
} else {
throw new IllegalStateException("Can't find " + inputRef + " from child columnrowtype");
}
}
代码示例来源:origin: Qihoo360/Quicksql
@Override public RexNode visitInputRef(RexInputRef inputRef) {
Collection<Integer> c = exprsLineage.get(inputRef.toString());
if (c.isEmpty()) {
// Cannot map expression
throw Util.FoundOne.NULL;
}
int pos = c.iterator().next();
if (rewritingMapping != null) {
pos = rewritingMapping.getTargetOpt(pos);
if (pos == -1) {
// Cannot map expression
throw Util.FoundOne.NULL;
}
}
if (node != null) {
return rexBuilder.makeInputRef(node, pos);
}
return rexBuilder.makeInputRef(inputRef.getType(), pos);
}
代码示例来源:origin: org.apache.kylin/kylin-query
@Override
public TupleExpression visitInputRef(RexInputRef inputRef) {
int index = inputRef.getIndex();
// check it for rewrite count
if (index < inputRowType.size()) {
TblColRef column = inputRowType.getColumnByIndex(index);
TupleExpression tuple = new ColumnTupleExpression(column);
tuple.setDigest(inputRef.toString());
return tuple;
} else {
throw new IllegalStateException("Can't find " + inputRef + " from child columnrowtype");
}
}
代码示例来源: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: org.apache.calcite/calcite-core
@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 testExpressionLineageFilter() {
// ename is column 1 in catalog.sales.emp
final RelNode rel = convertSql("select ename from emp where deptno = 10");
final RelNode tableRel = convertSql("select * from emp");
final RelMetadataQuery mq = RelMetadataQuery.instance();
final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
final String inputRef = RexInputRef.of(1, 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 testExpressionLineageSelfJoin() {
// deptno is column 7 in catalog.sales.emp
// sal is column 5 in catalog.sales.emp
final RelNode rel = convertSql("select a.deptno, b.sal from (select * from emp limit 7) as a\n"
+ "inner join (select * from emp limit 2) as b\n"
+ "on a.deptno = b.deptno");
final RelNode tableRel = convertSql("select * from emp");
final RelMetadataQuery mq = RelMetadataQuery.instance();
final RexNode ref1 = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r1 = mq.getExpressionLineage(rel, ref1);
final String inputRef1 = RexInputRef.of(7, tableRel.getRowType().getFieldList()).toString();
assertThat(r1.size(), is(1));
final String resultString1 = r1.iterator().next().toString();
assertThat(resultString1, startsWith(EMP_QNAME.toString()));
assertThat(resultString1, endsWith(inputRef1));
final RexNode ref2 = RexInputRef.of(1, rel.getRowType().getFieldList());
final Set<RexNode> r2 = mq.getExpressionLineage(rel, ref2);
final String inputRef2 = RexInputRef.of(5, tableRel.getRowType().getFieldList()).toString();
assertThat(r2.size(), is(1));
final String resultString2 = r2.iterator().next().toString();
assertThat(resultString2, startsWith(EMP_QNAME.toString()));
assertThat(resultString2, endsWith(inputRef2));
assertThat(((RexTableInputRef) r1.iterator().next()).getIdentifier(),
not(((RexTableInputRef) r2.iterator().next()).getIdentifier()));
}
代码示例来源:origin: org.apache.calcite/calcite-core
@Test public void testExpressionLineageFilter() {
// ename is column 1 in catalog.sales.emp
final RelNode rel = convertSql("select ename from emp where deptno = 10");
final RelNode tableRel = convertSql("select * from emp");
final RelMetadataQuery mq = RelMetadataQuery.instance();
final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
final String inputRef = RexInputRef.of(1, 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 testExpressionLineageAggregateGroupColumn() {
// deptno is column 7 in catalog.sales.emp
final RelNode rel = convertSql("select deptno, count(*) from emp where deptno > 10 "
+ "group by deptno having count(*) = 0");
final RelNode tableRel = convertSql("select * from emp");
final RelMetadataQuery mq = RelMetadataQuery.instance();
final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
final String inputRef = RexInputRef.of(7, 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: org.apache.calcite/calcite-core
@Test public void testExpressionLineageSelfJoin() {
// deptno is column 7 in catalog.sales.emp
// sal is column 5 in catalog.sales.emp
final RelNode rel = convertSql("select a.deptno, b.sal from (select * from emp limit 7) as a\n"
+ "inner join (select * from emp limit 2) as b\n"
+ "on a.deptno = b.deptno");
final RelNode tableRel = convertSql("select * from emp");
final RelMetadataQuery mq = RelMetadataQuery.instance();
final RexNode ref1 = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r1 = mq.getExpressionLineage(rel, ref1);
final String inputRef1 = RexInputRef.of(7, tableRel.getRowType().getFieldList()).toString();
assertThat(r1.size(), is(1));
final String resultString1 = r1.iterator().next().toString();
assertThat(resultString1, startsWith(EMP_QNAME.toString()));
assertThat(resultString1, endsWith(inputRef1));
final RexNode ref2 = RexInputRef.of(1, rel.getRowType().getFieldList());
final Set<RexNode> r2 = mq.getExpressionLineage(rel, ref2);
final String inputRef2 = RexInputRef.of(5, tableRel.getRowType().getFieldList()).toString();
assertThat(r2.size(), is(1));
final String resultString2 = r2.iterator().next().toString();
assertThat(resultString2, startsWith(EMP_QNAME.toString()));
assertThat(resultString2, endsWith(inputRef2));
assertThat(((RexTableInputRef) r1.iterator().next()).getIdentifier(),
not(((RexTableInputRef) r2.iterator().next()).getIdentifier()));
}
代码示例来源:origin: org.apache.calcite/calcite-core
@Test public void testExpressionLineageAggregateGroupColumn() {
// deptno is column 7 in catalog.sales.emp
final RelNode rel = convertSql("select deptno, count(*) from emp where deptno > 10 "
+ "group by deptno having count(*) = 0");
final RelNode tableRel = convertSql("select * from emp");
final RelMetadataQuery mq = RelMetadataQuery.instance();
final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
final String inputRef = RexInputRef.of(7, 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 testExpressionLineageUnion() {
// sal is column 5 in catalog.sales.emp
final RelNode rel = convertSql("select sal from (\n"
+ " select * from emp union all select * from emp) "
+ "where deptno = 10");
final RelNode tableRel = convertSql("select * from emp");
final RelMetadataQuery mq = RelMetadataQuery.instance();
final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
final String inputRef = RexInputRef.of(5, tableRel.getRowType().getFieldList()).toString();
assertThat(r.size(), is(2));
for (RexNode result : r) {
final String resultString = result.toString();
assertThat(resultString, startsWith(EMP_QNAME.toString()));
assertThat(resultString, endsWith(inputRef));
}
Iterator<RexNode> it = r.iterator();
assertThat(((RexTableInputRef) it.next()).getIdentifier(),
not(((RexTableInputRef) it.next()).getIdentifier()));
}
代码示例来源:origin: org.apache.calcite/calcite-core
@Test public void testExpressionLineageUnion() {
// sal is column 5 in catalog.sales.emp
final RelNode rel = convertSql("select sal from (\n"
+ " select * from emp union all select * from emp) "
+ "where deptno = 10");
final RelNode tableRel = convertSql("select * from emp");
final RelMetadataQuery mq = RelMetadataQuery.instance();
final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
final String inputRef = RexInputRef.of(5, tableRel.getRowType().getFieldList()).toString();
assertThat(r.size(), is(2));
for (RexNode result : r) {
final String resultString = result.toString();
assertThat(resultString, startsWith(EMP_QNAME.toString()));
assertThat(resultString, endsWith(inputRef));
}
Iterator<RexNode> it = r.iterator();
assertThat(((RexTableInputRef) it.next()).getIdentifier(),
not(((RexTableInputRef) it.next()).getIdentifier()));
}
代码示例来源:origin: Qihoo360/Quicksql
if (ref == childTargetIdx) {
exprsLineage.put(
new RexInputRef(childTargetIdx, targetNode.getType()).toString(), k);
added = true;
rewritingMapping.set(inputViewExprs.size(), i);
additionalViewExprs.add(
new RexInputRef(targetIdx, targetNode.getType()).toString());
内容来源于网络,如有侵权,请联系作者删除!