Java Code Examples for org.apache.calcite.rel.logical.LogicalTableFunctionScan#getColumnMappings()
The following examples show how to use
org.apache.calcite.rel.logical.LogicalTableFunctionScan#getColumnMappings() .
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: CopyWithCluster.java From dremio-oss with Apache License 2.0 | 5 votes |
private RelNode copyOf(LogicalTableFunctionScan rel) { return new LogicalTableFunctionScan( cluster, copyOf(rel.getTraitSet()), visitAll(rel.getInputs()), copyOf(rel.getCall()), rel.getElementType(), copyOf(rel.getRowType()), rel.getColumnMappings() ); }
Example 2
Source File: EnumerableTableFunctionScanRule.java From calcite with Apache License 2.0 | 5 votes |
@Override public RelNode convert(RelNode rel) { final RelTraitSet traitSet = rel.getTraitSet().replace(EnumerableConvention.INSTANCE); LogicalTableFunctionScan tbl = (LogicalTableFunctionScan) rel; return new EnumerableTableFunctionScan(rel.getCluster(), traitSet, convertList(tbl.getInputs(), traitSet.getTrait(0)), tbl.getElementType(), tbl.getRowType(), tbl.getCall(), tbl.getColumnMappings()); }
Example 3
Source File: FilterTableFunctionTransposeRule.java From Bats with Apache License 2.0 | 4 votes |
public void onMatch(RelOptRuleCall call) { LogicalFilter filter = call.rel(0); LogicalTableFunctionScan funcRel = call.rel(1); Set<RelColumnMapping> columnMappings = funcRel.getColumnMappings(); if (columnMappings == null || columnMappings.isEmpty()) { // No column mapping information, so no push-down // possible. return; } List<RelNode> funcInputs = funcRel.getInputs(); if (funcInputs.size() != 1) { // TODO: support more than one relational input; requires // offsetting field indices, similar to join return; } // TODO: support mappings other than 1-to-1 if (funcRel.getRowType().getFieldCount() != funcInputs.get(0).getRowType().getFieldCount()) { return; } for (RelColumnMapping mapping : columnMappings) { if (mapping.iInputColumn != mapping.iOutputColumn) { return; } if (mapping.derived) { return; } } final List<RelNode> newFuncInputs = new ArrayList<>(); final RelOptCluster cluster = funcRel.getCluster(); final RexNode condition = filter.getCondition(); // create filters on top of each func input, modifying the filter // condition to reference the child instead RexBuilder rexBuilder = filter.getCluster().getRexBuilder(); List<RelDataTypeField> origFields = funcRel.getRowType().getFieldList(); // TODO: these need to be non-zero once we // support arbitrary mappings int[] adjustments = new int[origFields.size()]; for (RelNode funcInput : funcInputs) { RexNode newCondition = condition.accept( new RelOptUtil.RexInputConverter( rexBuilder, origFields, funcInput.getRowType().getFieldList(), adjustments)); newFuncInputs.add( LogicalFilter.create(funcInput, newCondition)); } // create a new UDX whose children are the filters created above LogicalTableFunctionScan newFuncRel = LogicalTableFunctionScan.create(cluster, newFuncInputs, funcRel.getCall(), funcRel.getElementType(), funcRel.getRowType(), columnMappings); call.transformTo(newFuncRel); }
Example 4
Source File: FilterTableFunctionTransposeRule.java From calcite with Apache License 2.0 | 4 votes |
public void onMatch(RelOptRuleCall call) { LogicalFilter filter = call.rel(0); LogicalTableFunctionScan funcRel = call.rel(1); Set<RelColumnMapping> columnMappings = funcRel.getColumnMappings(); if (columnMappings == null || columnMappings.isEmpty()) { // No column mapping information, so no push-down // possible. return; } List<RelNode> funcInputs = funcRel.getInputs(); if (funcInputs.size() != 1) { // TODO: support more than one relational input; requires // offsetting field indices, similar to join return; } // TODO: support mappings other than 1-to-1 if (funcRel.getRowType().getFieldCount() != funcInputs.get(0).getRowType().getFieldCount()) { return; } for (RelColumnMapping mapping : columnMappings) { if (mapping.iInputColumn != mapping.iOutputColumn) { return; } if (mapping.derived) { return; } } final List<RelNode> newFuncInputs = new ArrayList<>(); final RelOptCluster cluster = funcRel.getCluster(); final RexNode condition = filter.getCondition(); // create filters on top of each func input, modifying the filter // condition to reference the child instead RexBuilder rexBuilder = filter.getCluster().getRexBuilder(); List<RelDataTypeField> origFields = funcRel.getRowType().getFieldList(); // TODO: these need to be non-zero once we // support arbitrary mappings int[] adjustments = new int[origFields.size()]; for (RelNode funcInput : funcInputs) { RexNode newCondition = condition.accept( new RelOptUtil.RexInputConverter( rexBuilder, origFields, funcInput.getRowType().getFieldList(), adjustments)); newFuncInputs.add( LogicalFilter.create(funcInput, newCondition)); } // create a new UDX whose children are the filters created above LogicalTableFunctionScan newFuncRel = LogicalTableFunctionScan.create(cluster, newFuncInputs, funcRel.getCall(), funcRel.getElementType(), funcRel.getRowType(), columnMappings); call.transformTo(newFuncRel); }