public void Run(RegressionEnvironment env) { SendTimeEvent(env, "2002-05-1T10:00:00.000"); var path = new RegressionPath(); var epl = "\n @Name('ctx') create context RuleActivityTime as start (0, 9, *, *, *) end (0, 17, *, *, *);" + "\n @Name('window') context RuleActivityTime create window EventsWindow#firstunique(ProductID) as SupportProductIdEvent;" + "\n @Name('variable') create variable boolean IsOutputTriggered_2 = false;" + "\n @Name('A') context RuleActivityTime insert into EventsWindow select * from SupportProductIdEvent(not exists (select * from EventsWindow));" + "\n @Name('B') context RuleActivityTime insert into EventsWindow select * from SupportProductIdEvent(not exists (select * from EventsWindow));" + "\n @Name('C') context RuleActivityTime insert into EventsWindow select * from SupportProductIdEvent(not exists (select * from EventsWindow));" + "\n @Name('D') context RuleActivityTime insert into EventsWindow select * from SupportProductIdEvent(not exists (select * from EventsWindow));" + "\n @Name('out') context RuleActivityTime select * from EventsWindow"; env.CompileDeploy(epl, path).AddListener("out"); env.SendEventBean(new SupportProductIdEvent("A1")); // invalid - subquery not the same context SupportMessageAssertUtil.TryInvalidCompile( env, path, "insert into EventsWindow select * from SupportProductIdEvent(not exists (select * from EventsWindow))", "Failed to validate subquery number 1 querying EventsWindow: Named window by name 'EventsWindow' has been declared for context 'RuleActivityTime' and can only be used within the same context"); env.UndeployAll(); }
private void RunAssertionContextVariable() { _epService.EPAdministrator.Configuration.AddImport(typeof(MyNonConstantServiceVariableFactory)); _epService.EPAdministrator.Configuration.AddImport(typeof(MyNonConstantServiceVariable)); _epService.EPAdministrator.CreateEPL("create context MyContext " + "initiated by SupportBean_S0 as c_s0 " + "terminated by SupportBean_S1(id=c_s0.id)"); _epService.EPAdministrator.CreateEPL("context MyContext " + "create variable MyNonConstantServiceVariable var = MyNonConstantServiceVariableFactory.Make()"); _epService.EPAdministrator.CreateEPL("context MyContext " + "select id as c0 from SupportBean(intPrimitive=context.c_s0.id) as sb, " + "method:var.FetchABean(intPrimitive) as h0").AddListener(_listener); _epService.EPAdministrator.CreateEPL("context MyContext on SupportBean_S2(id = context.c_s0.id) set var.Postfix=p20"); _epService.EPRuntime.SendEvent(new SupportBean_S0(1)); _epService.EPRuntime.SendEvent(new SupportBean_S0(2)); SendEventAssert("E1", 1, "_1_context_postfix"); SendEventAssert("E2", 2, "_2_context_postfix"); _epService.EPRuntime.SendEvent(new SupportBean_S2(1, "a")); _epService.EPRuntime.SendEvent(new SupportBean_S2(2, "b")); SendEventAssert("E1", 1, "_1_a"); SendEventAssert("E2", 2, "_2_b"); // invalid context SupportMessageAssertUtil.TryInvalid(_epService, "select * from method:var.FetchABean(intPrimitive) as h0", "Error starting statement: Variable by name 'var' has been declared for context 'MyContext' and can only be used within the same context"); _epService.EPAdministrator.CreateEPL("create context ABC start @now end after 1 minute"); SupportMessageAssertUtil.TryInvalid(_epService, "context ABC select * from method:var.FetchABean(intPrimitive) as h0", "Error starting statement: Variable by name 'var' has been declared for context 'MyContext' and can only be used within the same context"); }
public void TestUnidirectionalOuterJoin() { foreach (Type clazz in new Type[] { typeof(SupportBean_A), typeof(SupportBean_B), typeof(SupportBean_C) }) { _epService.EPAdministrator.Configuration.AddEventType(clazz); } // all: unidirectional and full-outer-join RunAssertion2Stream(); RunAssertion3Stream(); RunAssertion3StreamMixed(); RunAssertion4StreamWhereClause(); // no-view-declared SupportMessageAssertUtil.TryInvalid(_epService, "select * from SupportBean_A unidirectional full outer join SupportBean_B#keepall unidirectional", "Error starting statement: The unidirectional keyword requires that no views are declared onto the stream (applies to stream 1)"); // not-all-unidirectional SupportMessageAssertUtil.TryInvalid(_epService, "select * from SupportBean_A unidirectional full outer join SupportBean_B unidirectional full outer join SupportBean_C#keepall", "Error starting statement: The unidirectional keyword must either apply to a single stream or all streams in a full outer join"); // no iterate SupportMessageAssertUtil.TryInvalidIterate(_epService, "select * from SupportBean_A unidirectional full outer join SupportBean_B unidirectional", "Iteration over a unidirectional join is not supported"); }
private void RunAssertionDynamicDateFormat() { var epl = "select " + "cast(a,date,dateformat:b) as c0," + "cast(a,long,dateformat:b) as c1" + " from SupportBean_StringAlphabetic"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.AddListener(_listener); RunAssertionDynamicDateFormat("20100502", "yyyyMMdd"); RunAssertionDynamicDateFormat("20100502101112", "yyyyMMddhhmmss"); RunAssertionDynamicDateFormat(null, "yyyyMMdd"); // invalid date try { _epService.EPRuntime.SendEvent(new SupportBean_StringAlphabetic("x", "yyyyMMddhhmmss")); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessageContains(ex, "Exception parsing date 'x' format 'yyyyMMddhhmmss': String was not recognized as a valid DateTime"); } #if NO_ERROR_IN_CLR // invalid format try { _epService.EPRuntime.SendEvent(new SupportBean_StringAlphabetic("20100502", "UUHHYY")); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessageContains(ex, "Illegal pattern character 'U'"); } #endif stmt.Dispose(); }
public void TestCountMain() { var statementText = "select count(*) as cnt from " + typeof(SupportMarketDataBean).FullName + ".win:time(1)"; _selectTestView = _epService.EPAdministrator.CreateEPL(statementText); _selectTestView.AddListener(_listener); SendEvent("DELL", 1L); Assert.IsTrue(_listener.GetAndClearIsInvoked()); Assert.AreEqual(1, _listener.LastNewData.Length); Assert.AreEqual(1L, _listener.LastNewData[0].Get("cnt")); SendEvent("DELL", 1L); Assert.IsTrue(_listener.GetAndClearIsInvoked()); Assert.AreEqual(1, _listener.LastNewData.Length); Assert.AreEqual(2L, _listener.LastNewData[0].Get("cnt")); SendEvent("DELL", 1L); Assert.IsTrue(_listener.GetAndClearIsInvoked()); Assert.AreEqual(1, _listener.LastNewData.Length); Assert.AreEqual(3L, _listener.LastNewData[0].Get("cnt")); // test invalid distinct SupportMessageAssertUtil.TryInvalid(_epService, "select count(distinct *) from " + typeof(SupportMarketDataBean).FullName, "Error starting statement: Failed to validate select-clause expression 'count(distinct *)': Invalid use of the 'distinct' keyword with count and wildcard"); }
public void TestInvalidSyntax() { // keyword in select clause EPStatementException exception = GetSyntaxExceptionView("select inner from MyStream"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'inner' (a reserved keyword) at line 1 column 7, please check the select clause [select inner from MyStream]"); // keyword in from clause exception = GetSyntaxExceptionView("select something from Outer"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'Outer' (a reserved keyword) at line 1 column 22, please check the from clause [select something from Outer]"); // keyword used in package exception = GetSyntaxExceptionView("select * from com.true.mycompany.MyEvent"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'true' (a reserved keyword) expecting an identifier but found 'true' at line 1 column 18, please check the view specifications within the from clause [select * from com.true.mycompany.MyEvent]"); // keyword as part of identifier exception = GetSyntaxExceptionView("select * from MyEvent, MyEvent2 where a.day=b.day"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'day' (a reserved keyword) at line 1 column 40, please check the where clause [select * from MyEvent, MyEvent2 where a.day=b.day]"); exception = GetSyntaxExceptionView("select * * from " + EVENT_NUM); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near '*' at line 1 column 9 near reserved keyword 'from' [select * * from " + Name.Of <SupportBean_N>() + "]"); // keyword in select clause exception = GetSyntaxExceptionView("select day from MyEvent, MyEvent2"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'day' (a reserved keyword) at line 1 column 7, please check the select clause [select day from MyEvent, MyEvent2]"); }
public void RunAssertionInvalidSubquery(bool namedWindow) { string eplCreate = namedWindow ? "create window MyInfra.win:keepall() as " + typeof(SupportBean).FullName : "create table MyInfra(TheString string)"; epService.EPAdministrator.CreateEPL(eplCreate); try { epService.EPAdministrator.CreateEPL("select (select TheString from MyInfra.std:lastevent()) from MyInfra"); Assert.Fail(); } catch (EPException ex) { if (namedWindow) { Assert.AreEqual("Error starting statement: Failed to plan subquery number 1 querying MyInfra: Consuming statements to a named window cannot declare a data window view onto the named window [select (select TheString from MyInfra.std:lastevent()) from MyInfra]", ex.Message); } else { SupportMessageAssertUtil.AssertMessage(ex, "Views are not supported with tables"); } } epService.EPAdministrator.DestroyAllStatements(); epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false); }
public void TestInvalid() { string stmtText; SupportMessageAssertUtil.TryInvalid(_epService, "", "Unexpected end-of-input []"); stmtText = "select (select sum(s0.id) from S1#length(3) as s1) as value from S0 as s0"; SupportMessageAssertUtil.TryInvalid(_epService, stmtText, "Error starting statement: Failed to plan subquery number 1 querying S1: Subselect aggregation functions cannot aggregate across correlated properties"); stmtText = "select (select s1.id + sum(s1.id) from S1#length(3) as s1) as value from S0 as s0"; SupportMessageAssertUtil.TryInvalid(_epService, stmtText, "Error starting statement: Failed to plan subquery number 1 querying S1: Subselect properties must all be within aggregation functions"); stmtText = "select (select sum(s0.id + s1.id) from S1#length(3) as s1) as value from S0 as s0"; SupportMessageAssertUtil.TryInvalid(_epService, stmtText, "Error starting statement: Failed to plan subquery number 1 querying S1: Subselect aggregation functions cannot aggregate across correlated properties"); // having-clause cannot aggregate over properties from other streams stmtText = "select (select last(theString) from SupportBean#keepall having sum(s0.p00) = 1) as c0 from S0 as s0"; SupportMessageAssertUtil.TryInvalid(_epService, stmtText, "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Failed to validate having-clause expression '(sum(s0.p00))=1': Implicit conversion from datatype 'String' to numeric is not allowed for aggregation function 'sum' ["); // having-clause properties must be aggregated stmtText = "select (select last(theString) from SupportBean#keepall having sum(intPrimitive) = intPrimitive) as c0 from S0 as s0"; SupportMessageAssertUtil.TryInvalid(_epService, stmtText, "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Subselect having-clause requires that all properties are under aggregation, consider using the 'first' aggregation function instead"); // having-clause not returning boolean stmtText = "select (select last(theString) from SupportBean#keepall having sum(intPrimitive)) as c0 from S0"; SupportMessageAssertUtil.TryInvalid(_epService, stmtText, "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Subselect having-clause expression must return a boolean value "); }
private static void TryInvalidDeploy( RegressionEnvironment env, EPCompiled compiled, string text, string moduleName) { var message = "A precondition is not satisfied: " + text + " has already been created for module '" + moduleName + "'"; try { env.Runtime.DeploymentService.Deploy(compiled); Assert.Fail(); } catch (EPDeployPreconditionException ex) { Assert.That(ex.RolloutItemNumber, Is.EqualTo(-1)); if (!message.Equals("skip")) { SupportMessageAssertUtil.AssertMessage(ex.Message, message); } } catch (EPDeployException) { Assert.Fail(); } }
public void TestFilters() { epService.EPAdministrator.CreateEPL("create table MyTable(pkey string primary key, col0 int)"); epService.EPAdministrator.CreateEPL("insert into MyTable select TheString as pkey, IntPrimitive as col0 from SupportBean"); for (int i = 0; i < 5; i++) { epService.EPRuntime.SendEvent(new SupportBean("E" + i, i)); } string[] fields = "col0".Split(','); // test FAF filter EventBean[] events = epService.EPRuntime.ExecuteQuery("select col0 from MyTable(pkey='E1')").Array; EPAssertionUtil.AssertPropsPerRow(events, fields, new object[][] { new object[] { 1 } }); // test iterate EPStatement stmtIterate = epService.EPAdministrator.CreateEPL("select col0 from MyTable(pkey='E2')"); EPAssertionUtil.AssertPropsPerRow(stmtIterate.GetEnumerator(), fields, new object[][] { new object[] { 2 } }); stmtIterate.Dispose(); // test subquery EPStatement stmtSubquery = epService.EPAdministrator.CreateEPL("select (select col0 from MyTable(pkey='E3')) as col0 from SupportBean_S0"); stmtSubquery.AddListener(listener); epService.EPRuntime.SendEvent(new SupportBean_S0(0)); Assert.AreEqual(3, listener.AssertOneGetNewAndReset().Get("col0")); stmtSubquery.Dispose(); // test join SupportMessageAssertUtil.TryInvalid(epService, "select col0 from SupportBean_S0, MyTable(pkey='E4')", "Error starting statement: Joins with tables do not allow table filter expressions, please add table filters to the where-clause instead ["); }
public void TestInvalid() { String stmt = "create variable somedummy myvar = 10"; SupportMessageAssertUtil.TryInvalid( _epService, stmt, "Error starting statement: Cannot create variable: Cannot create variable 'myvar', type 'somedummy' is not a recognized type [create variable somedummy myvar = 10]"); stmt = "create variable string myvar = 5"; SupportMessageAssertUtil.TryInvalid( _epService, stmt, "Error starting statement: Cannot create variable: Variable 'myvar' of declared type System.String cannot be initialized by a value of type " + typeof(int).FullName + " [create variable string myvar = 5]"); stmt = "create variable string myvar = 'a'"; _epService.EPAdministrator.CreateEPL("create variable string myvar = 'a'"); SupportMessageAssertUtil.TryInvalid( _epService, stmt, "Error starting statement: Cannot create variable: Variable by name 'myvar' has already been created [create variable string myvar = 'a']"); SupportMessageAssertUtil.TryInvalid( _epService, "select * from " + Name.Of <SupportBean>() + " output every somevar events", "Error starting statement: Error in the output rate limiting clause: Variable named 'somevar' has not been declared ["); }
public override void Run(EPServiceProvider epService) { RunAssertionMultirowGroupedNoDataWindowUncorrelated(epService); RunAssertionMultirowGroupedNamedWindowSubqueryIndexShared(epService); RunAssertionMultirowGroupedUncorrelatedIteratorAndExpressionDef(epService); RunAssertionMultirowGroupedCorrelatedWithEnumMethod(epService); RunAssertionMultirowGroupedUncorrelatedWithEnumerationMethod(epService); RunAssertionMultirowGroupedCorrelatedWHaving(epService); RunAssertionMulticolumnGroupedUncorrelatedUnfiltered(epService); RunAssertionMulticolumnGroupedContextPartitioned(epService); RunAssertionMulticolumnGroupedWHaving(epService); // Invalid tests string epl; // not fully aggregated epl = "select (select TheString, sum(LongPrimitive) from SupportBean#keepall group by IntPrimitive) from S0"; SupportMessageAssertUtil.TryInvalid(epService, epl, "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Subselect with group-by requires non-aggregated properties in the select-clause to also appear in the group-by clause [select (select TheString, sum(LongPrimitive) from SupportBean#keepall group by IntPrimitive) from S0]"); // correlated group-by not allowed epl = "select (select TheString, sum(LongPrimitive) from SupportBean#keepall group by TheString, s0.id) from S0 as s0"; SupportMessageAssertUtil.TryInvalid(epService, epl, "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Subselect with group-by requires that group-by properties are provided by the subselect stream only (property 'id' is not) [select (select TheString, sum(LongPrimitive) from SupportBean#keepall group by TheString, s0.id) from S0 as s0]"); epl = "select (select TheString, sum(LongPrimitive) from SupportBean#keepall group by TheString, s0.get_P00()) from S0 as s0"; SupportMessageAssertUtil.TryInvalid(epService, epl, "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Subselect with group-by requires that group-by properties are provided by the subselect stream only (expression 's0.get_P00()' against stream 1 is not)"); // aggregations not allowed in group-by epl = "select (select IntPrimitive, sum(LongPrimitive) from SupportBean#keepall group by sum(IntPrimitive)) from S0 as s0"; SupportMessageAssertUtil.TryInvalid(epService, epl, "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Group-by expressions in a subselect may not have an aggregation function [select (select IntPrimitive, sum(LongPrimitive) from SupportBean#keepall group by sum(IntPrimitive)) from S0 as s0]"); // "prev" not allowed in group-by epl = "select (select IntPrimitive, sum(LongPrimitive) from SupportBean#keepall group by prev(1, IntPrimitive)) from S0 as s0"; SupportMessageAssertUtil.TryInvalid(epService, epl, "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Group-by expressions in a subselect may not have a function that requires view resources (prior, prev) [select (select IntPrimitive, sum(LongPrimitive) from SupportBean#keepall group by prev(1, IntPrimitive)) from S0 as s0]"); }
public override void Run(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddVariable("MyConstantServiceVariable", typeof(MyConstantServiceVariable), new MyConstantServiceVariable()); RunAssertionConstantVariable(epService); epService.EPAdministrator.Configuration.AddVariable("MyNonConstantServiceVariable", typeof(MyNonConstantServiceVariable), new MyNonConstantServiceVariable("postfix")); TryAssertionNonConstantVariable(epService, false); TryAssertionNonConstantVariable(epService, true); RunAssertionContextVariable(epService); RunAssertionVariableMapAndOA(epService); // invalid footprint SupportMessageAssertUtil.TryInvalid(epService, "select * from method:MyConstantServiceVariable.FetchABean() as h0", "Error starting statement: Method footprint does not match the number or type of expression parameters, expecting no parameters in method: Could not find enumeration method, date-time method or instance method named 'FetchABean' in class 'com.espertech.esper.regression.epl.fromclausemethod.ExecFromClauseMethodVariable+MyConstantServiceVariable' taking no parameters (nearest match found was 'FetchABean' taking type(s) 'System.Int32') ["); // null variable value and metadata is instance method epService.EPAdministrator.Configuration.AddVariable("MyNullMap", typeof(MyMethodHandlerMap), null); SupportMessageAssertUtil.TryInvalid(epService, "select field1, field2 from method:MyNullMap.GetMapData", "Error starting statement: Failed to access variable method invocation metadata: The variable value is null and the metadata method is an instance method"); // variable with context and metadata is instance method epService.EPAdministrator.CreateEPL("create context BetweenStartAndEnd start SupportBean end SupportBean"); epService.EPAdministrator.CreateEPL("context BetweenStartAndEnd create variable " + TypeHelper.MaskTypeName <MyMethodHandlerMap>() + " themap"); SupportMessageAssertUtil.TryInvalid(epService, "context BetweenStartAndEnd select field1, field2 from method:themap.GetMapData", "Error starting statement: Failed to access variable method invocation metadata: The metadata method is an instance method however the variable is contextual, please declare the metadata method as static or remove the context declaration for the variable"); }
public void Run(RegressionEnvironment env) { var epl = "@Name('mywindow') create window PointWindow#keepall as SupportSpatialPoint;\n" + "insert into PointWindow select * from SupportSpatialPoint;\n" + "create index MyIndex on PointWindow((Px, Py) pointregionquadtree(0, 0, 100, 100));\n"; env.CompileDeploy(epl); try { env.SendEventBean(new SupportSpatialPoint("E1", null, null)); } catch (Exception ex) { SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'mywindow': Invalid value for index 'MyIndex' column 'x' received null and expected non-null"); } try { env.SendEventBean(new SupportSpatialPoint("E1", 200d, 200d)); } catch (Exception ex) { SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'mywindow': Invalid value for index 'MyIndex' column '(X,Y)' received (200.0d,200.0d) and expected a value within index bounding box (range-end-non-inclusive) {MinX=0.0d, MinY=0.0d, MaxX=100.0d, MaxY=100.0d}"); } env.UndeployAll(); }
private void RunAssertionCount(EPServiceProvider epService) { string statementText = "select count(*) as cnt from " + typeof(SupportMarketDataBean).FullName + "#time(1)"; EPStatement stmt = epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendEvent(epService, "DELL", 1L); Assert.IsTrue(listener.GetAndClearIsInvoked()); Assert.AreEqual(1, listener.LastNewData.Length); Assert.AreEqual(1L, listener.LastNewData[0].Get("cnt")); SendEvent(epService, "DELL", 1L); Assert.IsTrue(listener.GetAndClearIsInvoked()); Assert.AreEqual(1, listener.LastNewData.Length); Assert.AreEqual(2L, listener.LastNewData[0].Get("cnt")); SendEvent(epService, "DELL", 1L); Assert.IsTrue(listener.GetAndClearIsInvoked()); Assert.AreEqual(1, listener.LastNewData.Length); Assert.AreEqual(3L, listener.LastNewData[0].Get("cnt")); // test invalid distinct SupportMessageAssertUtil.TryInvalid(epService, "select count(distinct *) from " + typeof(SupportMarketDataBean).FullName, "Error starting statement: Failed to validate select-clause expression 'count(distinct *)': Invalid use of the 'distinct' keyword with count and wildcard"); stmt.Dispose(); }
public void Run(RegressionEnvironment env) { SupportMessageAssertUtil.TryInvalidCompile( env, "select * from SupportBean#rank(1, IntPrimitive desc)", "Failed to validate data window declaration: Rank view requires a list of expressions providing unique keys, a numeric size parameter and a list of expressions providing sort keys [select * from SupportBean#rank(1, IntPrimitive desc)]"); SupportMessageAssertUtil.TryInvalidCompile( env, "select * from SupportBean#rank(1, IntPrimitive, TheString desc)", "Failed to validate data window declaration: Failed to find unique value expressions that are expected to occur before the numeric size parameter [select * from SupportBean#rank(1, IntPrimitive, TheString desc)]"); SupportMessageAssertUtil.TryInvalidCompile( env, "select * from SupportBean#rank(TheString, IntPrimitive, 1)", "Failed to validate data window declaration: Failed to find sort key expressions after the numeric size parameter [select * from SupportBean#rank(TheString, IntPrimitive, 1)]"); SupportMessageAssertUtil.TryInvalidCompile( env, "select * from SupportBean#rank(TheString, IntPrimitive, TheString desc)", "Failed to validate data window declaration: Failed to find constant value for the numeric size parameter [select * from SupportBean#rank(TheString, IntPrimitive, TheString desc)]"); SupportMessageAssertUtil.TryInvalidCompile( env, "select * from SupportBean#rank(TheString, 1, 1, IntPrimitive, TheString desc)", "Failed to validate data window declaration: Invalid view parameter expression 2 for Rank view, the expression returns a constant result value, are you sure? [select * from SupportBean#rank(TheString, 1, 1, IntPrimitive, TheString desc)]"); SupportMessageAssertUtil.TryInvalidCompile( env, "select * from SupportBean#rank(TheString, IntPrimitive, 1, IntPrimitive, 1, TheString desc)", "Failed to validate data window declaration: Invalid view parameter expression 4 for Rank view, the expression returns a constant result value, are you sure? [select * from SupportBean#rank(TheString, IntPrimitive, 1, IntPrimitive, 1, TheString desc)]"); }
public void Run(RegressionEnvironment env) { string epl; // invalid initiated-by type epl = "create context InvalidCtx partition by TheString from SupportBean initiated by SupportBean_S0"; SupportMessageAssertUtil.TryInvalidCompile( env, epl, "Segmented context 'InvalidCtx' requires that all of the event types that are listed in the initialized-by also appear in the partition-by, type 'SupportBean_S0' is not one of the types listed in partition-by"); // cannot assign name in different places epl = "create context InvalidCtx partition by P00 from SupportBean_S0 as n1 initiated by SupportBean_S0 as n2"; SupportMessageAssertUtil.TryInvalidCompile( env, epl, "Segmented context 'InvalidCtx' requires that either partition-by or initialized-by assign stream names, but not both"); // name assigned is already used var message = "Name 'a' already used for type 'SupportBean_S0'"; epl = "create context InvalidCtx partition by P00 from SupportBean_S0, P10 from SupportBean_S1 initiated by SupportBean_S0 as a, SupportBean_S1 as a"; SupportMessageAssertUtil.TryInvalidCompile(env, epl, message); epl = "create context InvalidCtx partition by P00 from SupportBean_S0 as a, P10 from SupportBean_S1 as a"; SupportMessageAssertUtil.TryInvalidCompile(env, epl, message); }
public void TestInvalid() { SupportMessageAssertUtil.TryInvalid(_epService, "@Hint('enable_outputlimit_opt') select sum(IntPrimitive) " + "from SupportBean output last every 4 events order by TheString", "Error starting statement: Error in the output rate limiting clause: The ENABLE_OUTPUTLIMIT_OPT hint is not supported with order-by"); }
private void TryAssertionInvalid(EPServiceProvider epService, EventRepresentationChoice rep) { epService.EPAdministrator.CreateEPL( "create " + rep.GetOutputTypeCreateSchemaName() + " schema Src as (myint int, mystr string)"); // mismatch in type epService.EPAdministrator.CreateEPL( "create " + rep.GetOutputTypeCreateSchemaName() + " schema E1 as (myint long)"); var message = !rep.IsAvroEvent() ? "Error starting statement: Type by name 'E1' in property 'myint' expected " + Name.Clean<int>() + " but receives " + Name.Clean<long>() : "Error starting statement: Type by name 'E1' in property 'myint' expected schema '{\"type\":\"long\"}' but received schema '{\"type\":\"int\"}'"; SupportMessageAssertUtil.TryInvalid(epService, "insert into E1 select mysrc.* from Src as mysrc", message); // mismatch in column name epService.EPAdministrator.CreateEPL( "create " + rep.GetOutputTypeCreateSchemaName() + " schema E2 as (someprop long)"); SupportMessageAssertUtil.TryInvalid( epService, "insert into E2 select mysrc.*, 1 as otherprop from Src as mysrc", "Error starting statement: Failed to find column 'otherprop' in target type 'E2' [insert into E2 select mysrc.*, 1 as otherprop from Src as mysrc]"); epService.EPAdministrator.DestroyAllStatements(); foreach (var name in Collections.List("Src", "E1", "E2")) { epService.EPAdministrator.Configuration.RemoveEventType(name, false); } }
private static void RunAssertionDynamicDateFormat(RegressionEnvironment env) { var fields = "c0,c1,c2,c3".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean_StringAlphabetic") .WithExpression(fields[0], "cast(A,long,dateformat:B)") .WithExpression(fields[1], "cast(A,datetime,dateformat:B)") .WithExpression(fields[2], "cast(A,datetimeoffset,dateformat:B)") .WithExpression(fields[3], "cast(A,dtx,dateformat:B)"); AssertDynamicDateFormat(builder, fields, "20100502", "yyyyMMdd"); AssertDynamicDateFormat(builder, fields, "20100502101112", "yyyyMMddhhmmss"); AssertDynamicDateFormat(builder, fields, null, "yyyyMMdd"); builder.Run(env); // invalid date try { env.SendEventBean(new SupportBean_StringAlphabetic("x", "yyyyMMddhhmmss")); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessageContains(ex, "Exception parsing date 'x' format 'yyyyMMddhhmmss': Unparseable date: \"x\""); } // invalid format try { env.SendEventBean(new SupportBean_StringAlphabetic("20100502", "UUHHYY")); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessageContains(ex, "Illegal pattern character 'U'"); } env.UndeployAll(); }
private void RunAssertionInvalid(EPServiceProvider epService) { var template = "select * from SupportBean " + "match_recognize (" + " measures A as a" + " pattern (REPLACE) " + ")"; epService.EPAdministrator.CreateEPL("create variable int myvariable = 0"); SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{}"), "Invalid match-recognize quantifier '{}', expecting an expression"); SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{null}"), "Error starting statement: pattern quantifier 'null' must return an integer-type value"); SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{myvariable}"), "Error starting statement: pattern quantifier 'myvariable' must return a constant value"); SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{prev(A)}"), "Error starting statement: Invalid match-recognize pattern expression 'prev(A)': Aggregation, sub-select, previous or prior functions are not supported in this context"); var expected = "Error starting statement: Invalid pattern quantifier value -1, expecting a minimum of 1"; SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{-1}"), expected); SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{,-1}"), expected); SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{-1,10}"), expected); SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{-1,}"), expected); SupportMessageAssertUtil.TryInvalid(epService, template.RegexReplaceAll("REPLACE", "A{5,3}"), "Error starting statement: Invalid pattern quantifier value 5, expecting a minimum of 1 and maximum of 3"); }
private void RunAssertionInvalid(EventRepresentationChoice eventRepresentationEnum) { string expectedOne = !eventRepresentationEnum.IsAvroEvent() ? "Error starting statement: Nestable type configuration encountered an unexpected property type name 'xxxx' for property 'col1', expected Type or DataMap or the name of a previously-declared Map or ObjectArray type [" : "Error starting statement: Type definition encountered an unexpected property type name 'xxxx' for property 'col1', expected the name of a previously-declared Avro type"; SupportMessageAssertUtil.TryInvalid(epService, eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col1 xxxx)", expectedOne); SupportMessageAssertUtil.TryInvalid(epService, eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col1 int, col1 string)", "Error starting statement: Duplicate column name 'col1' ["); epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col1 string)"); string expectedTwo = !eventRepresentationEnum.IsAvroEvent() ? "Error starting statement: Event type named 'MyEventType' has already been declared with differing column name or type information: Type by name 'MyEventType' expects 1 properties but receives 2 properties [" : "Error starting statement: Event type named 'MyEventType' has already been declared with differing column name or type information: Type by name 'MyEventType' is not a compatible type (target type underlying is '" + AvroConstantsNoDep.GENERIC_RECORD_CLASSNAME + "')"; SupportMessageAssertUtil.TryInvalid(epService, "create schema MyEventType as (col1 string, col2 string)", expectedTwo); SupportMessageAssertUtil.TryInvalid(epService, eventRepresentationEnum.GetAnnotationText() + " create schema MyEventTypeT1 as () inherit ABC", "Error in expression: Expected 'inherits', 'starttimestamp', 'endtimestamp' or 'copyfrom' keyword after create-schema clause but encountered 'inherit' ["); SupportMessageAssertUtil.TryInvalid(epService, eventRepresentationEnum.GetAnnotationText() + " create schema MyEventTypeT2 as () inherits ABC", "Error starting statement: Supertype by name 'ABC' could not be found ["); SupportMessageAssertUtil.TryInvalid(epService, eventRepresentationEnum.GetAnnotationText() + " create schema MyEventTypeT3 as () inherits", "Incorrect syntax near end-of-input expecting an identifier but found end-of-input at line 1 column "); epService.EPAdministrator.Configuration.RemoveEventType("MyEventType", true); }
public void Run(RegressionEnvironment env) { string epl; epl = "select case when true then new { col1 = 'a' } else 1 end from SupportBean"; SupportMessageAssertUtil.TryInvalidCompile( env, epl, "Failed to validate select-clause expression 'case when true then new{col1=\"a\"} e...(44 chars)': Case node 'when' expressions require that all results either return a single value or a Map-type (new-operator) value, check the else-condition [select case when true then new { col1 = 'a' } else 1 end from SupportBean]"); epl = "select case when true then new { col1 = 'a' } when false then 1 end from SupportBean"; SupportMessageAssertUtil.TryInvalidCompile( env, epl, "Failed to validate select-clause expression 'case when true then new{col1=\"a\"} w...(55 chars)': Case node 'when' expressions require that all results either return a single value or a Map-type (new-operator) value, check when-condition number 1 [select case when true then new { col1 = 'a' } when false then 1 end from SupportBean]"); epl = "select case when true then new { col1 = 'a' } else new { col1 = 1 } end from SupportBean"; SupportMessageAssertUtil.TryInvalidCompile( env, epl, "Failed to validate select-clause expression 'case when true then new{col1=\"a\"} e...(54 chars)': Incompatible case-when return types by new-operator in case-when number 1: Type by name 'Case-when number 1' in property 'col1' expected System.String but receives System.Nullable<System.Int32> [select case when true then new { col1 = 'a' } else new { col1 = 1 } end from SupportBean]"); epl = "select case when true then new { col1 = 'a' } else new { col2 = 'a' } end from SupportBean"; SupportMessageAssertUtil.TryInvalidCompile( env, epl, "Failed to validate select-clause expression 'case when true then new{col1=\"a\"} e...(56 chars)': Incompatible case-when return types by new-operator in case-when number 1: The property 'col1' is not provided but required [select case when true then new { col1 = 'a' } else new { col2 = 'a' } end from SupportBean]"); epl = "select case when true then new { col1 = 'a', col1 = 'b' } end from SupportBean"; SupportMessageAssertUtil.TryInvalidCompile( env, epl, "Failed to validate select-clause expression 'case when true then new{col1=\"a\",co...(46 chars)': Failed to validate new-keyword property names, property 'col1' has already been declared [select case when true then new { col1 = 'a', col1 = 'b' } end from SupportBean]"); }
public void TestInvalidExceptionList() { var moduleOne = MakeModule("mymodule.one", "create schema MySchemaOne (col1 Wrong)", "create schema MySchemaOne (col2 WrongTwo)"); try { var options = new DeploymentOptions(); options.IsFailFast = false; _deploymentAdmin.Deploy(moduleOne, options); Assert.Fail(); } catch (DeploymentActionException ex) { Assert.AreEqual("Deployment failed in module 'mymodule.one' in expression 'create schema MySchemaOne (col1 Wrong)' : Error starting statement: Nestable type configuration encountered an unexpected property type name 'Wrong' for property 'col1', expected Type or DataMap or the name of a previously-declared Map or ObjectArray type [create schema MySchemaOne (col1 Wrong)]", ex.Message); Assert.AreEqual(2, ex.Exceptions.Count); Assert.AreEqual("create schema MySchemaOne (col1 Wrong)", ex.Exceptions[0].Expression); Assert.AreEqual("Error starting statement: Nestable type configuration encountered an unexpected property type name 'Wrong' for property 'col1', expected Type or DataMap or the name of a previously-declared Map or ObjectArray type [create schema MySchemaOne (col1 Wrong)]", ex.Exceptions[0].Inner.Message); Assert.AreEqual("create schema MySchemaOne (col2 WrongTwo)", ex.Exceptions[1].Expression); Assert.AreEqual("Error starting statement: Nestable type configuration encountered an unexpected property type name 'WrongTwo' for property 'col2', expected Type or DataMap or the name of a previously-declared Map or ObjectArray type [create schema MySchemaOne (col2 WrongTwo)]", ex.Exceptions[1].Inner.Message); } // test newline as part of the failing expression - replaced by space try { _deploymentAdmin.ParseDeploy("XX\nX"); Assert.Fail(); } catch (DeploymentException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Compilation failed in expression 'XX X' : Incorrect syntax near 'XX' ["); } }
public void Run(RegressionEnvironment env) { var epl = "@Name('win') create window MyRectWindow#keepall as (Id string, rx double, ry double, rw double, rh double);\n" + "@Name('insert') insert into MyRectWindow select Id, X as rx, Y as ry, Width as rw, Height as rh from SupportSpatialEventRectangle;\n" + "@Name('Idx') create unique index Idx on MyRectWindow( (rx, ry, rw, rh) mxcifquadtree(0, 0, 100, 100));\n" + IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "@Name('out') on SupportSpatialAABB select mpw.Id as c0 from MyRectWindow as mpw where rectangle(rx, ry, rw, rh).intersects(rectangle(X, Y, Width, Height));\n"; env.CompileDeploy(epl).AddListener("out"); SupportQueryPlanIndexHook.AssertOnExprTableAndReset( "Idx", "unique hash={} btree={} advanced={mxcifquadtree(rx,ry,rw,rh)}"); SendEventRectangle(env, "P1", 10, 15, 1, 2); try { SendEventRectangle(env, "P1", 10, 15, 1, 2); Assert.Fail(); } catch (Exception ex) { // we have a handler SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'win': Unique index violation, index 'Idx' is a unique index and key '(10.0d,15.0d,1.0d,2.0d)' already exists"); } env.UndeployAll(); }
public override void Run(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); var currentTime = new AtomicLong(0); SendTime(epService, currentTime.Get()); // unaggregated and ungrouped // TryAssertion(epService, currentTime, 0, false, "IntPrimitive", null, null, "last", null); TryAssertion(epService, currentTime, 0, false, "IntPrimitive", null, null, "last", "order by IntPrimitive"); TryAssertion(epService, currentTime, 5, false, "IntPrimitive", null, null, "all", null); TryAssertion(epService, currentTime, 0, true, "IntPrimitive", null, null, "all", null); TryAssertion(epService, currentTime, 0, false, "IntPrimitive", null, null, "first", null); // fully-aggregated and ungrouped TryAssertion(epService, currentTime, 5, false, "count(*)", null, null, "last", null); TryAssertion(epService, currentTime, 0, true, "count(*)", null, null, "last", null); TryAssertion(epService, currentTime, 5, false, "count(*)", null, null, "all", null); TryAssertion(epService, currentTime, 0, true, "count(*)", null, null, "all", null); TryAssertion(epService, currentTime, 0, false, "count(*)", null, null, "first", null); TryAssertion(epService, currentTime, 0, false, "count(*)", null, "having count(*) > 0", "first", null); // aggregated and ungrouped TryAssertion(epService, currentTime, 5, false, "TheString, count(*)", null, null, "last", null); TryAssertion(epService, currentTime, 0, true, "TheString, count(*)", null, null, "last", null); TryAssertion(epService, currentTime, 5, false, "TheString, count(*)", null, null, "all", null); TryAssertion(epService, currentTime, 0, true, "TheString, count(*)", null, null, "all", null); TryAssertion(epService, currentTime, 0, true, "TheString, count(*)", null, null, "first", null); TryAssertion(epService, currentTime, 0, true, "TheString, count(*)", null, "having count(*) > 0", "first", null); // fully-aggregated and grouped TryAssertion(epService, currentTime, 5, false, "TheString, count(*)", "group by TheString", null, "last", null); TryAssertion(epService, currentTime, 0, true, "TheString, count(*)", "group by TheString", null, "last", null); TryAssertion(epService, currentTime, 5, false, "TheString, count(*)", "group by TheString", null, "all", null); TryAssertion(epService, currentTime, 0, true, "TheString, count(*)", "group by TheString", null, "all", null); TryAssertion(epService, currentTime, 0, false, "TheString, count(*)", "group by TheString", null, "first", null); // aggregated and grouped TryAssertion(epService, currentTime, 5, false, "TheString, IntPrimitive, count(*)", "group by TheString", null, "last", null); TryAssertion(epService, currentTime, 0, true, "TheString, IntPrimitive, count(*)", "group by TheString", null, "last", null); TryAssertion(epService, currentTime, 5, false, "TheString, IntPrimitive, count(*)", "group by TheString", null, "all", null); TryAssertion(epService, currentTime, 0, false, "TheString, IntPrimitive, count(*)", "group by TheString", null, "first", null); SupportMessageAssertUtil.TryInvalid(epService, "@Hint('enable_outputlimit_opt') select sum(IntPrimitive) " + "from SupportBean output last every 4 events order by TheString", "Error starting statement: Error in the output rate limiting clause: The ENABLE_OUTPUTLIMIT_OPT hint is not supported with order-by"); }
private void RunAssertionEventInvalidProp(EventBean @event) { foreach (var prop in Arrays.AsList("xxxx", "MyString('a')", "x.y", "MyString.x")) { SupportMessageAssertUtil.TryInvalidProperty(@event, prop); SupportMessageAssertUtil.TryInvalidGetFragment(@event, prop); } }
private void RunAssertionEventInvalidProp(EventBean @event) { foreach (var prop in Arrays.AsList("L2", "L1.L3", "L1.xxx", "L1.L2.x", "L1.L2.L3.x", "L1.Lvl1.x")) { SupportMessageAssertUtil.TryInvalidProperty(@event, prop); SupportMessageAssertUtil.TryInvalidGetFragment(@event, prop); } }
public void TestInvalidInsertInto() { SupportMessageAssertUtil.TryInvalid(_epService, "insert into RevQuote select * from " + Name.Of <SupportBean>(), "Error starting statement: Selected event type is not a valid base or delta event type of revision event type 'RevisableQuote' ["); SupportMessageAssertUtil.TryInvalid(_epService, "insert into RevQuote select intPrimitive as k0 from " + Name.Of <SupportBean>(), "Error starting statement: Selected event type is not a valid base or delta event type of revision event type 'RevisableQuote' "); }
private static void TryInvalidCompileQuery( RegressionEnvironment env, RegressionPath path, string epl, string expected) { SupportMessageAssertUtil.TryInvalidFAFCompile(env, path, epl, expected); }