public static ExprNodeSubselectVisitor walkSubselectAndDeclaredDotExpr(StatementSpecRaw spec) throws ExprValidationException {
// Look for expressions with sub-selects in select expression list and filter expression
// Recursively compile the statement within the statement.
ExprNodeSubselectVisitor visitor = new ExprNodeSubselectVisitor();
for (SelectClauseElementRaw raw : spec.getSelectClauseSpec().getSelectExprList())
{
if (raw instanceof SelectClauseExprRawSpec)
{
SelectClauseExprRawSpec rawExpr = (SelectClauseExprRawSpec) raw;
rawExpr.getSelectExpression().accept(visitor);
}
else
{
continue;
}
}
if (spec.getFilterRootNode() != null)
{
spec.getFilterRootNode().accept(visitor);
}
if (spec.getUpdateDesc() != null)
{
if (spec.getUpdateDesc().getOptionalWhereClause() != null)
{
spec.getUpdateDesc().getOptionalWhereClause().accept(visitor);
}
for (OnTriggerSetAssignment assignment : spec.getUpdateDesc().getAssignments())
{
assignment.getExpression().accept(visitor);
}
}
if (spec.getOnTriggerDesc() != null) {
visitSubselectOnTrigger(spec.getOnTriggerDesc(), visitor);
}
// Determine pattern-filter subqueries
for (StreamSpecRaw streamSpecRaw : spec.getStreamSpecs()) {
if (streamSpecRaw instanceof PatternStreamSpecRaw) {
PatternStreamSpecRaw patternStreamSpecRaw = (PatternStreamSpecRaw) streamSpecRaw;
EvalNodeAnalysisResult analysisResult = EvalNodeUtil.recursiveAnalyzeChildNodes(patternStreamSpecRaw.getEvalFactoryNode());
for (EvalFactoryNode evalNode : analysisResult.getActiveNodes()) {
if (evalNode instanceof EvalFilterFactoryNode) {
EvalFilterFactoryNode filterNode = (EvalFilterFactoryNode) evalNode;
for (ExprNode filterExpr : filterNode.getRawFilterSpec().getFilterExpressions()) {
filterExpr.accept(visitor);
}
}
else if (evalNode instanceof EvalObserverFactoryNode) {
int beforeCount = visitor.getSubselects().size();
EvalObserverFactoryNode observerNode = (EvalObserverFactoryNode) evalNode;
for (ExprNode param : observerNode.getPatternObserverSpec().getObjectParameters()) {
param.accept(visitor);
}
if (visitor.getSubselects().size() != beforeCount) {
throw new ExprValidationException("Subselects are not allowed within pattern observer parameters, please consider using a variable instead");
}
}
}
}