emanueledellavalle / streaming-data-analytics

Apache License 2.0
30 stars 11 forks source link

Join stream to "table" in epl #42

Open emanueledellavalle opened 2 months ago

emanueledellavalle commented 2 months ago

si potrebbe utilizzare la finestra #keepall per "simulare una table" e spiegare il join stream to table in epl.

Ecco un esempio completo funzionante:

EPL Statements

create schema StockTick(symbol string, price double);

create schema StockSymbol(symbol string, name string);

@Name('Out') select s.name AS name, t.price AS price
from StockTick.win:length(1) AS t, StockSymbol#keepall AS s
where t.symbol=s.symbol;

Time And Event Sequence

StockSymbol={symbol='GE',name='General Electric'}
StockSymbol={symbol='YHOO',name='Yahoo!'}
StockTick={symbol='GE', price=20.5}

t=t.plus(5 seconds)

StockTick={symbol='YHOO', price=65}

Scenario Results

 At: 2001-01-01 08:00:00.000

    Statement: Out
        Insert
            Out-output={name='General Electric', price=20.5}

At: 2001-01-01 08:00:05.000

    Statement: Out
        Insert
            Out-output={name='Yahoo!', price=65.0}

Esempio preso dalla guida

select * from RfidEvent#time(30 sec) as rfid
      left outer join ProductName#keepall as refprod
        on rfid.productId = refprod.prodId
      left outer join LocationDescription#keepall as refdesc
        on rfid.location = refdesc.locId

[src: 5.12.3. Outer, Left and Right Joins]