public void Run(RegressionEnvironment env) { EventType[] types = { env.Runtime.EventTypeService.GetEventTypePreconfigured("SupportBean_S0"), env.Runtime.EventTypeService.GetEventTypePreconfigured("SupportBean_S1") }; var epl = "select * from SupportBean_S0#keepall as S0, SupportBean_S1#keepall as S1 "; var planFullTableScan = SupportQueryPlanBuilder.Start(2) .SetIndexFullTableScan(0, "i0") .SetIndexFullTableScan(1, "i1") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i1"))) .SetLookupPlanInner(1, new FullTableScanLookupPlanForge(1, 0, false, types, GetIndexKey("i0"))) .Get(); // test "any" var excludeAny = "@Hint('exclude_plan(true)')"; TryAssertionJoin(env, epl, planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 = P10", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 = 'abc'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 = (P10 || 'A')", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P10 = 'abc'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 > P10", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 > 'A'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P10 > 'A'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P10 > 'A'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 > (P10 || 'A')", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 between P10 and P11", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 between 'a' and P11", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 between 'a' and 'c'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 between P10 and 'c'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 in (P10, P11)", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 in ('a', P11)", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 in ('a', 'b')", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P10 in (P00, P01)", planFullTableScan); // test EQUALS var planEquals = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(0, "i1", "P00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner( 0, new FullTableScanLookupPlanForge( 0, 1, false, types, GetIndexKey("i2"))) .SetLookupPlanInner( 1, new IndexedTableLookupPlanHashedOnlyForge( 1, 0, false, types, GetIndexKey("i1"), new[] { SupportExprNodeFactory.MakeKeyed("P10") }, null, null, null)) .Get(); var eplWithWhereEquals = epl + " where P00 = P10"; TryAssertionJoin( env, "@Hint('exclude_plan(from_streamnum=0)')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(from_streamname=\"S0\")')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(from_streamname=\"S0\")') @Hint('exclude_plan(from_streamname=\"S1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(from_streamname=\"S0\")') @Hint('exclude_plan(from_streamname=\"S1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(to_streamname=\"S1\")')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(to_streamname=\"S0\")') @Hint('exclude_plan(to_streamname=\"S1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(from_streamnum=0 and to_streamnum = 1)')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(to_streamnum=1)')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(to_streamnum = 1, from_streamnum = 0)')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(opname=\"equals\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(exprs.anyOf(v-> v=\"P00\"))')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(\"P10\" in (exprs))')" + eplWithWhereEquals, planFullTableScan); // test greater (relop) var planGreater = SupportQueryPlanBuilder.Start(2) .AddIndexBtreeSingle(0, "i1", "P00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i2"))) .SetLookupPlanInner( 1, new SortedTableLookupPlanForge( 1, 0, false, types, GetIndexKey("i1"), SupportExprNodeFactory.MakeRangeLess("P10"), null)) .Get(); var eplWithWhereGreater = epl + " where P00 > P10"; TryAssertionJoin(env, "@Hint('exclude_plan(from_streamnum=0)')" + eplWithWhereGreater, planGreater); TryAssertionJoin( env, "@Hint('exclude_plan(opname=\"relop\")')" + eplWithWhereGreater, planFullTableScan); // test range (relop) var planRange = SupportQueryPlanBuilder.Start(2) .AddIndexBtreeSingle(0, "i1", "P00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i2"))) .SetLookupPlanInner( 1, new SortedTableLookupPlanForge( 1, 0, false, types, GetIndexKey("i1"), SupportExprNodeFactory.MakeRangeIn("P10", "P11"), null)) .Get(); var eplWithWhereRange = epl + " where P00 between P10 and P11"; TryAssertionJoin(env, "@Hint('exclude_plan(from_streamnum=0)')" + eplWithWhereRange, planRange); TryAssertionJoin(env, "@Hint('exclude_plan(opname=\"relop\")')" + eplWithWhereRange, planFullTableScan); // test in (relop) var planIn = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(0, "i1", "P00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i2"))) .SetLookupPlanInner( 1, new InKeywordTableLookupPlanSingleIdxForge( 1, 0, false, types, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("P10", "P11"))) .Get(); var eplWithIn = epl + " where P00 in (P10, P11)"; TryAssertionJoin(env, "@Hint('exclude_plan(from_streamnum=0)')" + eplWithIn, planIn); TryAssertionJoin(env, "@Hint('exclude_plan(opname=\"inkw\")')" + eplWithIn, planFullTableScan); env.UndeployAll(); }
private void RunAssertionJoin(EPServiceProvider epService) { string epl = "select * from S0#keepall as s0, S1#keepall as s1 "; QueryPlan planFullTableScan = SupportQueryPlanBuilder.Start(2) .SetIndexFullTableScan(0, "i0") .SetIndexFullTableScan(1, "i1") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i1"))) .SetLookupPlanInner(1, new FullTableScanLookupPlan(1, 0, GetIndexKey("i0"))) .Get(); // test "any" string excludeAny = "@Hint('Exclude_plan(true)')"; TryAssertionJoin(epService, epl, planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 = p10", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 = 'abc'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 = (p10 || 'A')", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p10 = 'abc'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 > p10", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 > 'A'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p10 > 'A'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p10 > 'A'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 > (p10 || 'A')", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 between p10 and p11", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 between 'a' and p11", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 between 'a' and 'c'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 between p10 and 'c'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 in (p10, p11)", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 in ('a', p11)", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 in ('a', 'b')", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p10 in (p00, p01)", planFullTableScan); // test EQUALS QueryPlan planEquals = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(0, "i1", "p00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i2"))) .SetLookupPlanInner(1, new IndexedTableLookupPlanSingle(1, 0, GetIndexKey("i1"), SupportExprNodeFactory.MakeKeyed("p10"))) .Get(); string eplWithWhereEquals = epl + " where p00 = p10"; TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0)')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamname=\"s0\")')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamname=\"s0\")') @Hint('Exclude_plan(from_streamname=\"s1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamname=\"s0\")') @Hint('Exclude_plan(from_streamname=\"s1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(to_streamname=\"s1\")')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(to_streamname=\"s0\")') @Hint('Exclude_plan(to_streamname=\"s1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0 and to_streamnum = 1)')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(to_streamnum=1)')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(to_streamnum = 1, from_streamnum = 0)')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(opname=\"equals\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(exprs.anyOf(v=> v=\"p00\"))')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(\"p10\" in (exprs))')" + eplWithWhereEquals, planFullTableScan); // test greater (relop) QueryPlan planGreater = SupportQueryPlanBuilder.Start(2) .AddIndexBtreeSingle(0, "i1", "p00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i2"))) .SetLookupPlanInner(1, new SortedTableLookupPlan(1, 0, GetIndexKey("i1"), SupportExprNodeFactory.MakeRangeLess("p10"))) .Get(); string eplWithWhereGreater = epl + " where p00 > p10"; TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0)')" + eplWithWhereGreater, planGreater); TryAssertionJoin(epService, "@Hint('Exclude_plan(opname=\"relop\")')" + eplWithWhereGreater, planFullTableScan); // test range (relop) QueryPlan planRange = SupportQueryPlanBuilder.Start(2) .AddIndexBtreeSingle(0, "i1", "p00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i2"))) .SetLookupPlanInner(1, new SortedTableLookupPlan(1, 0, GetIndexKey("i1"), SupportExprNodeFactory.MakeRangeIn("p10", "p11"))) .Get(); string eplWithWhereRange = epl + " where p00 between p10 and p11"; TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0)')" + eplWithWhereRange, planRange); TryAssertionJoin(epService, "@Hint('Exclude_plan(opname=\"relop\")')" + eplWithWhereRange, planFullTableScan); // test in (relop) QueryPlan planIn = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(0, "i1", "p00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i2"))) .SetLookupPlanInner(1, new InKeywordTableLookupPlanSingleIdx(1, 0, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("p10", "p11"))) .Get(); string eplWithIn = epl + " where p00 in (p10, p11)"; TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0)')" + eplWithIn, planIn); TryAssertionJoin(epService, "@Hint('Exclude_plan(opname=\"inkw\")')" + eplWithIn, planFullTableScan); epService.EPAdministrator.DestroyAllStatements(); }