本文整理汇总了Java中org.apache.calcite.rel.rules.ReduceExpressionsRule类的典型用法代码示例。如果您正苦于以下问题:Java ReduceExpressionsRule类的具体用法?Java ReduceExpressionsRule怎么用?Java ReduceExpressionsRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReduceExpressionsRule类属于org.apache.calcite.rel.rules包,在下文中一共展示了ReduceExpressionsRule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDrillUserConfigurableLogicalRules
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
/**
* Get a list of logical rules that can be turned on or off by session/system options.
*
* If a rule is intended to always be included with the logical set, it should be added
* to the immutable list created in the getDrillBasicRules() method below.
*
* @param optimizerRulesContext - used to get the list of planner settings, other rules may
* also in the future need to get other query state from this,
* such as the available list of UDFs (as is used by the
* DrillMergeProjectRule created in getDrillBasicRules())
* @return - a list of rules that have been filtered to leave out
* rules that have been turned off by system or session settings
*/
public static RuleSet getDrillUserConfigurableLogicalRules(OptimizerRulesContext optimizerRulesContext) {
final PlannerSettings ps = optimizerRulesContext.getPlannerSettings();
// This list is used to store rules that can be turned on an off
// by user facing planning options
final Builder<RelOptRule> userConfigurableRules = ImmutableSet.<RelOptRule>builder();
if (ps.isConstantFoldingEnabled()) {
// TODO - DRILL-2218
userConfigurableRules.add(ReduceExpressionsRule.PROJECT_INSTANCE);
userConfigurableRules.add(DrillReduceExpressionsRule.FILTER_INSTANCE_DRILL);
userConfigurableRules.add(DrillReduceExpressionsRule.CALC_INSTANCE_DRILL);
}
return new DrillRuleSet(userConfigurableRules.build());
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:31,代码来源:DrillRuleSets.java
示例2: testReduceNestedCaseWhen
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceNestedCaseWhen() {
HepProgram preProgram = new HepProgramBuilder()
.build();
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleClass(ReduceExpressionsRule.class);
HepPlanner hepPlanner = new HepPlanner(builder.build());
hepPlanner.addRule(ReduceExpressionsRule.FILTER_INSTANCE);
final String sql = "select sal\n"
+ "from emp\n"
+ "where case when (sal = 1000) then\n"
+ "(case when sal = 1000 then null else 1 end is null) else\n"
+ "(case when sal = 2000 then null else 1 end is null) end is true";
checkPlanning(tester, preProgram, hepPlanner, sql);
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelOptRulesTest.java
示例3: testReduceCompositeInSubQuery
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1479">[CALCITE-1479]
* AssertionError in ReduceExpressionsRule on multi-column IN
* sub-query</a>. */
@Test public void testReduceCompositeInSubQuery() {
final HepProgram hepProgram = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.build();
final String sql = "select *\n"
+ "from emp\n"
+ "where (empno, deptno) in (\n"
+ " select empno, deptno from (\n"
+ " select empno, deptno\n"
+ " from emp\n"
+ " group by empno, deptno))\n"
+ "or deptno < 40 + 60";
checkSubQuery(sql)
.with(hepProgram)
.check();
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:RelOptRulesTest.java
示例4: testSemiJoinReduceConstants
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-571">[CALCITE-571]
* ReduceExpressionsRule tries to reduce SemiJoin condition to non-equi
* condition</a>. */
@Test public void testSemiJoinReduceConstants() {
final HepProgram preProgram = HepProgram.builder()
.addRuleInstance(SemiJoinRule.PROJECT)
.build();
final HepProgram program = HepProgram.builder()
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
final String sql = "select e1.sal\n"
+ "from (select * from emp where deptno = 200) as e1\n"
+ "where e1.deptno in (\n"
+ " select e2.deptno from emp e2 where e2.sal = 100)";
sql(sql)
.withDecorrelation(false)
.withTrim(true)
.withPre(preProgram)
.with(program)
.checkUnchanged();
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:RelOptRulesTest.java
示例5: testReduceConstants
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceConstants() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
// NOTE jvs 27-May-2006: among other things, this verifies
// intentionally different treatment for identical coalesce expression
// in select and where.
// There is "CAST(2 AS INTEGER)" in the plan because 2 has type "INTEGER NOT
// NULL" and we need "INTEGER".
final String sql = "select"
+ " 1+2, d.deptno+(3+4), (5+6)+d.deptno, cast(null as integer),"
+ " coalesce(2,null), row(7+8)"
+ " from dept d inner join emp e"
+ " on d.deptno = e.deptno + (5-5)"
+ " where d.deptno=(7+8) and d.deptno=(8+7) and d.deptno=coalesce(2,null)";
sql(sql).with(program)
.withProperty(Hook.REL_BUILDER_SIMPLIFY, false)
.check();
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:RelOptRulesTest.java
示例6: testReduceConstantsCaseEquals2
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceConstantsCaseEquals2() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
// Equivalent to 'case when deptno = 20 then false
// when deptno = 10 then true
// else null end'
checkPlanning(program,
"select count(1) from emp\n"
+ "where case deptno\n"
+ " when 20 then 2\n"
+ " when 10 then 1\n"
+ " else cast(null as integer) end = 1");
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:RelOptRulesTest.java
示例7: testReduceConstantsCaseEquals3
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceConstantsCaseEquals3() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
// Equivalent to 'deptno = 30 or deptno = 10'
checkPlanning(program,
"select count(1) from emp\n"
+ "where case deptno\n"
+ " when 30 then 1\n"
+ " when 20 then 2\n"
+ " when 10 then 1\n"
+ " when 30 then 111\n"
+ " else 0 end = 1");
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:RelOptRulesTest.java
示例8: testReduceCastsNullable
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Ignore // Calcite does not support INSERT yet
@Test public void testReduceCastsNullable() throws Exception {
HepProgram program = new HepProgramBuilder()
// Simulate the way INSERT will insert casts to the target types
.addRuleInstance(
new CoerceInputsRule(LogicalTableModify.class, false,
RelFactories.LOGICAL_BUILDER))
// Convert projects to calcs, merge two calcs, and then
// reduce redundant casts in merged calc.
.addRuleInstance(ProjectToCalcRule.INSTANCE)
.addRuleInstance(CalcMergeRule.INSTANCE)
.addRuleInstance(ReduceExpressionsRule.CALC_INSTANCE)
.build();
checkPlanning(program,
"insert into sales.depts(name) "
+ "select cast(gender as varchar(128)) from sales.emps");
}
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:RelOptRulesTest.java
示例9: testCorrelationScalarAggAndFilter
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-2110">[CALCITE-2110]
* ArrayIndexOutOfBoundsException in RexSimplify when using
* ReduceExpressionsRule.JOIN_INSTANCE</a>. */
@Test public void testCorrelationScalarAggAndFilter() {
final String sql = "SELECT e1.empno\n"
+ "FROM emp e1, dept d1 where e1.deptno = d1.deptno\n"
+ "and e1.deptno < 10 and d1.deptno < 15\n"
+ "and e1.sal > (select avg(sal) from emp e2 where e1.empno = e2.empno)";
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
sql(sql)
.withDecorrelation(true)
.withTrim(true)
.expand(true)
.withPre(program)
.with(program)
.checkUnchanged();
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:RelOptRulesTest.java
示例10: DrillSqlWorker
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
public DrillSqlWorker(QueryContext context) {
final List<RelTraitDef> traitDefs = new ArrayList<RelTraitDef>();
traitDefs.add(ConventionTraitDef.INSTANCE);
traitDefs.add(DrillDistributionTraitDef.INSTANCE);
traitDefs.add(RelCollationTraitDef.INSTANCE);
this.context = context;
RelOptCostFactory costFactory = (context.getPlannerSettings().useDefaultCosting()) ?
null : new DrillCostBase.DrillCostFactory() ;
int idMaxLength = (int)context.getPlannerSettings().getIdentifierMaxLength();
FrameworkConfig config = Frameworks.newConfigBuilder() //
.parserConfig(SqlParser.configBuilder()
.setLex(Lex.MYSQL)
.setIdentifierMaxLength(idMaxLength)
.setParserFactory(DrillParserWithCompoundIdConverter.FACTORY)
.build()) //
.defaultSchema(context.getNewDefaultSchema()) //
.operatorTable(context.getDrillOperatorTable()) //
.traitDefs(traitDefs) //
.convertletTable(new DrillConvertletTable()) //
.context(context.getPlannerSettings()) //
.ruleSets(getRules(context)) //
.costFactory(costFactory) //
.executor(new DrillConstExecutor(context.getFunctionRegistry(), context, context.getPlannerSettings()))
.typeSystem(DrillRelDataTypeSystem.DRILL_REL_DATATYPE_SYSTEM) //
.build();
this.planner = Frameworks.getPlanner(config);
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleClass(ReduceExpressionsRule.class);
builder.addRuleClass(ProjectToWindowRule.class);
this.hepPlanner = new HepPlanner(builder.build());
hepPlanner.addRule(ReduceExpressionsRule.CALC_INSTANCE);
hepPlanner.addRule(ProjectToWindowRule.PROJECT);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:36,代码来源:DrillSqlWorker.java
示例11: checkRuleApplyCount
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
private long checkRuleApplyCount(HepMatchOrder matchOrder) {
final HepProgramBuilder programBuilder = HepProgram.builder();
programBuilder.addMatchOrder(matchOrder);
programBuilder.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE);
programBuilder.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE);
final HepTestListener listener = new HepTestListener(0);
HepPlanner planner = new HepPlanner(programBuilder.build());
planner.addListener(listener);
planner.setRoot(tester.convertSqlToRel(COMPLEX_UNION_TREE).rel);
planner.findBestExp();
return listener.getApplyTimes();
}
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:HepPlannerTest.java
示例12: testReduceNot
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceNot() {
HepProgram preProgram = new HepProgramBuilder()
.build();
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleClass(ReduceExpressionsRule.class);
HepPlanner hepPlanner = new HepPlanner(builder.build());
hepPlanner.addRule(ReduceExpressionsRule.FILTER_INSTANCE);
final String sql = "select *\n"
+ "from (select (case when sal > 1000 then null else false end) as caseCol from emp)\n"
+ "where NOT(caseCol)";
checkPlanning(tester, preProgram, hepPlanner, sql, true);
}
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:RelOptRulesTest.java
示例13: testReduceOrCaseWhen
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceOrCaseWhen() {
HepProgram preProgram = new HepProgramBuilder()
.build();
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleClass(ReduceExpressionsRule.class);
HepPlanner hepPlanner = new HepPlanner(builder.build());
hepPlanner.addRule(ReduceExpressionsRule.FILTER_INSTANCE);
final String sql = "select sal\n"
+ "from emp\n"
+ "where case when sal = 1000 then null else 1 end is null\n"
+ "OR case when sal = 2000 then null else 1 end is null";
checkPlanning(tester, preProgram, hepPlanner, sql);
}
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:RelOptRulesTest.java
示例14: testReduceNullableCase
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceNullableCase() {
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleClass(ReduceExpressionsRule.class);
HepPlanner hepPlanner = new HepPlanner(builder.build());
hepPlanner.addRule(ReduceExpressionsRule.PROJECT_INSTANCE);
final String sql = "SELECT CASE WHEN 1=2 "
+ "THEN cast((values(1)) as integer) "
+ "ELSE 2 end from (values(1))";
sql(sql).with(hepPlanner).check();
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelOptRulesTest.java
示例15: testReduceNullableCase2
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceNullableCase2() {
HepProgramBuilder builder = new HepProgramBuilder();
builder.addRuleClass(ReduceExpressionsRule.class);
HepPlanner hepPlanner = new HepPlanner(builder.build());
hepPlanner.addRule(ReduceExpressionsRule.PROJECT_INSTANCE);
final String sql = "SELECT deptno, ename, CASE WHEN 1=2 "
+ "THEN substring(ename, 1, cast(2 as int)) ELSE NULL end from emp"
+ " group by deptno, ename, case when 1=2 then substring(ename,1, cast(2 as int)) else null end";
sql(sql).with(hepPlanner).check();
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelOptRulesTest.java
示例16: testReduceConstantsDup
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-570">[CALCITE-570]
* ReduceExpressionsRule throws "duplicate key" exception</a>. */
@Test public void testReduceConstantsDup() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
final String sql = "select d.deptno"
+ " from dept d"
+ " where d.deptno=7 and d.deptno=8";
checkPlanning(new HepPlanner(program), sql);
}
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:RelOptRulesTest.java
示例17: testReduceConstantsDup2
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-935">[CALCITE-935]
* Improve how ReduceExpressionsRule handles duplicate constraints</a>. */
@Test public void testReduceConstantsDup2() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
final String sql = "select *\n"
+ "from emp\n"
+ "where deptno=7 and deptno=8\n"
+ "and empno = 10 and mgr is null and empno = 10";
checkPlanning(program, sql);
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelOptRulesTest.java
示例18: testPullNull
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testPullNull() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
final String sql = "select *\n"
+ "from emp\n"
+ "where deptno=7\n"
+ "and empno = 10 and mgr is null and empno = 10";
checkPlanning(program, sql);
}
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:RelOptRulesTest.java
示例19: testReduceConstants2
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
@Test public void testReduceConstants2() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
checkPlanning(program,
"select p1 is not distinct from p0 from (values (2, cast(null as integer))) as t(p0, p1)");
}
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:RelOptRulesTest.java
示例20: testReduceConstantsProjectNullable
import org.apache.calcite.rel.rules.ReduceExpressionsRule; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-902">[CALCITE-902]
* Match nullability when reducing expressions in a Project</a>. */
@Test public void testReduceConstantsProjectNullable() throws Exception {
HepProgram program = new HepProgramBuilder()
.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE)
.build();
checkPlanning(program, "select mgr from emp where mgr=10");
}
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:RelOptRulesTest.java
注:本文中的org.apache.calcite.rel.rules.ReduceExpressionsRule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论