Exemplo n.º 1
0
        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 ");
        }
Exemplo n.º 2
0
        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 void RunAssertionInvalid(EPServiceProvider epService)
        {
            // invalid filter expression name parameter: multiple values
            SupportMessageAssertUtil.TryInvalid(
                epService, "select sum(IntPrimitive, filter:(IntPrimitive, DoublePrimitive)) from SupportBean",
                "Error starting statement: Failed to validate select-clause expression 'sum(IntPrimitive,filter:(IntPrimiti...(55 chars)': Filter named parameter requires a single expression returning a boolean-typed value");

            // multiple filter expressions
            SupportMessageAssertUtil.TryInvalid(
                epService, "select sum(IntPrimitive, IntPrimitive > 0, filter:IntPrimitive < 0) from SupportBean",
                "Error starting statement: Failed to validate select-clause expression 'sum(IntPrimitive,IntPrimitive>0,fil...(54 chars)': Only a single filter expression can be provided");

            // invalid filter expression name parameter: not returning boolean
            SupportMessageAssertUtil.TryInvalid(
                epService, "select sum(IntPrimitive, filter:IntPrimitive) from SupportBean",
                "Error starting statement: Failed to validate select-clause expression 'sum(IntPrimitive,filter:IntPrimitive)': Filter named parameter requires a single expression returning a boolean-typed value");

            // create-table does not allow filters
            SupportMessageAssertUtil.TryInvalid(
                epService, "create table MyTable(totals sum(int, filter:true))",
                "Error starting statement: Failed to validate table-column expression 'sum(int,filter:true)': The 'group_by' and 'filter' parameter is not allowed in create-table statements");

            // invalid correlated subquery
            SupportMessageAssertUtil.TryInvalid(
                epService,
                "select (select sum(IntPrimitive, filter:s0.p00='a') from SupportBean) from SupportBean_S0 as s0",
                "Error starting statement: Failed to plan subquery number 1 querying SupportBean: Subselect aggregation functions cannot aggregate across correlated properties");
        }
Exemplo n.º 4
0
        public void TestVariables()
        {
            _epService.EPAdministrator.Configuration.AddVariable("MyConstantServiceVariable", typeof(MyConstantServiceVariable), new MyConstantServiceVariable());
            RunAssertionConstantVariable();

            _epService.EPAdministrator.Configuration.AddVariable("MyNonConstantServiceVariable", typeof(MyNonConstantServiceVariable), new MyNonConstantServiceVariable("postfix"));
            RunAssertionNonConstantVariable(false);
            RunAssertionNonConstantVariable(true);

            RunAssertionContextVariable();

            RunAssertionVariableMapAndOA();

            // 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.TestFromClauseMethodVariable+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 " + typeof(MyMethodHandlerMap).MaskTypeName() + " 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");
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
 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");
 }
        public override void Run(EPServiceProvider epService)
        {
            foreach (Type clazz in Collections.List(typeof(SupportSpatialPoint)))
            {
                epService.EPAdministrator.Configuration.AddEventType(clazz);
            }

            AssertCompileSODA(epService, "create index MyIndex on MyWindow((x,y) dummy_name(\"a\",10101))");
            AssertCompileSODA(epService, "create index MyIndex on MyWindow(x dummy_name)");
            AssertCompileSODA(epService, "create index MyIndex on MyWindow((x,y,z) dummy_name)");
            AssertCompileSODA(epService, "create index MyIndex on MyWindow(x dummy_name, (y,z) dummy_name_2(\"a\"), p dummyname3)");

            epService.EPAdministrator.CreateEPL("create window MyWindow#keepall as SupportSpatialPoint");
            SupportMessageAssertUtil.TryInvalid(epService, "create index MyIndex on MyWindow(())",
                                                "Error starting statement: Invalid empty list of index expressions");

            SupportMessageAssertUtil.TryInvalid(epService, "create index MyIndex on MyWindow(IntPrimitive+1)",
                                                "Error starting statement: Invalid index expression 'IntPrimitive+1'");

            SupportMessageAssertUtil.TryInvalid(epService, "create index MyIndex on MyWindow((x, y))",
                                                "Error starting statement: Invalid multiple index expressions");

            SupportMessageAssertUtil.TryInvalid(epService, "create index MyIndex on MyWindow(x.y)",
                                                "Error starting statement: Invalid index expression 'x.y'");

            SupportMessageAssertUtil.TryInvalid(epService, "create index MyIndex on MyWindow(id xxxx)",
                                                "Error starting statement: Unrecognized advanced-type index 'xxxx'");
        }
