Read data from a comma-separated value (.csv) file, and aggregate the data using a volume-weighted average price (vwap) function.
The example creates a schema named TradeSchema, which is referenced by an input window named TradeWindow. The example attaches a File CSV Input adapter to TradeWindow.
The example creates an output window named VwapWindow, which outputs the results of the volume-weighted average price of the trade values processed by TradeWindow. The results are grouped by Symbol.
CREATE output WINDOW VwapWindow SCHEMA (Symbol STRING, vwap MONEY(4)) PRIMARY KEY DEDUCED AS SELECT TradeWindow.Symbol AS Symbol, ((SUM(TradeWindow.Price*TradeWindow.Volume)) / (SUM(TradeWindow.Volume))) AS vwap FROM TradeWindow GROUP BY TradeWindow.Symbol;