Java Code Examples for org.apache.calcite.rel.logical.LogicalWindow#getInput()
The following examples show how to use
org.apache.calcite.rel.logical.LogicalWindow#getInput() .
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: EnumerableWindowRule.java From calcite with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final LogicalWindow winAgg = (LogicalWindow) rel; final RelTraitSet traitSet = winAgg.getTraitSet().replace(EnumerableConvention.INSTANCE); final RelNode child = winAgg.getInput(); final RelNode convertedChild = convert(child, child.getTraitSet().replace(EnumerableConvention.INSTANCE)); return new EnumerableWindow(rel.getCluster(), traitSet, convertedChild, winAgg.getConstants(), winAgg.getRowType(), winAgg.groups); }
Example 2
Source File: Bindables.java From calcite with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final LogicalWindow winAgg = (LogicalWindow) rel; final RelTraitSet traitSet = winAgg.getTraitSet().replace(BindableConvention.INSTANCE); final RelNode input = winAgg.getInput(); final RelNode convertedInput = convert(input, input.getTraitSet().replace(BindableConvention.INSTANCE)); return new BindableWindow(rel.getCluster(), traitSet, convertedInput, winAgg.getConstants(), winAgg.getRowType(), winAgg.groups); }
Example 3
Source File: RelMdColumnOrigins.java From dremio-oss with Apache License 2.0 | 4 votes |
@SuppressWarnings("unused") // Called through reflection public Set<RelColumnOrigin> getColumnOrigins(LogicalWindow window, RelMetadataQuery mq, int iOutputColumn) { final RelNode inputRel = window.getInput(); final int numFieldsInInput = inputRel.getRowType().getFieldCount(); if (iOutputColumn < numFieldsInInput) { return mq.getColumnOrigins(inputRel, iOutputColumn); } if (iOutputColumn >= window.getRowType().getFieldCount()) { return Collections.emptySet(); } int startGroupIdx = iOutputColumn - numFieldsInInput; int curentIdx = 0; Group finalGroup = null; for (Group group : window.groups) { curentIdx += group.aggCalls.size(); if (curentIdx > startGroupIdx) { // this is the group finalGroup = group; break; } } Preconditions.checkNotNull(finalGroup); // calculating index of the aggCall within a group // currentIdx = through idx within groups/aggCalls (max currentIdx = sum(groups size * aggCals_per_group) ) // since currentIdx at this moment points to the end of the group substracting aggCals_per_group // to get to the beginning of the group and have startGroupIdx substract the diff final int aggCalIdx = startGroupIdx - (curentIdx - finalGroup.aggCalls.size()); Preconditions.checkElementIndex(aggCalIdx, finalGroup.aggCalls.size()); final Set<RelColumnOrigin> set = new HashSet<>(); // Add aggregation column references final RexWinAggCall aggCall = finalGroup.aggCalls.get(aggCalIdx); for (RexNode operand : aggCall.operands) { if (operand instanceof RexInputRef) { final RexInputRef opInputRef = (RexInputRef) operand; if (opInputRef.getIndex() < numFieldsInInput) { Set<RelColumnOrigin> inputSet = mq.getColumnOrigins(inputRel, opInputRef.getIndex()); inputSet = createDerivedColumnOrigins(inputSet); if (inputSet != null) { set.addAll(inputSet); } } } } return set; }