本文整理汇总了Java中org.apache.calcite.rel.rules.FilterProjectTransposeRule类的典型用法代码示例。如果您正苦于以下问题:Java FilterProjectTransposeRule类的具体用法?Java FilterProjectTransposeRule怎么用?Java FilterProjectTransposeRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FilterProjectTransposeRule类属于org.apache.calcite.rel.rules包,在下文中一共展示了FilterProjectTransposeRule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: decorrelate
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
private RelNode decorrelate(RelNode root) {
// first adjust count() expression if any
HepProgram program = HepProgram.builder().addRuleInstance(new AdjustProjectForCountAggregateRule(false)).addRuleInstance(new AdjustProjectForCountAggregateRule(true)).addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(FilterProjectTransposeRule.INSTANCE).addRuleInstance(FilterCorrelateRule.INSTANCE).build();
HepPlanner planner = createPlanner(program);
planner.setRoot(root);
root = planner.findBestExp();
// Perform decorrelation.
map.clear();
final Frame frame = getInvoke(root, null);
if (frame != null) {
// has been rewritten; apply rules post-decorrelation
final HepProgram program2 = HepProgram.builder().addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(FilterJoinRule.JOIN).build();
final HepPlanner planner2 = createPlanner(program2);
final RelNode newRoot = frame.r;
planner2.setRoot(newRoot);
return planner2.findBestExp();
}
return root;
}
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:FlinkRelDecorrelator.java
示例2: testStrengthenJoinType
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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();
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:RelOptRulesTest.java
示例3: testSemiJoinRuleExists
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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();
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:RelOptRulesTest.java
示例4: testSemiJoinRule
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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();
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RelOptRulesTest.java
示例5: testSemiJoinRuleRight
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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();
}
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:RelOptRulesTest.java
示例6: testSemiJoinRuleFull
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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();
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:RelOptRulesTest.java
示例7: testSemiJoinRuleLeft
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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();
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:RelOptRulesTest.java
示例8: testPushFilterThroughSemiJoin
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-438">[CALCITE-438]
* Push predicates through SemiJoin</a>. */
@Test public void testPushFilterThroughSemiJoin() {
final HepProgram preProgram =
HepProgram.builder()
.addRuleInstance(SemiJoinRule.PROJECT)
.build();
final HepProgram program =
HepProgram.builder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.addRuleInstance(FilterJoinRule.JOIN)
.build();
final String sql = "select * from (\n"
+ " select * from dept where dept.deptno in (\n"
+ " select emp.deptno from emp))R\n"
+ "where R.deptno <=10";
sql(sql)
.withDecorrelation(true)
.withTrim(false)
.withPre(preProgram)
.with(program)
.check();
}
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:RelOptRulesTest.java
示例9: testMergeJoinFilter
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
/** Tests that a filters is combined are combined if they are identical,
* even if one of them originates in an ON clause of a JOIN. */
@Test public void testMergeJoinFilter() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterMergeRule.INSTANCE)
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.build();
checkPlanning(program,
"select * from (\n"
+ " select d.deptno, e.ename\n"
+ " from emp as e\n"
+ " join dept as d\n"
+ " on e.deptno = d.deptno\n"
+ " and d.deptno = 10)\n"
+ "where deptno = 10\n");
}
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:RelOptRulesTest.java
示例10: testEmptyFilterProjectUnion
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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");
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:RelOptRulesTest.java
示例11: decorrelate
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
private RelNode decorrelate(RelNode root) {
// first adjust count() expression if any
HepProgram program = HepProgram.builder()
.addRuleInstance(new AdjustProjectForCountAggregateRule(false))
.addRuleInstance(new AdjustProjectForCountAggregateRule(true))
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterCorrelateRule.INSTANCE)
.build();
HepPlanner planner = createPlanner(program);
planner.setRoot(root);
root = planner.findBestExp();
// Perform decorrelation.
map.clear();
final Frame frame = getInvoke(root, null);
if (frame != null) {
// has been rewritten; apply rules post-decorrelation
final HepProgram program2 = HepProgram.builder()
.addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
.addRuleInstance(FilterJoinRule.JOIN)
.build();
final HepPlanner planner2 = createPlanner(program2);
final RelNode newRoot = frame.r;
planner2.setRoot(newRoot);
return planner2.findBestExp();
}
return root;
}
开发者ID:apache,项目名称:calcite,代码行数:35,代码来源:RelDecorrelator.java
示例12: substitute
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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);
}
开发者ID:apache,项目名称:calcite,代码行数:32,代码来源:RelOptMaterializations.java
示例13: testConvertSemiJoin
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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));
}
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:MutableRelTest.java
示例14: basePushFilterPastAggWithGroupingSets
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的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);
}
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:RelOptRulesTest.java
示例15: testMergeFilter
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
/** Tests that filters are combined if they are identical. */
@Test public void testMergeFilter() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterMergeRule.INSTANCE)
.build();
checkPlanning(program,
"select name from (\n"
+ " select *\n"
+ " from dept\n"
+ " where deptno = 10)\n"
+ "where deptno = 10\n");
}
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:RelOptRulesTest.java
示例16: testReduceConstantsCalc
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
@Test public void testReduceConstantsCalc() throws Exception {
// This reduction does not work using
// ReduceExpressionsRule.PROJECT_INSTANCE or FILTER_INSTANCE,
// only CALC_INSTANCE, because we need to pull the project expression
// upper('table')
// into the condition
// upper('table') = 'TABLE'
// and reduce it to TRUE. Only in the Calc are projects and conditions
// combined.
HepProgram program = new HepProgramBuilder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(FilterSetOpTransposeRule.INSTANCE)
.addRuleInstance(FilterToCalcRule.INSTANCE)
.addRuleInstance(ProjectToCalcRule.INSTANCE)
.addRuleInstance(CalcMergeRule.INSTANCE)
.addRuleInstance(ReduceExpressionsRule.CALC_INSTANCE)
// the hard part is done... a few more rule calls to clean up
.addRuleInstance(PruneEmptyRules.UNION_INSTANCE)
.addRuleInstance(ProjectToCalcRule.INSTANCE)
.addRuleInstance(CalcMergeRule.INSTANCE)
.addRuleInstance(ReduceExpressionsRule.CALC_INSTANCE)
.build();
// Result should be same as typing
// SELECT * FROM (VALUES ('TABLE ', 'T')) AS T(U, S)
checkPlanning(program,
"select * from (\n"
+ " select upper(substring(x FROM 1 FOR 2) || substring(x FROM 3)) as u,\n"
+ " substring(x FROM 1 FOR 1) as s\n"
+ " from (\n"
+ " select 'table' as x from (values (true))\n"
+ " union\n"
+ " select 'view' from (values (true))\n"
+ " union\n"
+ " select 'foreign table' from (values (true))\n"
+ " )\n"
+ ") where u = 'TABLE'");
}
开发者ID:apache,项目名称:calcite,代码行数:40,代码来源:RelOptRulesTest.java
示例17: testReduceValuesUnderFilter
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
@Test public void testReduceValuesUnderFilter() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(ValuesReduceRule.FILTER_INSTANCE)
.build();
// Plan should be same as for
// select a, b from (values (10,'x')) as t(a, b)");
checkPlanning(program,
"select a, b from (values (10, 'x'), (20, 'y')) as t(a, b) where a < 15");
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelOptRulesTest.java
示例18: testReduceValuesUnderProjectFilter
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
@Test public void testReduceValuesUnderProjectFilter() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(ValuesReduceRule.PROJECT_FILTER_INSTANCE)
.build();
// Plan should be same as for
// select * from (values (11, 1, 10), (23, 3, 20)) as t(x, b, a)");
checkPlanning(program,
"select a + b as x, b, a from (values (10, 1), (30, 7), (20, 3)) as t(a, b)"
+ " where a - b < 21");
}
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:RelOptRulesTest.java
示例19: testReduceValuesToEmpty
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
@Test public void testReduceValuesToEmpty() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE)
.addRuleInstance(ProjectMergeRule.INSTANCE)
.addRuleInstance(ValuesReduceRule.PROJECT_FILTER_INSTANCE)
.build();
// Plan should be same as for
// select * from (values (11, 1, 10), (23, 3, 20)) as t(x, b, a)");
checkPlanning(program,
"select a + b as x, b, a from (values (10, 1), (30, 7)) as t(a, b)"
+ " where a - b < 0");
}
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:RelOptRulesTest.java
示例20: testPushFilterWithRank
import org.apache.calcite.rel.rules.FilterProjectTransposeRule; //导入依赖的package包/类
@Test public void testPushFilterWithRank() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(FilterProjectTransposeRule.INSTANCE).build();
final String sql = "select e1.ename, r\n"
+ "from (\n"
+ " select ename, "
+ " rank() over(partition by deptno order by sal) as r "
+ " from emp) e1\n"
+ "where r < 2";
checkPlanUnchanged(new HepPlanner(program), sql);
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelOptRulesTest.java
注:本文中的org.apache.calcite.rel.rules.FilterProjectTransposeRule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论