public void SetUp() { _maxNode = new ExprMinMaxAggrNode(false, MinMaxTypeEnum.MAX, false, false); _minNode = new ExprMinMaxAggrNode(false, MinMaxTypeEnum.MIN, false, false); ValidatedNodeToTest = MakeNode(MinMaxTypeEnum.MAX, 5, typeof(int)); }
public void TestValidate() { // Must have exactly 1 subnodes try { _minNode.Validate(SupportExprValidationContextFactory.MakeEmpty()); Assert.Fail(); } catch (ExprValidationException ex) { // Expected } // Must have only number-type subnodes _minNode = new ExprMinMaxAggrNode(false, MinMaxTypeEnum.MIN, true, false); _minNode.AddChildNode(new SupportExprNode(typeof(string))); _minNode.AddChildNode(new SupportExprNode(typeof(int))); try { _minNode.Validate(SupportExprValidationContextFactory.Make(new SupportStreamTypeSvc3Stream())); Assert.Fail(); } catch (ExprValidationException ex) { // Expected } }
private ExprMinMaxAggrNode MakeNode(MinMaxTypeEnum minMaxType, Object value, Type type) { ExprMinMaxAggrNode minMaxNode = new ExprMinMaxAggrNode(false, minMaxType, false, false); minMaxNode.AddChildNode(new SupportExprNode(value, type)); SupportExprNodeFactory.Validate3Stream(minMaxNode); return(minMaxNode); }
public AggregationMethodFactory MakeMinMax( StatementExtensionSvcContext statementExtensionSvcContext, ExprMinMaxAggrNode exprMinMaxAggrNode, Type type, bool hasDataWindows) { return(new AggregationMethodFactoryMinMax(exprMinMaxAggrNode, type, hasDataWindows)); }
// Min/Max nodes can be either an aggregate or a per-row function depending on the number or arguments private static void HandleMinMax( string ident, EsperEPL2GrammarParser.LibFunctionArgsContext ctxArgs, IDictionary <ITree, ExprNode> astExprNodeMap) { // Determine min or max var childNodeText = ident; MinMaxTypeEnum minMaxTypeEnum; var filtered = childNodeText.StartsWith("f"); if (childNodeText.ToLowerInvariant().Equals("min") || childNodeText.ToLowerInvariant().Equals("fmin")) { minMaxTypeEnum = MinMaxTypeEnum.MIN; } else if (childNodeText.ToLowerInvariant().Equals("max") || childNodeText.ToLowerInvariant().Equals("fmax")) { minMaxTypeEnum = MinMaxTypeEnum.MAX; } else { throw ASTWalkException.From("Uncountered unrecognized min or max node '" + ident + "'"); } var args = Collections.GetEmptyList <ExprNode>(); if (ctxArgs != null && ctxArgs.libFunctionArgItem() != null) { args = ASTExprHelper.ExprCollectSubNodes(ctxArgs, 0, astExprNodeMap); } var numArgsPositional = ExprAggregateNodeUtil.CountPositionalArgs(args); var isDistinct = ctxArgs != null && ctxArgs.DISTINCT() != null; if (numArgsPositional > 1 && isDistinct && !filtered) { throw ASTWalkException.From( "The distinct keyword is not valid in per-row min and max " + "functions with multiple sub-expressions"); } ExprNode minMaxNode; if (!isDistinct && numArgsPositional > 1 && !filtered) { // use the row function minMaxNode = new ExprMinMaxRowNode(minMaxTypeEnum); } else { // use the aggregation function minMaxNode = new ExprMinMaxAggrNode(isDistinct, minMaxTypeEnum, filtered, false); } minMaxNode.AddChildNodes(args); astExprNodeMap.Put(ctxArgs, minMaxNode); }
public override void SetUp() { base.SetUp(); _container = SupportContainer.Reset(); _maxNode = new ExprMinMaxAggrNode(false, MinMaxTypeEnum.MAX, false, false); _minNode = new ExprMinMaxAggrNode(false, MinMaxTypeEnum.MIN, false, false); ValidatedNodeToTest = MakeNode(MinMaxTypeEnum.MAX, 5, typeof(int)); }
public AggregationFactoryMethodMinMax( ExprMinMaxAggrNode parent, Type resultType, bool hasDataWindows) { this.parent = parent; // need the boxed type - even if the underlying type is a primitive, if no values come in then // we will end up with a null value for the aggregation. this.resultType = resultType.GetBoxedType(); this.hasDataWindows = hasDataWindows; }
public AggregationForgeFactoryMinMax( ExprMinMaxAggrNode parent, Type type, bool hasDataWindows, DataInputOutputSerdeForge serde, DataInputOutputSerdeForge distinctSerde) { this.parent = parent; this.type = type; this.hasDataWindows = hasDataWindows; this.serde = serde; this.distinctSerde = distinctSerde; }
public void TestGetType() { _maxNode.AddChildNode(new SupportExprNode(typeof(int))); SupportExprNodeFactory.Validate3Stream(_maxNode); Assert.AreEqual(typeof(int?), _maxNode.ReturnType); _minNode.AddChildNode(new SupportExprNode(typeof(float?))); SupportExprNodeFactory.Validate3Stream(_minNode); Assert.AreEqual(typeof(float?), _minNode.ReturnType); _maxNode = new ExprMinMaxAggrNode(false, MinMaxTypeEnum.MAX, false, false); _maxNode.AddChildNode(new SupportExprNode(typeof(short))); SupportExprNodeFactory.Validate3Stream(_maxNode); Assert.AreEqual(typeof(short?), _maxNode.ReturnType); }
private static ExprNode HandleMinMaxNode( string chainFirstLowerCase, Chainable spec) { MinMaxTypeEnum minMaxTypeEnum; var filtered = chainFirstLowerCase.StartsWith("f"); if (chainFirstLowerCase.Equals("min") || chainFirstLowerCase.Equals("fmin")) { minMaxTypeEnum = MinMaxTypeEnum.MIN; } else if (chainFirstLowerCase.Equals("max") || chainFirstLowerCase.Equals("fmax")) { minMaxTypeEnum = MinMaxTypeEnum.MAX; } else { throw new ValidationException("Uncountered unrecognized min or max node '" + spec.GetRootNameOrEmptyString() + "'"); } var args = spec.GetParametersOrEmpty(); var distinct = spec.IsDistinct; var numArgsPositional = ExprAggregateNodeUtil.CountPositionalArgs(args); if (numArgsPositional > 1 && spec.IsDistinct && !filtered) { throw new ValidationException( "The distinct keyword is not valid in per-row min and max " + "functions with multiple sub-expressions"); } ExprNode minMaxNode; if (!distinct && numArgsPositional > 1 && !filtered) { // use the row function minMaxNode = new ExprMinMaxRowNode(minMaxTypeEnum); } else { // use the aggregation function minMaxNode = new ExprMinMaxAggrNode(distinct, minMaxTypeEnum, filtered, false); } minMaxNode.AddChildNodes(args); return(minMaxNode); }
public AggregationMethodFactoryMinMax(ExprMinMaxAggrNode parent, Type type, bool hasDataWindows) { Parent = parent; Type = type; HasDataWindows = hasDataWindows; }