MATCH_RECOGNIZE and the WHERE Clause Referencing Singleton and Group Matches

Pattern Recognition With MATCH_RECOGNIZE 19-7 Consider Example 19–8 . Assume that the schema of S includes attributes account and balance. This query returns an event for each account that has not received 3 or more events in 60 minutes. Example 19–8 MATCH_RECOGNIZE Query Using countA. select T.account, T.Atime FROM S MATCH_RECOGNIZE PARTITION BY account MEASURES A.account has account A.ELEMENT_TIME as Atime ALL MATCHES INCLUDE TIMER EVENTS PATTERN A+ DURATION 60 MINUTES DEFINE A AS countA. 3 as T The PATTERN A+ specifies the pattern Match A one or more times. The DEFINE clause specifies the condition: A AS countA. 3 This condition for A places no restrictions on input tuples such as A.balance 1000. The only restrictions are imposed by the PARTITION BY account and DURATION 60 MINUTES clauses. In the DEFINE clause, the A. means, Match all input tuples for the group A+. This group includes the one or more input tuples with a particular account received in the 60 minutes starting with the first input tuple. The countA. is a running aggregate that returns the total number of events in this group. If the DEFINE clause specifies the condition: A AS A.balance 1000 and countA. 3 Then A. still means Match all input tuples for the group A+. In this case, this group includes the one or more input tuples with a particular account received in the 60 minutes starting with the first input tuple and with balance 1000. In contrast: identifier . The number of all tuples that match the correlation variable identifier, including duplicates and nulls. Note the following: ■ countA. = 1 is true for the first event that matches A. ■ countA. = 0 is true while A has not been matched yet. identifier .attr The number of tuples that match correlation variable identifier, where attr is not NULL. Table 19–1 Cont. Return Values for count Aggregate Function Input Argument Return Value 19-8 Oracle Complex Event Processing CQL Language Reference ■ count means The number of all tuples, including duplicates and nulls. That is, the number of all tuples received on S, whether they satisfy the MATCH_ RECOGNIZE clause or not. ■ countA.balance means The number of all tuples that match the correlation variable A where the balance is not NULL. For more information, see: ■ count on page 9-5 ■ Section 1.1.3.1.1, Range, Rows, and Slide at Query Start-Up and for Empty Relations ■ Section 19.1.2, Referencing Singleton and Group Matches ■ Section 19.1.3, Referencing Aggregates