Example #1
0
        public static ExprAggregateNodeParamDesc GetValidatePositionalParams(ExprNode[] childNodes, bool allowOnlyGroupBy)
        {
            ExprAggregateLocalGroupByDesc optionalLocalGroupBy = null;
            var count = 0;

            foreach (var node in childNodes)
            {
                if (!IsNonPositionalParameter(node))
                {
                    count++;
                }
                else
                {
                    var namedParameterNode = (ExprNamedParameterNodeImpl)node;
                    if (allowOnlyGroupBy && namedParameterNode.ParameterName.ToLower() != "group_by")
                    {
                        throw new ExprValidationException("Invalid named parameter '" + namedParameterNode.ParameterName + "' (did you mean 'group_by'?)");
                    }
                    optionalLocalGroupBy = new ExprAggregateLocalGroupByDesc(namedParameterNode.ChildNodes);
                }
            }
            var positionals = new ExprNode[count];

            count = 0;
            foreach (var node in childNodes)
            {
                if (!IsNonPositionalParameter(node))
                {
                    positionals[count++] = node;
                }
            }
            return(new ExprAggregateNodeParamDesc(positionals, optionalLocalGroupBy));
        }
Example #2
0
 public ExprAggregateNodeParamDesc(
     ExprNode[] positionalParams,
     ExprAggregateLocalGroupByDesc optLocalGroupBy,
     ExprNode optionalFilter)
 {
     PositionalParams = positionalParams;
     OptLocalGroupBy  = optLocalGroupBy;
     OptionalFilter   = optionalFilter;
 }
Example #3
0
        public void ValidatePositionals()
        {
            ExprAggregateNodeParamDesc paramDesc = ExprAggregateNodeUtil.GetValidatePositionalParams(ChildNodes, !(this is ExprAggregationPlugInNodeMarker));

            _optionalAggregateLocalGroupByDesc = paramDesc.OptLocalGroupBy;
            if (_optionalAggregateLocalGroupByDesc != null)
            {
                ExprNodeUtility.ValidateNoSpecialsGroupByExpressions(_optionalAggregateLocalGroupByDesc.PartitionExpressions);
            }

            _positionalParams = paramDesc.PositionalParams;
        }
Example #4
0
        public static ExprAggregateNodeParamDesc GetValidatePositionalParams(IList <ExprNode> childNodes, bool builtinAggregationFunc)
        {
            ExprAggregateLocalGroupByDesc optionalLocalGroupBy = null;
            ExprNode optionalFilter = null;
            var      count          = 0;

            foreach (ExprNode node in childNodes)
            {
                if (!IsNonPositionalParameter(node))
                {
                    count++;
                }
                else
                {
                    var namedParameterNode = (ExprNamedParameterNode)node;
                    var paramNameLower     = namedParameterNode.ParameterName.ToLowerInvariant();
                    if (paramNameLower == "group_by")
                    {
                        optionalLocalGroupBy = new ExprAggregateLocalGroupByDesc(namedParameterNode.ChildNodes);
                    }
                    else if (paramNameLower == "filter")
                    {
                        if ((namedParameterNode.ChildNodes.Count != 1) ||
                            (namedParameterNode.ChildNodes[0].ExprEvaluator.ReturnType.GetBoxedType() != typeof(bool?)))
                        {
                            throw new ExprValidationException("Filter named parameter requires a single expression returning a boolean-typed value");
                        }
                        optionalFilter = namedParameterNode.ChildNodes[0];
                    }
                    else if (builtinAggregationFunc)
                    {
                        throw new ExprValidationException("Invalid named parameter '" + namedParameterNode.ParameterName + "' (did you mean 'group_by' or 'filter'?)");
                    }
                }
            }
            var positionals = new ExprNode[count];

            count = 0;
            foreach (var node in childNodes)
            {
                if (!IsNonPositionalParameter(node))
                {
                    positionals[count++] = node;
                }
            }
            return(new ExprAggregateNodeParamDesc(positionals, optionalLocalGroupBy, optionalFilter));
        }