Example #1
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));
        }
Example #2
0
        public override ScalarValue VisitFunctionCallExpression(FunctionCallExpression node)
        {
            var functionName = node.Name.SimpleName;
            var args         = node.ArgumentList.Expressions.Select(e => e.Element.Accept(this)).ToList();

            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.Parent is SummarizeByClause)
                {
                    return(ScalarFunctionFactory.Create(functionName, args));
                }

                return(AggregationFunctionFactory.Create(functionName, args));
            }
            else
            {
                return(ScalarFunctionFactory.Create(functionName, args));
            }
        }