import bubbles
src_url = 'postgresql://primarysite:primarysite@localhost/primarysite'
dest_url = 'postgresql://primarysite:primarysite@localhost/slicer_db'
stores = {'source': bubbles.open_store('sql', src_url),
'target': bubbles.open_store('sql', dest_url), }
pl = bubbles.pipeline.Pipeline(stores=stores)
pl.source('source', 'core_site')
pl.create('target', 'core_site')
pl.run()
{
'name': 'revenue_change',
'expression': "(lead(coalesce(sum(pl.revenue), 0)::integer, 1, 0) OVER (ORDER BY month_end DESC) - coalesce(sum(pl.revenue), 0)) AS delta"
}