private void RunAssertionQueryPlan3Stream(EPServiceProvider epService) { var epl = "select * from S0 as s0 unidirectional, S1#keepall, S2#keepall "; // 3-stream join with in-multiindex directional var planInMidx = new InKeywordTableLookupPlanMultiIdx( 0, 1, GetIndexKeys("i1a", "i1b"), SupportExprNodeFactory.MakeIdentExprNode("P00")); TryAssertion( epService, epl + " where P00 in (P10, P11)", SupportQueryPlanBuilder.Start(3) .AddIndexHashSingleNonUnique(1, "i1a", "P10") .AddIndexHashSingleNonUnique(1, "i1b", "P11") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction( 0, "s0", new[] { new LookupInstructionPlan( 0, "s0", new[] {1}, new TableLookupPlan[] {planInMidx}, null, new bool[3]), new LookupInstructionPlan( 0, "s0", new[] {2}, new TableLookupPlan[] {new FullTableScanLookupPlan(1, 2, GetIndexKey("i2"))}, null, new bool[3]) }) .Get()); var planInMidxMulitiSrc = new InKeywordTableLookupPlanMultiIdx( 0, 1, GetIndexKeys("i1", "i2"), SupportExprNodeFactory.MakeIdentExprNode("P00")); TryAssertion( epService, epl + " where P00 in (P10, P20)", SupportQueryPlanBuilder.Start(3) .SetIndexFullTableScan(1, "i1") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction( 0, "s0", new[] { new LookupInstructionPlan( 0, "s0", new[] {1}, new TableLookupPlan[] {new FullTableScanLookupPlan(0, 1, GetIndexKey("i1"))}, null, new bool[3]), new LookupInstructionPlan( 0, "s0", new[] {2}, new TableLookupPlan[] {new FullTableScanLookupPlan(1, 2, GetIndexKey("i2"))}, null, new bool[3]) }) .Get()); // 3-stream join with in-singleindex directional var planInSidx = new InKeywordTableLookupPlanSingleIdx( 0, 1, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("P00", "P01")); TryAssertion(epService, epl + " where P10 in (P00, P01)", GetSingleIndexPlan(planInSidx)); // 3-stream join with in-singleindex multi-sourced var planInSingleMultiSrc = new InKeywordTableLookupPlanSingleIdx( 0, 1, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("P00")); TryAssertion(epService, epl + " where P10 in (P00, P20)", GetSingleIndexPlan(planInSingleMultiSrc)); }
private QueryPlan GetSingleIndexPlan(InKeywordTableLookupPlanSingleIdx plan) { return(SupportQueryPlanBuilder.Start(3) .AddIndexHashSingleNonUnique(1, "i1", "p10") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction(0, "s0", new LookupInstructionPlan[] { new LookupInstructionPlan(0, "s0", new int[] { 1 }, new TableLookupPlan[] { plan }, null, new bool[3]), new LookupInstructionPlan(0, "s0", new int[] { 2 }, new TableLookupPlan[] { new FullTableScanLookupPlan(1, 2, GetIndexKey("i2")) }, null, new bool[3]) }) .Get()); }
public void TestQueryPlan3Stream() { var epl = "select * from S0 as s0 unidirectional, S1.win:keepall(), S2.win:keepall() "; // 3-stream join with in-multiindex directional var planInMidx = new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("i1a", "i1b"), SupportExprNodeFactory.MakeIdentExprNode("p00")); RunAssertion(epl + " where p00 in (p10, p11)", SupportQueryPlanBuilder.Start(3) .AddIndexHashSingleNonUnique(1, "i1a", "p10") .AddIndexHashSingleNonUnique(1, "i1b", "p11") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction(0, "s0", new LookupInstructionPlan[] { new LookupInstructionPlan(0, "s0", new int[] { 1 }, new TableLookupPlan[] { planInMidx }, null, new bool[3]), new LookupInstructionPlan(0, "s0", new int[] { 2 }, new TableLookupPlan[] { new FullTableScanLookupPlan(1, 2, GetIndexKey("i2")) }, null, new bool[3]) }) .Get()); var planInMidxMulitiSrc = new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("i1", "i2"), SupportExprNodeFactory.MakeIdentExprNode("p00")); RunAssertion(epl + " where p00 in (p10, p20)", SupportQueryPlanBuilder.Start(3) .SetIndexFullTableScan(1, "i1") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction(0, "s0", new LookupInstructionPlan[] { new LookupInstructionPlan(0, "s0", new int[] { 1 }, new TableLookupPlan[] { new FullTableScanLookupPlan(0, 1, GetIndexKey("i1")) }, null, new bool[3]), new LookupInstructionPlan(0, "s0", new int[] { 2 }, new TableLookupPlan[] { new FullTableScanLookupPlan(1, 2, GetIndexKey("i2")) }, null, new bool[3]) }) .Get()); // 3-stream join with in-singleindex directional var planInSidx = new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("p00", "p01")); RunAssertion(epl + " where p10 in (p00, p01)", GetSingleIndexPlan(planInSidx)); // 3-stream join with in-singleindex multi-sourced var planInSingleMultiSrc = new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("p00")); RunAssertion(epl + " where p10 in (p00, p20)", GetSingleIndexPlan(planInSingleMultiSrc)); }
private static QueryPlanForge GetSingleIndexPlan( EventType[] types, InKeywordTableLookupPlanSingleIdxForge plan) { return SupportQueryPlanBuilder.Start(3) .AddIndexHashSingleNonUnique(1, "i1", "P10") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction( 0, "S0", new[] { new LookupInstructionPlanForge(0, "S0", new[] {1}, new TableLookupPlanForge[] {plan}, null, new bool[3]), new LookupInstructionPlanForge( 0, "S0", new[] {2}, new TableLookupPlanForge[] {new FullTableScanLookupPlanForge(1, 2, false, types, GetIndexKey("i2"))}, null, new bool[3]) }) .Get(); }
public void TestQueryPlan2Stream() { var epl = "select * from S0 as s0 unidirectional, S1.win:keepall() "; var fullTableScan = SupportQueryPlanBuilder.Start(2) .SetIndexFullTableScan(1, "a") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("a"))).Get(); // 2-stream unidirectional joins RunAssertion(epl, fullTableScan); var planEquals = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p10") .SetLookupPlanInner(0, new IndexedTableLookupPlanSingle(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeKeyed("p00"))).Get(); RunAssertion(epl + "where p00 = p10", planEquals); RunAssertion(epl + "where p00 = p10 and p00 in (p11, p12, p13)", planEquals); var planInMultiInner = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p11") .AddIndexHashSingleNonUnique(1, "b", "p12") .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("p00"))).Get(); RunAssertion(epl + "where p00 in (p11, p12)", planInMultiInner); RunAssertion(epl + "where p00 = p11 or p00 = p12", planInMultiInner); var planInMultiOuter = SupportQueryPlanBuilder.Start(planInMultiInner) .SetLookupPlanOuter(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("p00"))).Get(); var eplOuterJoin = "select * from S0 as s0 unidirectional full outer join S1.win:keepall() "; RunAssertion(eplOuterJoin + "where p00 in (p11, p12)", planInMultiOuter); var planInMultiWConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p11") .AddIndexHashSingleNonUnique(1, "b", "p12") .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeConstExprNode("A"))).Get(); RunAssertion(epl + "where 'A' in (p11, p12)", planInMultiWConst); RunAssertion(epl + "where 'A' = p11 or 'A' = p12", planInMultiWConst); var planInMultiWAddConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p12") .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a"), SupportExprNodeFactory.MakeConstExprNode("A"))).Get(); RunAssertion(epl + "where 'A' in ('B', p12)", planInMultiWAddConst); RunAssertion(epl + "where 'A' in ('B', 'C')", fullTableScan); var planInSingle = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p10") .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeIdentExprNodes("p00", "p01"))).Get(); RunAssertion(epl + "where p10 in (p00, p01)", planInSingle); var planInSingleWConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p10") .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndIdentNode("A", "p01"))).Get(); RunAssertion(epl + "where p10 in ('A', p01)", planInSingleWConst); var planInSingleJustConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p10") .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndConstNode("A", "B"))).Get(); RunAssertion(epl + "where p10 in ('A', 'B')", planInSingleJustConst); }
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(); }
private void RunAssertionQueryPlan2Stream(EPServiceProvider epService) { var epl = "select * from S0 as s0 unidirectional, S1#keepall "; var fullTableScan = SupportQueryPlanBuilder.Start(2) .SetIndexFullTableScan(1, "a") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("a"))) .Get(); // 2-stream unidirectional joins TryAssertion(epService, epl, fullTableScan); var planEquals = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P10") .SetLookupPlanInner( 0, new IndexedTableLookupPlanSingle(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeKeyed("P00"))) .Get(); TryAssertion(epService, epl + "where P00 = P10", planEquals); TryAssertion(epService, epl + "where P00 = P10 and P00 in (P11, P12, P13)", planEquals); var planInMultiInner = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P11") .AddIndexHashSingleNonUnique(1, "b", "P12") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanMultiIdx( 0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("P00"))) .Get(); TryAssertion(epService, epl + "where P00 in (P11, P12)", planInMultiInner); TryAssertion(epService, epl + "where P00 = P11 or P00 = P12", planInMultiInner); var planInMultiOuter = SupportQueryPlanBuilder.Start(planInMultiInner) .SetLookupPlanOuter( 0, new InKeywordTableLookupPlanMultiIdx( 0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("P00"))) .Get(); var eplOuterJoin = "select * from S0 as s0 unidirectional full outer join S1#keepall "; TryAssertion(epService, eplOuterJoin + "where P00 in (P11, P12)", planInMultiOuter); var planInMultiWConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P11") .AddIndexHashSingleNonUnique(1, "b", "P12") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanMultiIdx( 0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeConstExprNode("A"))) .Get(); TryAssertion(epService, epl + "where 'A' in (P11, P12)", planInMultiWConst); TryAssertion(epService, epl + "where 'A' = P11 or 'A' = P12", planInMultiWConst); var planInMultiWAddConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P12") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanMultiIdx( 0, 1, GetIndexKeys("a"), SupportExprNodeFactory.MakeConstExprNode("A"))) .Get(); TryAssertion(epService, epl + "where 'A' in ('B', P12)", planInMultiWAddConst); TryAssertion(epService, epl + "where 'A' in ('B', 'C')", fullTableScan); var planInSingle = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P10") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanSingleIdx( 0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeIdentExprNodes("P00", "P01"))) .Get(); TryAssertion(epService, epl + "where P10 in (P00, P01)", planInSingle); var planInSingleWConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P10") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanSingleIdx( 0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndIdentNode("A", "P01"))) .Get(); TryAssertion(epService, epl + "where P10 in ('A', P01)", planInSingleWConst); var planInSingleJustConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P10") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanSingleIdx( 0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndConstNode("A", "B"))) .Get(); TryAssertion(epService, epl + "where P10 in ('A', 'B')", planInSingleJustConst); }
public void Run(RegressionEnvironment env) { var types = new EventType[2]; var epl = "select * from SupportBean_S0 as S0 unidirectional, SupportBean_S1#keepall "; var fullTableScan = SupportQueryPlanBuilder.Start(2) .SetIndexFullTableScan(1, "a") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("a"))) .Get(); // 2-stream unidirectional joins TryAssertion(env, epl, fullTableScan); var planEquals = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P10") .SetLookupPlanInner( 0, new IndexedTableLookupPlanHashedOnlyForge( 0, 1, false, types, GetIndexKey("a"), new[] {SupportExprNodeFactory.MakeKeyed("P00")}, null, null, null)) .Get(); TryAssertion(env, epl + "where P00 = P10", planEquals); TryAssertion(env, epl + "where P00 = P10 and P00 in (P11, P12, P13)", planEquals); var planInMultiInner = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P11") .AddIndexHashSingleNonUnique(1, "b", "P12") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanMultiIdxForge(0, 1, false, types, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("P00"))) .Get(); TryAssertion(env, epl + "where P00 in (P11, P12)", planInMultiInner); TryAssertion(env, epl + "where P00 = P11 or P00 = P12", planInMultiInner); var planInMultiOuter = SupportQueryPlanBuilder.Start(planInMultiInner) .SetLookupPlanOuter( 0, new InKeywordTableLookupPlanMultiIdxForge(0, 1, false, types, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("P00"))) .Get(); var eplOuterJoin = "select * from SupportBean_S0 as S0 unidirectional full outer join SupportBean_S1#keepall "; TryAssertion(env, eplOuterJoin + "where P00 in (P11, P12)", planInMultiOuter); var planInMultiWConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P11") .AddIndexHashSingleNonUnique(1, "b", "P12") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanMultiIdxForge(0, 1, false, types, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeConstExprNode("A"))) .Get(); TryAssertion(env, epl + "where 'A' in (P11, P12)", planInMultiWConst); TryAssertion(env, epl + "where 'A' = P11 or 'A' = P12", planInMultiWConst); var planInMultiWAddConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P12") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanMultiIdxForge(0, 1, false, types, GetIndexKeys("a"), SupportExprNodeFactory.MakeConstExprNode("A"))) .Get(); TryAssertion(env, epl + "where 'A' in ('B', P12)", planInMultiWAddConst); TryAssertion(env, epl + "where 'A' in ('B', 'C')", fullTableScan); var planInSingle = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P10") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanSingleIdxForge( 0, 1, false, types, GetIndexKey("a"), SupportExprNodeFactory.MakeIdentExprNodes("P00", "P01"))) .Get(); TryAssertion(env, epl + "where P10 in (P00, P01)", planInSingle); var planInSingleWConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P10") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanSingleIdxForge( 0, 1, false, types, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndIdentNode("A", "P01"))) .Get(); TryAssertion(env, epl + "where P10 in ('A', P01)", planInSingleWConst); var planInSingleJustConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "P10") .SetLookupPlanInner( 0, new InKeywordTableLookupPlanSingleIdxForge( 0, 1, false, types, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndConstNode("A", "B"))) .Get(); TryAssertion(env, epl + "where P10 in ('A', 'B')", planInSingleJustConst); }
public void Run(RegressionEnvironment env) { var types = new EventType[3]; var epl = "@Name('s0') select * from SupportBean_S0 as S0 unidirectional, SupportBean_S1#keepall, SupportBean_S2#keepall "; // 3-stream join with in-multiindex directional var planInMidx = new InKeywordTableLookupPlanMultiIdxForge( 0, 1, false, types, GetIndexKeys("i1a", "i1b"), SupportExprNodeFactory.MakeIdentExprNode("P00")); TryAssertion( env, epl + " where P00 in (P10, P11)", SupportQueryPlanBuilder.Start(3) .AddIndexHashSingleNonUnique(1, "i1a", "P10") .AddIndexHashSingleNonUnique(1, "i1b", "P11") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction( 0, "S0", new[] { new LookupInstructionPlanForge(0, "S0", new[] {1}, new TableLookupPlanForge[] {planInMidx}, null, new bool[3]), new LookupInstructionPlanForge( 0, "S0", new[] {2}, new TableLookupPlanForge[] {new FullTableScanLookupPlanForge(1, 2, false, types, GetIndexKey("i2"))}, null, new bool[3]) }) .Get()); var planInMidxMulitiSrc = new InKeywordTableLookupPlanMultiIdxForge( 0, 1, false, types, GetIndexKeys("i1", "i2"), SupportExprNodeFactory.MakeIdentExprNode("P00")); TryAssertion( env, epl + " where P00 in (P10, P20)", SupportQueryPlanBuilder.Start(3) .SetIndexFullTableScan(1, "i1") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction( 0, "S0", new[] { new LookupInstructionPlanForge( 0, "S0", new[] {1}, new TableLookupPlanForge[] {new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i1"))}, null, new bool[3]), new LookupInstructionPlanForge( 0, "S0", new[] {2}, new TableLookupPlanForge[] {new FullTableScanLookupPlanForge(1, 2, false, types, GetIndexKey("i2"))}, null, new bool[3]) }) .Get()); // 3-stream join with in-singleindex directional var planInSidx = new InKeywordTableLookupPlanSingleIdxForge( 0, 1, false, types, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("P00", "P01")); TryAssertion(env, epl + " where P10 in (P00, P01)", GetSingleIndexPlan(types, planInSidx)); // 3-stream join with in-singleindex multi-sourced var planInSingleMultiSrc = new InKeywordTableLookupPlanSingleIdxForge( 0, 1, false, types, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("P00")); TryAssertion(env, epl + " where P10 in (P00, P20)", GetSingleIndexPlan(types, planInSingleMultiSrc)); }