Skip to content

Instantly share code, notes, and snippets.

@edgars
Created November 9, 2018 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgars/1ead1997a5d4b7d38a059c2472640c03 to your computer and use it in GitHub Desktop.
Save edgars/1ead1997a5d4b7d38a059c2472640c03 to your computer and use it in GitHub Desktop.
@App:name('ETLStreamApp')
@App:description('ETL from CSV ')
@source(type = 'file', mode = 'line', tailing = 'false', dir.uri = 'file:/Users/edgar/Documents/DEV/2018/SP/ETL/IN', action.after.process = 'delete',
@map(type = 'csv', header = 'true',
@attributes(distrito = '2', endereco = '1', latitude = '7', crime = '5', dataHora = '0', codigocrime = '6', longitude = '8')))
define stream CargaInicialCrimesStream (dataHora string, endereco string, distrito string, crime string, codigocrime string, latitude string, longitude string);
@sink(type = 'log', priority="info")
define stream Distrito115Stream (dataHora string, endereco string, crime string, latitude string, longitude string);
define stream TotalDeLinhasStream (totalCount long);
-- Count the incoming events
@info(name = 'QueryTotalDeLinhas')
from CargaInicialCrimesStream
select count() as totalCount
insert into TotalDeLinhasStream;
-- Distrito equals 115
@info(name = 'QueryDistritoIgual115')
from CargaInicialCrimesStream[(distrito == "115")]
select dataHora, endereco, crime, latitude, longitude
insert into Distrito115Stream;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment