Aggregate. Generates an XML tree contianing all matches detected by a pattern-matching query.
The XMLPATTERNMATCH function performs causality tracking by generating an XML tree that contains all matches (except non-events) detected by a pattern-matching query. This function is allowed only in the SELECT clause of a query that contains a MATCHING clause. XMLPATTERNMATCH() generates an XML tree for every group of events that produces the match specified in the MATCHING clause, except events specified by the !stream-name syntax.
The root element contains an element for each of the data streams involved in the pattern match. Where the streams in question are aliased, the corresponding element has the name of the stream's alias. Each element has the same name as the corresponding stream (or its alias, if one exists).
Every element associated with a data stream contains a sub-element for each column defined in the stream schema and having the same name. Each of the column sub-elements contains its respective row value. Regardless of whether or not a timestamp column is defined in the schema, a sub-element called "C8_Timestamp" containing the row timestamp value is automatically created in the element associated with the stream.
While stream and column names are case-insensitive in CCL, XML element names are case-sensitive. In creating the element tree, XMLPATTERNMATCH() uses the same capitalization as is specified in the root-element-name argument, stream aliases or (in the absence of an alias) stream definitions, and schema column definitions.
The following example shows two stream schema definitions, followed by a query that uses the XMLPATTERNMATCH function:
CREATE STREAM Trades SCHEMA (Symbol STRING, Quantity FLOAT, Price FLOAT); CREATE STREAM Quotes SCHEMA (Symbol STRING, Bid FLOAT, Ask FLOAT); INSERT INTO TradeMismatch SELECT XMLPATTERNMATCH() FROM Quotes as Q, Trades as T MATCHING [10 seconds: Q, T] ON Q.Symbol = T.Symbol WHERE T.Price < Q.Bid OR T.Price > Q.Ask
The following sample XML tree was generated by XMLPATTERNMATCH when a pattern match is detected by the query:
<PatternMatch> <Q> <C8_Timestamp> 2207-11-26 16:23:27.203157 </C8_Timestamp> <Symbol> IBM </Symbol> <Bid> 102 </Bid> <Ask> 104 </Ask> </Q> <T> <C8_Timestamp> 2207-11-26 16:25:53.307201 </C8_Timestamp> <Symbol> IBM </Symbol> <Quantity> 100 </Quantity> <Price> 98 </Price> </T> <PatternMatch>