private void RunAssertionInvalidAggMatchMultiFunc(EPServiceProvider epService) { // Window and related // // window vs agg method TryInvalidAggMatch(epService, "var1", "window(*) @Type(SupportBean)", true, "avg(IntPrimitive)", "Error starting statement: Incompatible aggregation function for table 'var1' column 'value', expecting 'window(*)' and received 'avg(IntPrimitive)': Not a 'window' aggregation ["); // window vs sorted TryInvalidAggMatch(epService, "var1", "window(*) @Type(SupportBean)", true, "sorted(IntPrimitive)", "Error starting statement: Failed to validate select-clause expression 'sorted(IntPrimitive)': When specifying into-table a sort expression cannot be provided ["); // wrong type TryInvalidAggMatch(epService, "var1", "window(*) @Type(SupportBean_S0)", true, "window(*)", "Error starting statement: Incompatible aggregation function for table 'var1' column 'value', expecting 'window(*)' and received 'window(*)': The required event type is 'SupportBean_S0' and provided is 'SupportBean' ["); // sorted // TryInvalidAggMatch(epService, "var1", "sorted(IntPrimitive) @Type(SupportBean)", true, "window(*)", "Error starting statement: Incompatible aggregation function for table 'var1' column 'value', expecting 'sorted(IntPrimitive)' and received 'window(*)': Not a 'sorted' aggregation ["); TryInvalidAggMatch(epService, "var1", "sorted(id) @Type(SupportBean_S0)", true, "sorted(IntPrimitive)", "Error starting statement: Failed to validate select-clause expression 'sorted(IntPrimitive)': When specifying into-table a sort expression cannot be provided ["); // plug-in // var config = new ConfigurationPlugInAggregationMultiFunction(SupportAggMFFuncExtensions.GetFunctionNames(), typeof(SupportAggMFFactory)); epService.EPAdministrator.Configuration.AddPlugInAggregationMultiFunction(config); TryInvalidAggMatch(epService, "var1", "se1() @Type(SupportBean)", true, "window(*)", "Error starting statement: Incompatible aggregation function for table 'var1' column 'value', expecting 'se1(*)' and received 'window(*)': Not a 'se1' aggregation ["); }
private void RunAssertionUngroupedAggAdditionalAndPlugin() { _epService.EPAdministrator.Configuration.AddPlugInAggregationFunctionFactory("concatstring", typeof(MyConcatAggregationFunctionFactory).FullName); var mfAggConfig = new ConfigurationPlugInAggregationMultiFunction(SupportAggMFFuncExtensions.GetFunctionNames(), typeof(SupportAggMFFactory).FullName); _epService.EPAdministrator.Configuration.AddPlugInAggregationMultiFunction(mfAggConfig); var cols = "c0,c1,c2,c3,c4,c5,c8,c9,c10,c11,c12,c13".Split(','); var epl = "select IntPrimitive, " + " countever(*, IntPrimitive>0, group_by:(TheString)) as c0," + " countever(*, IntPrimitive>0, group_by:()) as c1," + " countever(*, group_by:(TheString)) as c2," + " countever(*, group_by:()) as c3," + " concatstring(Convert.ToString(IntPrimitive), group_by:(TheString)) as c4," + " concatstring(Convert.ToString(IntPrimitive), group_by:()) as c5," + " sc(IntPrimitive, group_by:(TheString)) as c6," + " sc(IntPrimitive, group_by:()) as c7," + " leaving(group_by:(TheString)) as c8," + " leaving(group_by:()) as c9," + " rate(3, group_by:(TheString)) as c10," + " rate(3, group_by:()) as c11," + " nth(IntPrimitive, 1, group_by:(TheString)) as c12," + " nth(IntPrimitive, 1, group_by:()) as c13" + " from SupportBean as sb"; _epService.EPAdministrator.CreateEPL(epl).AddListener(_listener); MakeSendEvent("E1", 10); AssertScalarColl(_listener.LastNewData[0], new int?[] { 10 }, new int?[] { 10 }); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { 1L, 1L, 1L, 1L, "10", "10", false, false, null, null, null, null }); MakeSendEvent("E2", 20); AssertScalarColl(_listener.LastNewData[0], new int?[] { 20 }, new int?[] { 10, 20 }); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { 1L, 2L, 1L, 2L, "20", "10 20", false, false, null, null, null, 10 }); MakeSendEvent("E1", -1); AssertScalarColl(_listener.LastNewData[0], new int?[] { 10, -1 }, new int?[] { 10, 20, -1 }); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { 1L, 2L, 2L, 3L, "10 -1", "10 20 -1", false, false, null, null, 10, 20 }); MakeSendEvent("E2", 30); AssertScalarColl(_listener.LastNewData[0], new int?[] { 20, 30 }, new int?[] { 10, 20, -1, 30 }); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { 2L, 3L, 2L, 4L, "20 30", "10 20 -1 30", false, false, null, null, 20, -1 }); // plug-in aggregation function can also take other parameters _epService.EPAdministrator.CreateEPL("select sc(IntPrimitive, dummy:1)," + "concatstring(Convert.ToString(IntPrimitive), dummy2:(1,2,3)) from SupportBean"); _epService.EPAdministrator.DestroyAllStatements(); }