}
}
catch (ExprValidationException ex)
{
log.debug(".validateNodes Validation exception for filter=" + optionalFilterNode.toExpressionString(), ex);
throw new EPStatementException("Error validating expression: " + ex.getMessage(), ex, statementContext.getExpression());
}
}
if ((statementSpec.getOutputLimitSpec() != null) && ((statementSpec.getOutputLimitSpec().getWhenExpressionNode() != null) || (statementSpec.getOutputLimitSpec().getAndAfterTerminateExpr() != null)))
{
// Validate where clause, initializing nodes to the stream ids used
try
{
EventType outputLimitType = OutputConditionExpressionFactory.getBuiltInEventType(statementContext.getEventAdapterService());
StreamTypeService typeServiceOutputWhen = new StreamTypeServiceImpl(new EventType[] {outputLimitType}, new String[]{null}, new boolean[] {true}, statementContext.getEngineURI(), false);
ExprValidationContext validationContext = new ExprValidationContext(typeServiceOutputWhen, methodResolutionService, null, statementContext.getSchedulingService(), statementContext.getVariableService(), evaluatorContextStmt, statementContext.getEventAdapterService(), statementContext.getStatementName(), statementContext.getStatementId(), statementContext.getAnnotations(), statementContext.getContextDescriptor(), false);
ExprNode outputLimitWhenNode = statementSpec.getOutputLimitSpec().getWhenExpressionNode();
if (outputLimitWhenNode != null) {
outputLimitWhenNode = ExprNodeUtility.getValidatedSubtree(outputLimitWhenNode, validationContext);
statementSpec.getOutputLimitSpec().setWhenExpressionNode(outputLimitWhenNode);
if (JavaClassHelper.getBoxedType(outputLimitWhenNode.getExprEvaluator().getType()) != Boolean.class) {
throw new ExprValidationException("The when-trigger expression in the OUTPUT WHEN clause must return a boolean-type value");
}
EPStatementStartMethodHelperValidate.validateNoAggregations(outputLimitWhenNode, "An aggregate function may not appear in a OUTPUT LIMIT clause");
}
// validate and-terminate expression if provided
if (statementSpec.getOutputLimitSpec().getAndAfterTerminateExpr() != null) {
if (statementSpec.getOutputLimitSpec().getRateType() != OutputLimitRateType.WHEN_EXPRESSION && statementSpec.getOutputLimitSpec().getRateType() != OutputLimitRateType.TERM) {
throw new ExprValidationException("A terminated-and expression must be used with the OUTPUT WHEN clause");
}
ExprNode validated = ExprNodeUtility.getValidatedSubtree(statementSpec.getOutputLimitSpec().getAndAfterTerminateExpr(), validationContext);
statementSpec.getOutputLimitSpec().setAndAfterTerminateExpr(validated);
if (JavaClassHelper.getBoxedType(validated.getExprEvaluator().getType()) != Boolean.class) {
throw new ExprValidationException("The terminated-and expression must return a boolean-type value");
}
EPStatementStartMethodHelperValidate.validateNoAggregations(validated, "An aggregate function may not appear in a terminated-and clause");
}
// validate then-expression
validateThenSetAssignments(statementSpec.getOutputLimitSpec().getThenExpressions(), validationContext);
// validate after-terminated then-expression
validateThenSetAssignments(statementSpec.getOutputLimitSpec().getAndAfterTerminateThenExpressions(), validationContext);
}
catch (ExprValidationException ex)
{
throw new EPStatementException("Error validating expression: " + ex.getMessage(), statementContext.getExpression());
}
}
for (int outerJoinCount = 0; outerJoinCount < statementSpec.getOuterJoinDescList().length; outerJoinCount++)
{
OuterJoinDesc outerJoinDesc = statementSpec.getOuterJoinDescList()[outerJoinCount];
// validate on-expression nodes, if provided
if (outerJoinDesc.getOptLeftNode() != null) {
UniformPair<Integer> streamIdPair = validateOuterJoinPropertyPair(statementContext, outerJoinDesc.getOptLeftNode(), outerJoinDesc.getOptRightNode(), outerJoinCount,
typeService, viewResourceDelegate);
if (outerJoinDesc.getAdditionalLeftNodes() != null)
{
Set<Integer> streamSet = new HashSet<Integer>();
streamSet.add(streamIdPair.getFirst());
streamSet.add(streamIdPair.getSecond());
for (int i = 0; i < outerJoinDesc.getAdditionalLeftNodes().length; i++)
{
UniformPair<Integer> streamIdPairAdd = validateOuterJoinPropertyPair(statementContext, outerJoinDesc.getAdditionalLeftNodes()[i], outerJoinDesc.getAdditionalRightNodes()[i], outerJoinCount,
typeService, viewResourceDelegate);
// make sure all additional properties point to the same two streams
if ((!streamSet.contains(streamIdPairAdd.getFirst()) || (!streamSet.contains(streamIdPairAdd.getSecond()))))
{
String message = "Outer join ON-clause columns must refer to properties of the same joined streams" +
" when using multiple columns in the on-clause";
throw new EPStatementException("Error validating expression: " + message, statementContext.getExpression());
}
}
}
}