Esempio n. 1
0
        private ExprNode GetFilterExpressionInclOnClause(ExprNode optionalFilterNode, OuterJoinDesc[] outerJoinDescList)
        {
            if (optionalFilterNode == null)
            {   // no need to add as query planning is fully based on on-clause
                return(null);
            }
            if (outerJoinDescList.Length == 0)
            {  // not an outer-join syntax
                return(optionalFilterNode);
            }
            if (!OuterJoinDesc.ConsistsOfAllInnerJoins(outerJoinDescList))
            {    // all-inner joins
                return(optionalFilterNode);
            }

            var hasOnClauses = OuterJoinDesc.HasOnClauses(outerJoinDescList);

            if (!hasOnClauses)
            {
                return(optionalFilterNode);
            }

            var expressions = new List <ExprNode>();

            expressions.Add(optionalFilterNode);

            foreach (var outerJoinDesc in outerJoinDescList)
            {
                if (outerJoinDesc.OptLeftNode != null)
                {
                    expressions.Add(outerJoinDesc.MakeExprNode(null));
                }
            }

            ExprAndNode andNode = ExprNodeUtility.ConnectExpressionsByLogicalAnd(expressions);

            try
            {
                andNode.Validate(null);
            }
            catch (ExprValidationException ex)
            {
                throw new EPRuntimeException("Unexpected exception validating expression: " + ex.Message, ex);
            }

            return(andNode);
        }
        private static ExprNode GetFilterExpressionInclOnClause(
            ExprNode whereClause,
            OuterJoinDesc[] outerJoinDescList,
            StatementRawInfo rawInfo,
            StatementCompileTimeServices services)
        {
            if (whereClause == null) { // no need to add as query planning is fully based on on-clause
                return null;
            }

            if (outerJoinDescList.Length == 0) { // not an outer-join syntax
                return whereClause;
            }

            if (!OuterJoinDesc.ConsistsOfAllInnerJoins(outerJoinDescList)) { // all-inner joins
                return whereClause;
            }

            var hasOnClauses = OuterJoinDesc.HasOnClauses(outerJoinDescList);
            if (!hasOnClauses) {
                return whereClause;
            }

            IList<ExprNode> expressions = new List<ExprNode>();
            expressions.Add(whereClause);

            foreach (var outerJoinDesc in outerJoinDescList) {
                if (outerJoinDesc.OptLeftNode != null) {
                    expressions.Add(outerJoinDesc.MakeExprNode(rawInfo, services));
                }
            }

            var andNode = ExprNodeUtilityMake.ConnectExpressionsByLogicalAnd(expressions);
            try {
                andNode.Validate(null);
            }
            catch (ExprValidationException ex) {
                throw new EPRuntimeException("Unexpected exception validating expression: " + ex.Message, ex);
            }

            return andNode;
        }