コード例 #1
0
        public void TestGetProcessorInvalid()
        {
            var selectionList = new SelectClauseElementCompiled[2];
            var identNode     = SupportExprNodeFactory.MakeIdentNode("DoubleBoxed", "s0");
            var mathNode      = SupportExprNodeFactory.MakeMathNode();

            selectionList[0] = new SelectClauseExprCompiledSpec(identNode, "result", "result", false);
            selectionList[1] = new SelectClauseExprCompiledSpec(mathNode, "result", "result", false);

            try
            {
                SelectExprProcessorFactory.GetProcessor(
                    _container,
                    Collections.GetEmptyList <int>(), selectionList,
                    false, null, null, null,
                    new SupportStreamTypeSvc3Stream(),
                    null, null, null,
                    null, null, null,
                    null, null, null,
                    null, null, 1,
                    null, null, null,
                    new Configuration(_container), null,
                    null, null, null, null);
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }
        }
コード例 #2
0
        public void TestGetProcessorSimpleSelect()
        {
            // empty group-by and no event properties aggregated in select clause (wildcard), no having clause
            var wildcardSelect = new SelectClauseElementCompiled[] { new SelectClauseElementWildcard() };
            var spec           = MakeSpec(new SelectClauseSpecCompiled(wildcardSelect, false), null, _groupByList, null, null, _orderByList);
            var processor      = ResultSetProcessorFactoryFactory.GetProcessorPrototype(
                spec, _stmtContext, _typeService3Stream,
                null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY,
                null, new Configuration(_container), null, false, false);

            Assert.IsTrue(processor.ResultSetProcessorFactory is ResultSetProcessorHandThroughFactory);

            // empty group-by with select clause elements
            var selectList = SupportSelectExprFactory.MakeNoAggregateSelectListUnnamed();

            spec      = MakeSpec(new SelectClauseSpecCompiled(selectList, false), null, _groupByList, null, null, _orderByList);
            processor = ResultSetProcessorFactoryFactory.GetProcessorPrototype(
                spec, _stmtContext, _typeService1Stream,
                null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY,
                null, new Configuration(_container), null, false, false);
            Assert.IsTrue(processor.ResultSetProcessorFactory is ResultSetProcessorHandThroughFactory);

            // non-empty group-by and wildcard select, group by ignored
            _groupByList.Add(SupportExprNodeFactory.MakeIdentNode("DoubleBoxed", "s0"));
            spec      = MakeSpec(new SelectClauseSpecCompiled(wildcardSelect, false), null, _groupByList, null, null, _orderByList);
            processor = ResultSetProcessorFactoryFactory.GetProcessorPrototype(
                spec, _stmtContext, _typeService1Stream,
                null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY,
                null, new Configuration(_container), null, false, false);
            Assert.IsTrue(processor.ResultSetProcessorFactory is ResultSetProcessorSimpleFactory);
        }
コード例 #3
0
        public void TestGetProcessorNoProcessorRequired()
        {
            // single stream, empty group-by and wildcard select, no having clause, no need for any output processing
            var wildcardSelect = new SelectClauseElementCompiled[] { new SelectClauseElementWildcard() };
            var spec           = MakeSpec(new SelectClauseSpecCompiled(wildcardSelect, false), null, _groupByList, null, null, _orderByList);
            var processor      = ResultSetProcessorFactoryFactory.GetProcessorPrototype(spec, _stmtContext, _typeService1Stream, null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY, null, new Configuration());

            Assert.IsTrue(processor.ResultSetProcessorFactory is ResultSetProcessorHandThroughFactory);
        }
コード例 #4
0
        public void TestGetProcessorWildcard()
        {
            var selectionList = new SelectClauseElementCompiled[] { new SelectClauseElementWildcard() };
            var processor     = SelectExprProcessorFactory.GetProcessor(Collections.GetEmptyList <int>(), selectionList, false, null, null, null,
                                                                        new SupportStreamTypeSvc3Stream(), SupportEventAdapterService.Service, _statementResultService, null, _selectExprEventTypeRegistry, null, null, null, null,
                                                                        new TableServiceImpl(), null, null, null, null, null, null, new Configuration(), null, null, null);

            Assert.IsTrue(processor is SelectExprResultProcessor);
        }