Exemplo n.º 8
0
        private void RunAssertionInvalidFilterIndex(EPServiceProvider epService)
        {
            // unrecognized named parameter
            SupportMessageAssertUtil.TryInvalid(epService, "select * from SupportSpatialAABB#keepall where point(0, 0, a:1).inside(rectangle(x, y, width, height))",
                                                "Error validating expression: Failed to validate filter expression 'point(0,0,a:1).inside(rectangle(x,y...(50 chars)': point does not accept 'a' as a named parameter");

            // not a filter
            SupportMessageAssertUtil.TryInvalid(epService, "expression myindex {pointregionquadtree(0, 0, 100, 100)} select * from SupportSpatialAABB#keepall where point(0, 0, filterindex:myindex).inside(rectangle(x, y, width, height))",
                                                "Error validating expression: Failed to validate filter expression 'point(0,0,filterindex:myindex()).in...(68 chars)': The 'filterindex' named parameter can only be used in in filter expressions");

            // invalid index expression
            SupportMessageAssertUtil.TryInvalid(epService, "select * from SupportSpatialAABB(point(0, 0, filterindex:1).inside(rectangle(x, y, width, height)))",
                                                "Failed to validate filter expression 'point(0,0,filterindex:1).inside(rec...(60 chars)': Named parameter 'filterindex' requires an expression name");
            SupportMessageAssertUtil.TryInvalid(epService, "select * from SupportSpatialAABB(point(0, 0, filterindex:dummy).inside(rectangle(x, y, width, height)))",
                                                "Failed to validate filter expression 'point(0,0,filterindex:dummy).inside...(64 chars)': Named parameter 'filterindex' requires an expression name");
            SupportMessageAssertUtil.TryInvalid(epService, "expression myindex {0} select * from SupportSpatialAABB(point(0, 0, filterindex:myindex).inside(rectangle(x, y, width, height)))",
                                                "Failed to validate filter expression 'point(0,0,filterindex:myindex()).in...(68 chars)': Named parameter 'filterindex' requires an index expression");
            SupportMessageAssertUtil.TryInvalid(epService, "expression myindex {dummy(0)} select * from SupportSpatialAABB(point(0, 0, filterindex:myindex).inside(rectangle(x, y, width, height)))",
                                                "Failed to validate filter expression 'point(0,0,filterindex:myindex()).in...(68 chars)': Unrecognized advanced-type index 'dummy'");
            SupportMessageAssertUtil.TryInvalid(epService, "expression myindex {pointregionquadtree(0)} select * from SupportSpatialAABB(point(0, 0, filterindex:myindex).inside(rectangle(x, y, width, height)))",
                                                "Failed to validate filter expression 'point(0,0,filterindex:myindex()).in...(68 chars)': Index of type 'pointregionquadtree' requires at least 4 parameters but received 1 [");
            SupportMessageAssertUtil.TryInvalid(epService, "expression myindex {pointregionquadtree(0,0,0,0)} select * from SupportSpatialAABB(point(0, 0, filterindex:myindex).inside(rectangle(x, y, width, height)))",
                                                "Failed to validate filter expression 'point(0,0,filterindex:myindex()).in...(68 chars)': Invalid value for index 'myindex' parameter 'width' received 0 and expected value>0");
            SupportMessageAssertUtil.TryInvalid(epService, "expression myindex {pointregionquadtree(0,0,100,100).Help()} select * from SupportSpatialAABB(point(0, 0, filterindex:myindex).inside(rectangle(x, y, width, height)))",
                                                "Failed to validate filter expression 'point(0,0,filterindex:myindex()).in...(68 chars)': Named parameter 'filterindex' invalid chained index expression");

            // filter-not-optimizable
            SupportMessageAssertUtil.TryInvalid(epService, "expression myindex {pointregionquadtree(0, 0, 100, 100)} select * from SupportSpatialAABB(point(x, y, filterindex:myindex).inside(rectangle(x, y, width, height)))",
                                                "Invalid filter-indexable expression 'x' in respect to index 'myindex': expected either a constant, context-builtin or property from a previous pattern match [expression myindex {pointregionquadtree(0, 0, 100, 100)} select * from SupportSpatialAABB(point(x, y, filterindex:myindex).inside(rectangle(x, y, width, height)))]");
            SupportMessageAssertUtil.TryInvalid(epService, "expression myindex {pointregionquadtree(0, 0, 100, 100)} select * from SupportSpatialAABB(point(0, 0, filterindex:myindex).inside(rectangle(0, y, width, height)))",
                                                "Invalid filter-index lookup expression '0' in respect to index 'myindex': expected an event property");
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        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");
        }
