Ejemplo n.º 1
0
        public static AggregationFunction Create(string name, List <ScalarValue> args)
        {
            if (mapping.TryGetValue(name, out ConstructorInfo constructor))
            {
                IEnumerator <ScalarValue> enumerator  = args.GetEnumerator();
                AggregationFunction       newFunction = (AggregationFunction)constructor.Invoke(new object[] { enumerator });
                newFunction.Name = name;
                return(newFunction);
            }

            throw new UnknownFunctionException($"Unknown function: '{name}'");
        }
Ejemplo n.º 2
0
        public override ScalarValue VisitSeparatedElement(SeparatedElement node)
        {
            Kusto.Language.Syntax.QueryBlock query = node.Root as Kusto.Language.Syntax.QueryBlock;
            var statement           = query.Statements[0];
            var expressionStatement = statement.Element as ExpressionStatement;

            if (expressionStatement.Expression is Kusto.Language.Syntax.SummarizeOperator)
            {
                if (node.Parent.Parent is SummarizeByClause &&
                    node.Element is FunctionCallExpression functionCallExpression)
                {
                    return(functionCallExpression.Accept(this));
                }

                if (node.Parent.Parent is SummarizeByClause &&
                    node.Element is NameReference identifierNameReference)
                {
                    return(identifierNameReference.Accept(this));
                }

                if (node.Element is FunctionCallExpression functionCallExpression1)
                {
                    AggregationFunction aggregationFunction =
                        VisitFunctionCallExpression(functionCallExpression1) as AggregationFunction;

                    RxKqlScalarValue retVal = new RxKqlScalarValue
                    {
                        Left  = aggregationFunction.Name,
                        Right = aggregationFunction
                    };

                    return(retVal);
                }

                if (node.Element is SimpleNamedExpression simpleNamedExpression)
                {
                    AggregationFunction aggregationFunction =
                        simpleNamedExpression.Expression.Accept(this) as AggregationFunction;

                    RxKqlScalarValue retVal = new RxKqlScalarValue
                    {
                        Left  = simpleNamedExpression.Name.SimpleName,
                        Right = aggregationFunction
                    };

                    return(retVal);
                }
            }

            return(base.VisitSeparatedElement(node));
        }