use of org.apache.calcite.rel.metadata.RelMetadataQuery in project calcite by apache.
the class RelMetadataTest method testExpressionLineageOuterJoin.
@Test
void testExpressionLineageOuterJoin() {
// lineage cannot be determined
final RelNode rel = sql("select name as dname from emp left outer join dept" + " on emp.deptno = dept.deptno").toRel();
final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
assertNull(r);
}
use of org.apache.calcite.rel.metadata.RelMetadataQuery in project calcite by apache.
the class RelMetadataFixture method assertThatNodeTypeCount.
/**
* Checks the number of each sub-class of {@link RelNode},
* calling {@link RelMetadataQuery#getNodeTypes(RelNode)}.
*/
public RelMetadataFixture assertThatNodeTypeCount(Matcher<Map<Class<? extends RelNode>, Integer>> matcher) {
final RelNode rel = toRel();
final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
final Multimap<Class<? extends RelNode>, RelNode> result = mq.getNodeTypes(rel);
assertThat(result, notNullValue());
final Map<Class<? extends RelNode>, Integer> resultCount = new HashMap<>();
for (Map.Entry<Class<? extends RelNode>, Collection<RelNode>> e : result.asMap().entrySet()) {
resultCount.put(e.getKey(), e.getValue().size());
}
assertThat(resultCount, matcher);
return this;
}
use of org.apache.calcite.rel.metadata.RelMetadataQuery in project calcite by apache.
the class RelMetadataFixture method assertThatAreColumnsUnique.
/**
* Checks {@link RelMetadataQuery#areColumnsUnique(RelNode, ImmutableBitSet)},
* deriving parameters via functions.
*/
public RelMetadataFixture assertThatAreColumnsUnique(Function<RelNode, ImmutableBitSet> columnsFn, UnaryOperator<RelNode> relFn, Matcher<Boolean> matcher) {
RelNode rel = toRel();
final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
final ImmutableBitSet columns = columnsFn.apply(rel);
final RelNode rel2 = relFn.apply(rel);
final Boolean areColumnsUnique = mq.areColumnsUnique(rel2, columns);
assertThat(areColumnsUnique, matcher);
return this;
}
use of org.apache.calcite.rel.metadata.RelMetadataQuery in project calcite by apache.
the class RelMetadataFixture method assertThatAreRowsUnique.
/**
* Checks {@link RelMetadataQuery#areRowsUnique(RelNode)}.
*/
@SuppressWarnings({ "UnusedReturnValue" })
public RelMetadataFixture assertThatAreRowsUnique(Matcher<Boolean> matcher) {
RelNode rel = toRel();
final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
final Boolean areRowsUnique = mq.areRowsUnique(rel);
assertThat(areRowsUnique, matcher);
return this;
}
use of org.apache.calcite.rel.metadata.RelMetadataQuery in project calcite by apache.
the class RelMetadataFixture method checkColumnOrigin.
private RelMetadataFixture checkColumnOrigin(Consumer<Set<RelColumnOrigin>> action) {
RelNode rel = toRel();
final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
final Set<RelColumnOrigin> columnOrigins = mq.getColumnOrigins(rel, 0);
action.accept(columnOrigins);
return this;
}
Aggregations