Exemplo n.º 11
0
        private void RunInvalid()
        {
            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 'pattern quantifier");

            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");
        }
Exemplo n.º 12
0
        public void TestCountMain()
        {
            var statementText = "select count(*) as cnt from " + typeof(SupportMarketDataBean).FullName + "#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");
        }
        private void RunAssertionNamedParameter(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            string epl = "select ?:my/value/int as c0 from SupportBean(TheString = ?:somevalue, IntPrimitive=?:my/value/int, LongPrimitive=?:/my/value/long)";
            EPPreparedStatement prepared = epService.EPAdministrator.PrepareEPL(epl);

            prepared.SetObject("somevalue", "E1");
            prepared.SetObject("my/value/int", 10);
            prepared.SetObject("/my/value/long", 100L);
            var listenerOne = new SupportUpdateListener();

            epService.EPAdministrator.Create(prepared).Events += listenerOne.Update;

            SupportBean @event = new SupportBean("E1", 10);

            @event.LongPrimitive = 100;
            epService.EPRuntime.SendEvent(@event);
            EPAssertionUtil.AssertProps(listenerOne.AssertOneGetNewAndReset(), "c0".Split(','), new object[] { 10 });

            SupportMessageAssertUtil.TryInvalid(epService, "select ?,?:a from SupportBean",
                                                "Inconsistent use of substitution parameters, expecting all substitutions to either all provide a name or provide no name");

            SupportMessageAssertUtil.TryInvalid(epService, "select ?:select from SupportBean",
                                                "Incorrect syntax near ':' ('select' is a reserved keyword) at line 1 column 8 near reserved keyword 'select' [");

            epService.EPAdministrator.DestroyAllStatements();
        }
Exemplo n.º 14
0
        private void TryAssertionReturnTypeIsEventsInvalid(EPServiceProvider epService)
        {
            var entry = new ConfigurationPlugInSingleRowFunction();
            entry.FunctionClassName = GetType().FullName;
            entry.FunctionMethodName = "MyItemProducerEventBeanArray";

            // test invalid: no event type name
            entry.Name = "myItemProducerInvalidNoType";
            entry.EventTypeName = null;
            epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(entry);
            epService.EPAdministrator.CreateEPL("select MyItemProducerInvalidNoType(TheString) as c0 from SupportBean");
            SupportMessageAssertUtil.TryInvalid(
                epService,
                "select MyItemProducerInvalidNoType(TheString).where(v => v.id='id1') as c0 from SupportBean",
                "Error starting statement: Failed to validate select-clause expression 'MyItemProducerInvalidNoType(TheStri...(68 chars)': Method 'MyItemProducerEventBeanArray' returns EventBean-array but does not provide the event type name [");

            // test invalid: event type name invalid
            entry.Name = "myItemProducerInvalidWrongType";
            entry.EventTypeName = "dummy";
            epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(entry);
            SupportMessageAssertUtil.TryInvalid(
                epService,
                "select MyItemProducerInvalidWrongType(TheString).where(v => v.id='id1') as c0 from SupportBean",
                "Error starting statement: Failed to validate select-clause expression 'MyItemProducerInvalidWrongType(TheS...(74 chars)': Method 'MyItemProducerEventBeanArray' returns event type 'dummy' and the event type cannot be found [select MyItemProducerInvalidWrongType(TheString).where(v => v.id='id1') as c0 from SupportBean]");

            epService.EPAdministrator.DestroyAllStatements();
        }
