private string GetDistinctExpression(SqlServerCommandParser.AggregationFunctionContext context) { StringBuilder result = new StringBuilder(); for (int i = 3; i < context.ChildCount - 1; i++) { result.Append(context.GetChild(i).GetText()); } return(result.ToString()); }
private IASTNode CreateAggregationSegment(SqlServerCommandParser.AggregationFunctionContext context, string aggregationType) { var type = AggregationType.ValueOf(aggregationType.ToUpper()); int innerExpressionStartIndex = ((ITerminalNode)context.GetChild(1)).Symbol.StartIndex; if (null == context.distinct()) { return(new AggregationProjectionSegment(context.Start.StartIndex, context.Stop.StopIndex, type, innerExpressionStartIndex)); } return(new AggregationDistinctProjectionSegment(context.Start.StartIndex, context.Stop.StopIndex, type, innerExpressionStartIndex, GetDistinctExpression(context))); }