本文整理汇总了Java中org.apache.calcite.rel.rules.ProjectMergeRule类的典型用法代码示例。如果您正苦于以下问题:Java ProjectMergeRule类的具体用法?Java ProjectMergeRule怎么用?Java ProjectMergeRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectMergeRule类属于org.apache.calcite.rel.rules包,在下文中一共展示了ProjectMergeRule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toLeafJoinForm
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
/**
* Converts a relational expression to a form where
* {@link org.apache.calcite.rel.logical.LogicalJoin}s are
* as close to leaves as possible.
*/
public static RelNode toLeafJoinForm(RelNode rel) {
final Program program = Programs.hep(
ImmutableList.of(
JoinProjectTransposeRule.RIGHT_PROJECT,
JoinProjectTransposeRule.LEFT_PROJECT,
FilterJoinRule.FilterIntoJoinRule.FILTER_ON_JOIN,
ProjectRemoveRule.INSTANCE,
ProjectMergeRule.INSTANCE),
false,
DefaultRelMetadataProvider.INSTANCE);
if (CalcitePrepareImpl.DEBUG) {
System.out.println(
RelOptUtil.dumpPlan("before", rel, SqlExplainFormat.TEXT,
SqlExplainLevel.DIGEST_ATTRIBUTES));
}
final RelNode rel2 = program.run(null, rel, null,
ImmutableList.<RelOptMaterialization>of(),
ImmutableList.<RelOptLattice>of());
if (CalcitePrepareImpl.DEBUG) {
System.out.println(
RelOptUtil.dumpPlan("after", rel2, SqlExplainFormat.TEXT,
SqlExplainLevel.DIGEST_ATTRIBUTES));
}
return rel2;
}
示例2: testStrengthenJoinType
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
@Test public void testStrengthenJoinType() {
// The "Filter(... , right.c IS NOT NULL)" above a left join is pushed into
// the join, makes it an inner join, and then disappears because c is NOT
// NULL.
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.build();
final String sql = "select *\n"
+ "from dept left join emp using (deptno)\n"
+ "where emp.deptno is not null and emp.sal > 100";
sql(sql)
.withDecorrelation(true)
.withTrim(true)
.withPre(preProgram)
.with(program)
.check();
}
示例3: testJoinProjectTranspose
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
@Test public void testJoinProjectTranspose() {
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(ProjectJoinTransposeRule.INSTANCE)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(JoinProjectTransposeRule.LEFT_PROJECT_INCLUDE_OUTER)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(JoinProjectTransposeRule.RIGHT_PROJECT_INCLUDE_OUTER)
.addRuleInstance(JoinProjectTransposeRule.LEFT_PROJECT_INCLUDE_OUTER)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.build();
final String sql = "select a.name\n"
+ "from dept a\n"
+ "left join dept b on b.deptno > 10\n"
+ "right join dept c on b.deptno > 10\n";
checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
示例4: testSemiJoinRuleExists
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
@Test public void testSemiJoinRuleExists() {
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(SemiJoinRule.PROJECT)
.build();
final String sql = "select * from dept where exists (\n"
+ " select * from emp\n"
+ " where emp.deptno = dept.deptno\n"
+ " and emp.sal > 100)";
sql(sql)
.withDecorrelation(true)
.withTrim(true)
.withPre(preProgram)
.with(program)
.check();
}
示例5: testSemiJoinRule
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
@Test public void testSemiJoinRule() {
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(SemiJoinRule.PROJECT)
.build();
final String sql = "select dept.* from dept join (\n"
+ " select distinct deptno from emp\n"
+ " where sal > 100) using (deptno)";
sql(sql)
.withDecorrelation(true)
.withTrim(true)
.withPre(preProgram)
.with(program)
.check();
}
示例6: testSemiJoinRuleRight
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1495">[CALCITE-1495]
* SemiJoinRule should not apply to RIGHT and FULL JOIN</a>. */
@Test public void testSemiJoinRuleRight() {
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(SemiJoinRule.PROJECT)
.build();
final String sql = "select dept.* from dept right join (\n"
+ " select distinct deptno from emp\n"
+ " where sal > 100) using (deptno)";
sql(sql)
.withPre(preProgram)
.with(program)
.withDecorrelation(true)
.withTrim(true)
.checkUnchanged();
}
示例7: testSemiJoinRuleFull
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
/** Similar to {@link #testSemiJoinRuleRight()} but FULL. */
@Test public void testSemiJoinRuleFull() {
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(SemiJoinRule.PROJECT)
.build();
final String sql = "select dept.* from dept full join (\n"
+ " select distinct deptno from emp\n"
+ " where sal > 100) using (deptno)";
sql(sql)
.withPre(preProgram)
.with(program)
.withDecorrelation(true)
.withTrim(true)
.checkUnchanged();
}
示例8: testSemiJoinRuleLeft
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
/** Similar to {@link #testSemiJoinRule()} but LEFT. */
@Test public void testSemiJoinRuleLeft() {
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(SemiJoinRule.PROJECT)
.build();
final String sql = "select name from dept left join (\n"
+ " select distinct deptno from emp\n"
+ " where sal > 100) using (deptno)";
sql(sql)
.withPre(preProgram)
.with(program)
.withDecorrelation(true)
.withTrim(true)
.check();
}
示例9: testEmptyFilterProjectUnion
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
@Test public void testEmptyFilterProjectUnion() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(FilterSetOpTransposeRule.INSTANCE)
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(ValuesReduceRule.PROJECT_FILTER_INSTANCE)
.addRuleInstance(PruneEmptyRules.PROJECT_INSTANCE)
.addRuleInstance(PruneEmptyRules.UNION_INSTANCE)
.build();
// Plan should be same as for
// select * from (values (30, 3)) as t(x, y)");
checkPlanning(program,
"select * from (\n"
+ "select * from (values (10, 1), (30, 3)) as t (x, y)\n"
+ "union all\n"
+ "select * from (values (20, 2))\n"
+ ")\n"
+ "where x + y > 30");
}
示例10: testPullFilterThroughAggregateGroupingSets
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
@Test public void testPullFilterThroughAggregateGroupingSets()
throws Exception {
HepProgram preProgram = HepProgram.builder()
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(ProjectFilterTransposeRule.INSTANCE)
.build();
HepProgram program = HepProgram.builder()
.addRuleInstance(AggregateFilterTransposeRule.INSTANCE)
.build();
final String sql = "select ename, sal, deptno from ("
+ " select ename, sal, deptno"
+ " from emp"
+ " where sal > 5000)"
+ "group by rollup(ename, sal, deptno)";
checkPlanning(tester, preProgram, new HepPlanner(program), sql);
}
示例11: testProjectWindowTransposeRuleWithConstants
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
@Test public void testProjectWindowTransposeRuleWithConstants() {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ProjectToWindowRule.PROJECT)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(ProjectWindowTransposeRule.INSTANCE)
.build();
final String sql = "select col1, col2\n"
+ "from (\n"
+ " select empno,\n"
+ " sum(100) over (partition by deptno order by sal) as col1,\n"
+ " sum(1000) over(partition by deptno order by sal) as col2\n"
+ " from emp)";
checkPlanning(program, sql);
}
示例12: substitute
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
private static List<RelNode> substitute(
RelNode root, RelOptMaterialization materialization) {
// First, if the materialization is in terms of a star table, rewrite
// the query in terms of the star table.
if (materialization.starTable != null) {
RelNode newRoot = RelOptMaterialization.tryUseStar(root,
materialization.starRelOptTable);
if (newRoot != null) {
root = newRoot;
}
}
// Push filters to the bottom, and combine projects on top.
RelNode target = materialization.queryRel;
HepProgram program =
new HepProgramBuilder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(ProjectRemoveRule.INSTANCE)
.build();
final HepPlanner hepPlanner = new HepPlanner(program);
hepPlanner.setRoot(target);
target = hepPlanner.findBestExp();
hepPlanner.setRoot(root);
root = hepPlanner.findBestExp();
return new MaterializedViewSubstitutionVisitor(target, root)
.go(materialization.tableRel);
}
示例13: testMergeProjectForceMode
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-648">[CALCITE-649]
* Update ProjectMergeRule description for new naming convention</a>. */
@Test public void testMergeProjectForceMode() throws Exception {
RuleSet ruleSet =
RuleSets.ofList(
new ProjectMergeRule(true,
RelBuilder.proto(RelFactories.DEFAULT_PROJECT_FACTORY)));
Planner planner = getPlanner(null, Programs.of(ruleSet));
planner.close();
}
示例14: testConvertSemiJoin
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
@Test public void testConvertSemiJoin() {
final String sql = "select * from dept where exists (\n"
+ " select * from emp\n"
+ " where emp.deptno = dept.deptno\n"
+ " and emp.sal > 100)";
checkConvertMutableRel(
"SemiJoin",
sql,
true,
ImmutableList.of(
FilterProjectTransposeRule.INSTANCE,
FilterJoinRule.FILTER_ON_JOIN,
ProjectMergeRule.INSTANCE,
SemiJoinRule.PROJECT));
}
示例15: basePushFilterPastAggWithGroupingSets
import org.apache.calcite.rel.rules.ProjectMergeRule; //导入依赖的package包/类
private void basePushFilterPastAggWithGroupingSets(boolean unchanged)
throws Exception {
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(FilterAggregateTransposeRule.INSTANCE)
.build();
checkPlanning(tester, preProgram, new HepPlanner(program), "${sql}",
unchanged);
}