-
Notifications
You must be signed in to change notification settings - Fork 14
/
upload-transactions-from-csv.sql
42 lines (34 loc) · 1.12 KB
/
upload-transactions-from-csv.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- ============================================================
-- Description:
-- 1. In this query, we run an ETL process on some transactions.
-- 2. First, we load a CSV file of transactions from Drive.
-- 3. Next, we transform the shape of the transaction data.
-- 4. Finally we upload the transaction data into LUSID.
-- ============================================================
-- Extract transaction data from LUSID Drive
@txn_data =
use Drive.Csv
--file=/luminesce-examples/transactions.csv
enduse;
-- Set variables for the portfolio's scope and code
@@portfolio_scope = select 'IBOR';
@@portfolio_code = select 'uk-equity';
--Transform data using SQL
@transactions =
select
@@portfolio_scope as PortfolioScope,
@@portfolio_code as PortfolioCode,
TransactionID as TxnId,
Type as Type,
TransactionDate as TransactionDate,
SettlementDate as SettlementDate,
Units as Units,
Price as TradePrice,
TotalConsideration as TotalConsideration,
Currency as SettlementCurrency,
ClientInternal as ClientInternal
from @txn_data;
-- Upload the transformed data into LUSID
select *
from Lusid.Portfolio.Txn.Writer
where ToWrite = @transactions;