Exemplo n.º 15
0
        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 [");
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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");
        }
        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]");
        }
Exemplo n.º 19
0
        /// <summary>
        /// Writeable-property tests: when a simple writable property needs to be converted
        /// </summary>
        private void RunAssertionSimpleWriteablePropertyCoerce(EPServiceProvider epService)
        {
            Schema schema = SchemaBuilder.Record("MyEventSchema", TypeBuilder.Field("isodate", TypeBuilder.StringType(
                                                                                        TypeBuilder.Property(AvroConstant.PROP_STRING_KEY, AvroConstant.PROP_ARRAY_VALUE))));

            epService.EPAdministrator.Configuration.AddEventTypeAvro("MyEvent", new ConfigurationEventTypeAvro(schema));
            epService.EPAdministrator.Configuration.AddEventType <MyEventWithDateTimeOffset>();
            epService.EPAdministrator.Configuration.AddEventType <MyEventWithDateTimeEx>();

            // invalid without explicit conversion
            SupportMessageAssertUtil.TryInvalid(
                epService,
                "insert into MyEvent(isodate) select dto from MyEventWithDateTimeOffset",
                "Error starting statement: Invalid assignment of column 'isodate' of type '" + Name.Of <DateTimeOffset>(false) + "' to event property 'isodate' typed as '" + Name.Of <char[]>(false) + "', column and parameter types mismatch"
                );

            // with hook
            var stmt     = epService.EPAdministrator.CreateEPL("insert into MyEvent(isodate) select dtx from MyEventWithDateTimeEx");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            DateTimeEx now = DateTimeEx.NowLocal();

            epService.EPRuntime.SendEvent(new MyEventWithDateTimeEx(now));
            Assert.AreEqual(DateTimeFormatter.ISO_DATE_TIME.Invoke(now), listener.AssertOneGetNewAndReset().Get("isodate"));

            stmt.Dispose();
        }
Exemplo n.º 20
0
 private void RunAssertionInvalidMethod(EPServiceProvider epService)
 {
     SupportMessageAssertUtil.TryInvalid(epService, "select * from SupportSpatialEventRectangle(rectangle('a', 0).inside(rectangle(0, 0, 0, 0)))",
                                         "Failed to validate filter expression 'rectangle(\"a\",0).inside(rectangle(0...(43 chars)': Failed to validate method-chain parameter expression 'rectangle(0,0,0,0)': Unknown single-row function, expression declaration, script or aggregation function named 'rectangle' could not be resolved (did you mean 'rectangle.intersects')");
     SupportMessageAssertUtil.TryInvalid(epService, "select * from SupportSpatialEventRectangle(rectangle(0).intersects(rectangle(0, 0, 0, 0)))",
                                         "Failed to validate filter expression 'rectangle(0).intersects(rectangle(0...(43 chars)': Error validating left-hand-side method 'rectangle', expected 4 parameters but received 1 parameters");
 }
        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");
        }
Exemplo n.º 22
0
        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' ");
        }
Exemplo n.º 23
0
        public void TestFirstEverLastEver()
        {
            RunAssertionFirstLastEver(true);
            RunAssertionFirstLastEver(false);

            SupportMessageAssertUtil.TryInvalid(_epService, "select countever(distinct IntPrimitive) from SupportBean",
                                                "Error starting statement: Failed to validate select-clause expression 'countever(distinct IntPrimitive)': Aggregation function 'countever' does now allow distinct [");
        }
