17 package com.mapd.calcite.parser;
19 import org.apache.calcite.plan.RelOptRule;
20 import org.apache.calcite.plan.RelOptRuleCall;
21 import org.apache.calcite.plan.hep.HepRelVertex;
22 import org.apache.calcite.rel.RelNode;
23 import org.apache.calcite.rel.core.Project;
24 import org.apache.calcite.rel.core.RelFactories;
25 import org.apache.calcite.rel.rules.ProjectRemoveRule;
26 import org.apache.calcite.tools.RelBuilderFactory;
33 static RelNode
unwrap(RelNode node) {
34 if (node instanceof HepRelVertex) {
35 return unwrap(((HepRelVertex) node).getCurrentRel());
52 super(operandJ(Project.class, null, ProjectRemoveRule::isTrivial, any()),
55 innerRule =
new ProjectRemoveRule(relBuilderFactory);
59 public void onMatch(RelOptRuleCall call) {
60 boolean hasParents = null != call.getParents() && !call.getParents().isEmpty();
61 Project project = (Project) call.rel(0);
62 boolean inputIsProject =
unwrap(project.getInput()) instanceof Project;
63 if (hasParents || inputIsProject) {
64 innerRule.onMatch(call);
ProjectRemoveRule innerRule
static RelNode unwrap(RelNode node)
void onMatch(RelOptRuleCall call)
ProjectProjectRemoveRule(RelBuilderFactory relBuilderFactory)
static final ProjectProjectRemoveRule INSTANCE