Search in sources :

Example 1 with SlidingWindow

use of com.hazelcast.jet.sql.impl.opt.SlidingWindow in project hazelcast by hazelcast.

the class SlidingWindowFilterTransposeRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    final Filter filter = call.rel(0);
    final SlidingWindow sw = call.rel(1);
    RexVisitorImpl<Void> visitor = new RexVisitorImpl<Void>(true) {

        @Override
        public Void visitInputRef(RexInputRef ref) {
            int index = ref.getIndex();
            if (index == sw.windowStartIndex() || index == sw.windowEndIndex()) {
                throw QueryException.error("Can't apply filter criteria to window bounds");
            }
            return super.visitInputRef(ref);
        }
    };
    filter.getCondition().accept(visitor);
    final Filter newFilter = filter.copy(filter.getTraitSet(), sw.getInput(), filter.getCondition());
    final SlidingWindow topSW = (SlidingWindow) sw.copy(sw.getTraitSet(), singletonList(newFilter));
    call.transformTo(topSW);
}
Also used : SlidingWindow(com.hazelcast.jet.sql.impl.opt.SlidingWindow) Filter(org.apache.calcite.rel.core.Filter) RexInputRef(org.apache.calcite.rex.RexInputRef) RexVisitorImpl(org.apache.calcite.rex.RexVisitorImpl)

Example 2 with SlidingWindow

use of com.hazelcast.jet.sql.impl.opt.SlidingWindow in project hazelcast by hazelcast.

the class SlidingWindowJoinTransposeRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    // TODO [sasha]: finish in follow-up PR
    final Join join = call.rel(0);
    final SlidingWindow sw = call.rel(1);
    boolean windowIsLeftInput = ((RelSubset) join.getLeft()).getBest() instanceof SlidingWindow;
    Join newJoin;
    if (windowIsLeftInput) {
        newJoin = join.copy(join.getTraitSet(), join.getCondition(), sw.getInput(), join.getRight(), join.getJoinType(), join.isSemiJoinDone());
    } else {
        newJoin = join.copy(join.getTraitSet(), join.getCondition(), join.getLeft(), sw.getInput(), join.getJoinType(), join.isSemiJoinDone());
    }
    final SlidingWindow topSW = (SlidingWindow) sw.copy(sw.getTraitSet(), singletonList(newJoin));
    call.transformTo(topSW);
}
Also used : SlidingWindow(com.hazelcast.jet.sql.impl.opt.SlidingWindow) Join(org.apache.calcite.rel.core.Join)

Aggregations

SlidingWindow (com.hazelcast.jet.sql.impl.opt.SlidingWindow)2 Filter (org.apache.calcite.rel.core.Filter)1 Join (org.apache.calcite.rel.core.Join)1 RexInputRef (org.apache.calcite.rex.RexInputRef)1 RexVisitorImpl (org.apache.calcite.rex.RexVisitorImpl)1