Exemplo n.º 24
0
        private void RunAssertionInvalidFilterIndex(EPServiceProvider epService)
        {
            // invalid index for filter
            string epl = "expression myindex { pointregionquadtree(0, 0, 100, 100) }" +
                         "select * from SupportSpatialEventRectangle(rectangle(10, 20, 5, 6, filterindex:myindex).intersects(rectangle(x, y, width, height)))";

            SupportMessageAssertUtil.TryInvalid(epService, epl, "Failed to validate filter expression 'rectangle(10,20,5,6,filterindex:myi...(82 chars)': Invalid index type 'pointregionquadtree', expected 'mxcifquadtree'");
        }
Exemplo n.º 25
0
        private void RunAssertionInvalidInsertInto(EPServiceProvider epService)
        {
            SupportMessageAssertUtil.TryInvalid(epService, "insert into RevQuote select * from " + typeof(SupportBean).FullName,
                                                "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 " + typeof(SupportBean).FullName,
                                                "Error starting statement: Selected event type is not a valid base or delta event type of revision event type 'RevisableQuote' ");
        }
Exemplo n.º 26
0
        private void RunAssertionInvalidUse(EPServiceProvider epService)
        {
            SupportMessageAssertUtil.TryInvalid(epService, "select * from " + Name.Of <SupportBean>() + " group by xxx(1)",
                                                "Error in expression: Error resolving aggregation: Aggregation class by name '" + Name.Of <object>() + "' does not implement AggregationFunctionFactory");

            SupportMessageAssertUtil.TryInvalid(epService, "select * from " + typeof(SupportBean).FullName + " group by yyy(1)",
                                                "Error in expression: Error resolving aggregation: Could not load aggregation factory class by name 'com.NoSuchClass'");
        }
Exemplo n.º 27
0
        private void RunAssertionAutoNamePackageAmbigous(EPServiceProvider epService)
        {
            SupportMessageAssertUtil.TryInvalid(epService, "select * from SupportAmbigousEventType",
                                                "Failed to resolve event type: Failed to resolve name 'SupportAmbigousEventType', the class was ambigously found both in namespace 'com.espertech.esper.supportregression.bean' and in namespace 'com.espertech.esper.supportregression.client'");

            SupportMessageAssertUtil.TryInvalid(epService, "select * from XXXX",
                                                "Failed to resolve event type: Event type or class named 'XXXX' was not found");
        }
Exemplo n.º 28
0
        private void RunAssertionInvalidPropertyHistorical(EPServiceProvider epService)
        {
            string stmtText = "select myvarchar from " +
                              " sql:MyDB ['select myvarchar from mytesttable where ${myvarchar} = mytesttable.mybigint'] as s0," +
                              typeof(SupportBeanComplexProps).FullName + " as s1";

            SupportMessageAssertUtil.TryInvalid(epService, stmtText,
                                                "Error starting statement: Invalid expression 'myvarchar' resolves to the historical data itself");
        }
Exemplo n.º 29
0
        private void RunAssertionScriptReturningEvents(EPServiceProvider epService)
        {
            RunAssertionScriptReturningEvents(epService, false);
            RunAssertionScriptReturningEvents(epService, true);

            SupportMessageAssertUtil.TryInvalid(
                epService, "expression double @Type(ItemEvent) fib(num) [] select fib(1) from SupportBean",
                "Error starting statement: Failed to validate select-clause expression 'fib(1)': The @type annotation is only allowed when the invocation target returns EventBean instances");
        }
Exemplo n.º 30
0
        private void RunAssertionInvalidSubviews(EPServiceProvider epService)
        {
            string sql      = "sql:MyDB ['select myvarchar from mytesttable where ${IntPrimitive} = mytesttable.myint']#time(30 sec)";
            string stmtText = "select myvarchar as s0Name from " +
                              sql + " as s0, " + typeof(SupportBean).FullName + " as s1";

            SupportMessageAssertUtil.TryInvalid(epService, stmtText,
                                                "Error starting statement: Historical data joins do not allow views onto the data, view 'time' is not valid in this context [select myvarchar as s0Name from sql:MyDB [");
        }