microsoft / Kusto-Query-Language

Kusto Query Language is a simple and productive language for querying Big Data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing nested aggregation functions causes an `ArgumentNullException`

AlexDKlein opened this issue · comments

Using KustoCode.ParseAndAnalyze or KustoCode.Parse on queries with illegal syntax that involves nested aggregate functions causes an unhandled exception. Any query that contains syntax similar to summarize count(any()) will trigger this behavior. Any pair of aggregate functions can be used and will trigger the same exception. A sample stack trace is included below.

An exception occurred parsing the query 'T | summarize any(avg(Y), X) by Y':
     System.ArgumentNullException - Value cannot be null. (Parameter 'type')
        at Kusto.Language.Symbols.ColumnSymbol..ctor(String name, TypeSymbol type, String description, IReadOnlyList`1 originalColumns, SyntaxNode source, IReadOnlyList`1 examples)
   at Kusto.Language.Aggregates.GetAnyResult(CustomReturnTypeContext context, String unnamedExpressionPrefix)
   at Kusto.Language.Binding.Binder.GetFunctionCallResult(Signature signature, IReadOnlyList`1 arguments, IReadOnlyList`1 argumentTypes, IReadOnlyList`1 argumentParameters, SyntaxElement location, List`1 diagnostics)
   at Kusto.Language.Binding.Binder.GetFunctionCallResult(Signature signature, IReadOnlyList`1 arguments, IReadOnlyList`1 argumentTypes, SyntaxElement location, List`1 diagnostics)
   at Kusto.Language.Binding.Binder.BindFunctionCall(FunctionCallExpression functionCall, FunctionSymbol fn)
   at Kusto.Language.Binding.Binder.TreeBinder.BindNode(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitFunctionCallExpression(FunctionCallExpression node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitChildren(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.DefaultVisit(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitChildren(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.DefaultVisit(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitInScope(SyntaxNode node, ScopeKind kind)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitSummarizeOperator(SummarizeOperator node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitPipeExpression(PipeExpression node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitChildren(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.DefaultVisit(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitChildren(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.DefaultVisit(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitChildren(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.DefaultVisit(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.VisitChildren(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TreeBinder.DefaultVisit(SyntaxNode node)
   at Kusto.Language.Binding.Binder.TryBind(SyntaxTree tree, GlobalState globals, LocalBindingCache localBindingCache, Action`2 semanticInfoSetter, CancellationToken cancellationToken)
   at Kusto.Language.KustoCode.Create(String text, GlobalState globals, LexicalToken[] tokens, List`1 tokenStarts, Boolean analyze, CancellationToken cancellationToken)
   at Kusto.Language.KustoCode.ParseAndAnalyze(String text, GlobalState globals, CancellationToken cancellationToken)

Thanks for finding this bug. It has been fixed now.