Java Code Examples for org.apache.calcite.util.mapping.Mappings#isIdentity()
The following examples show how to use
org.apache.calcite.util.mapping.Mappings#isIdentity() .
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: MutableRels.java From Bats with Apache License 2.0 | 6 votes |
/** Equivalent to * {@link RelOptUtil#createProject(org.apache.calcite.rel.RelNode, java.util.List)} * for {@link MutableRel}. */ public static MutableRel createProject(final MutableRel child, final List<Integer> posList) { final RelDataType rowType = child.rowType; if (Mappings.isIdentity(posList, rowType.getFieldCount())) { return child; } return MutableProject.of( RelOptUtil.permute(child.cluster.getTypeFactory(), rowType, Mappings.bijection(posList)), child, new AbstractList<RexNode>() { public int size() { return posList.size(); } public RexNode get(int index) { final int pos = posList.get(index); return RexInputRef.of(pos, rowType); } }); }
Example 2
Source File: RelRoot.java From Bats with Apache License 2.0 | 5 votes |
public boolean isRefTrivial() { if (SqlKind.DML.contains(kind)) { // DML statements return a single count column. // The validated type is of the SELECT. // Still, we regard the mapping as trivial. return true; } final RelDataType inputRowType = rel.getRowType(); return Mappings.isIdentity(Pair.left(fields), inputRowType.getFieldCount()); }
Example 3
Source File: MutableRels.java From calcite with Apache License 2.0 | 5 votes |
/** Equivalent to * {@link RelOptUtil#createProject(org.apache.calcite.rel.RelNode, java.util.List)} * for {@link MutableRel}. */ public static MutableRel createProject(final MutableRel child, final List<Integer> posList) { final RelDataType rowType = child.rowType; if (Mappings.isIdentity(posList, rowType.getFieldCount())) { return child; } final Mapping mapping = Mappings.create( MappingType.INVERSE_SURJECTION, rowType.getFieldCount(), posList.size()); for (int i = 0; i < posList.size(); i++) { mapping.set(posList.get(i), i); } return MutableProject.of( RelOptUtil.permute(child.cluster.getTypeFactory(), rowType, mapping), child, new AbstractList<RexNode>() { public int size() { return posList.size(); } public RexNode get(int index) { final int pos = posList.get(index); return RexInputRef.of(pos, rowType); } }); }
Example 4
Source File: RelRoot.java From calcite with Apache License 2.0 | 5 votes |
public boolean isRefTrivial() { if (SqlKind.DML.contains(kind)) { // DML statements return a single count column. // The validated type is of the SELECT. // Still, we regard the mapping as trivial. return true; } final RelDataType inputRowType = rel.getRowType(); return Mappings.isIdentity(Pair.left(fields), inputRowType.getFieldCount()); }