コード例 #5
0
        public void TestGetProcessorInvalid()
        {
            var spec = MakeSpec(new SelectClauseSpecCompiled(SupportSelectExprFactory.MakeInvalidSelectList(), false), null, _groupByList, null, null, _orderByList);

            // invalid select clause
            try
            {
                ResultSetProcessorFactoryFactory.GetProcessorPrototype(
                    spec, _stmtContext, _typeService3Stream,
                    null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY,
                    null, new Configuration(_container), null, false, false);
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // expected
            }

            // invalid group-by
            _groupByList.Add(new ExprIdentNodeImpl("xxxx", "s0"));
            try
            {
                spec = MakeSpec(new SelectClauseSpecCompiled(SupportSelectExprFactory.MakeNoAggregateSelectListUnnamed(), false), null, _groupByList, null, null, _orderByList);
                ResultSetProcessorFactoryFactory.GetProcessorPrototype(
                    spec, _stmtContext, _typeService3Stream,
                    null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY,
                    null, new Configuration(_container), null, false, false);
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // expected
            }

            // Test group by having properties that are aggregated in select clause, should fail
            _groupByList.Clear();
            _groupByList.Add(SupportExprNodeFactory.MakeSumAggregateNode());

            var selectList = new SelectClauseElementCompiled[] {
                new SelectClauseExprCompiledSpec(SupportExprNodeFactory.MakeSumAggregateNode(), null, null, false)
            };

            try
            {
                spec = MakeSpec(new SelectClauseSpecCompiled(selectList, false), null, _groupByList, null, null, _orderByList);
                ResultSetProcessorFactoryFactory.GetProcessorPrototype(
                    spec, _stmtContext, _typeService3Stream,
                    null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY,
                    null, new Configuration(_container), null, false, false);
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // expected
            }
        }
コード例 #6
0
        public static SelectClauseElementCompiled[] MakeAggregateSelectListWithProps()
        {
            ExprNode top       = new ExprSumNode(false);
            ExprNode identNode = SupportExprNodeFactory.MakeIdentNode("DoubleBoxed", "s0");

            top.AddChildNode(identNode);

            SelectClauseElementCompiled[] selectionList = new SelectClauseElementCompiled[] {
                new SelectClauseExprCompiledSpec(top, null, null, false)
            };
            return(selectionList);
        }
コード例 #7
0
        public void TestGetProcessorValid()
        {
            var selectionList = new SelectClauseElementCompiled[1];
            var identNode     = SupportExprNodeFactory.MakeIdentNode("DoubleBoxed", "s0");

            selectionList[0] = new SelectClauseExprCompiledSpec(identNode, "result", null, false);
            var statementContext = SupportStatementContextFactory.MakeContext();
            var processor        = SelectExprProcessorFactory.GetProcessor(Collections.GetEmptyList <int>(), selectionList, false, null, null, null,
                                                                           new SupportStreamTypeSvc3Stream(), SupportEventAdapterService.Service, _statementResultService, null, _selectExprEventTypeRegistry,
                                                                           statementContext.MethodResolutionService, null, null, null, null, null, null, null, null, null, null, new Configuration(), null, null, null);

            Assert.IsTrue(processor != null);
        }
コード例 #8
0
        public void TestVerifyNameUniqueness()
        {
            // try valid case
            var elements = new SelectClauseElementCompiled[4];

            elements[0] = new SelectClauseExprCompiledSpec(null, "xx", null, false);
            elements[1] = new SelectClauseExprCompiledSpec(null, "yy", null, false);
            elements[2] = new SelectClauseStreamCompiledSpec("win", null);
            elements[3] = new SelectClauseStreamCompiledSpec("s2", "abc");

            SelectExprProcessorFactory.VerifyNameUniqueness(elements);

            // try invalid case
            elements = (SelectClauseElementCompiled[])CollectionUtil.ArrayExpandAddSingle(elements, new SelectClauseExprCompiledSpec(null, "yy", null, false));
            try
            {
                SelectExprProcessorFactory.VerifyNameUniqueness(elements);
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // expected
            }

            // try invalid case
            elements    = new SelectClauseElementCompiled[2];
            elements[0] = new SelectClauseExprCompiledSpec(null, "abc", null, false);
            elements[1] = new SelectClauseStreamCompiledSpec("s0", "abc");
            try
            {
                SelectExprProcessorFactory.VerifyNameUniqueness(elements);
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // expected
            }
        }