Exemplo n.º 1
0
        protected override AggregationMethodFactory ValidateAggregationChild(ExprValidationContext validationContext)
        {
            var positionalParams = PositionalParams;

            if (positionalParams.Length == 0 || positionalParams.Length > 2)
            {
                throw new ExprValidationException(_minMaxTypeEnum.ToString() + " node must have either 1 or 2 parameters");
            }

            var  child = positionalParams[0];
            bool hasDataWindows;

            if (_isEver)
            {
                hasDataWindows = false;
            }
            else
            {
                if (validationContext.ExprEvaluatorContext.StatementType == StatementType.CREATE_TABLE)
                {
                    hasDataWindows = true;
                }
                else
                {
                    hasDataWindows = ExprNodeUtility.HasRemoveStreamForAggregations(child, validationContext.StreamTypeService, validationContext.IsResettingAggregations);
                }
            }

            if (_isFFunc)
            {
                if (positionalParams.Length < 2)
                {
                    throw new ExprValidationException(_minMaxTypeEnum.ToString() + "-filtered aggregation function must have a filter expression as a second parameter");
                }
                base.ValidateFilter(positionalParams[1].ExprEvaluator);
            }

            _hasFilter = positionalParams.Length == 2;

            return(validationContext.EngineImportService.AggregationFactoryFactory.MakeMinMax(
                       validationContext.StatementExtensionSvcContext, this, child.ExprEvaluator.ReturnType, hasDataWindows));
        }
Exemplo n.º 2
0
        public override AggregationMethodFactory ValidateAggregationChild(ExprValidationContext validationContext)
        {
            if (PositionalParams.Length == 0 || PositionalParams.Length > 2)
            {
                throw new ExprValidationException(_minMaxTypeEnum.ToString() + " node must have either 1 or 2 parameters");
            }

            ExprNode child = PositionalParams[0];
            bool     hasDataWindows;

            if (_isEver)
            {
                hasDataWindows = false;
            }
            else
            {
                if (validationContext.ExprEvaluatorContext.StatementType == StatementType.CREATE_TABLE)
                {
                    hasDataWindows = true;
                }
                else
                {
                    hasDataWindows = ExprNodeUtility.HasRemoveStreamForAggregations(child, validationContext.StreamTypeService, validationContext.IsResettingAggregations);
                }
            }

            if (_hasFilter)
            {
                if (PositionalParams.Length < 2)
                {
                    throw new ExprValidationException(_minMaxTypeEnum.ToString() + "-filtered aggregation function must have a filter expression as a second parameter");
                }
                base.ValidateFilter(PositionalParams[1].ExprEvaluator);
            }
            return(new ExprMinMaxAggrNodeFactory(this, child.ExprEvaluator.ReturnType, hasDataWindows));
        }