-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathsqlTuning.dos
More file actions
33 lines (30 loc) · 921 Bytes
/
sqlTuning.dos
File metadata and controls
33 lines (30 loc) · 921 Bytes
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
// 3.优化后代码
def toIntDate(d){
return year(d) * 10000 + monthOfYear(d) * 100 + dayOfMonth(d)
}
def transformData(tradeDate){
tradeSrc = loadTable("dfs://originData", "trade")
tradeTgt = loadTable("dfs://formatData", "trade")
data = select
securityID + "SZ" as securityID
,toIntDate(tradingdate) as tradingdate
,tradingtime$STRING as tradingtime
,recid as recid
,tradeprice
,tradevolume
,tradevolume * tradeprice as tradeamount
,buyorderid as buyrecid
,sellorderid as sellrecid
,iif(sellorderid> buyorderid,"S", "B") as buysellflag
,unix$LONG as unix
from tradeSrc
where tradingdate = tradeDate and tradetype in ["0", "F"]
tradeTgt.append!(data)
pnodeRun(flushOLAPCache)
}
allDays = 2022.05.01..2022.05.20
for(aDate in allDays){
jobId = "transform_"+ strReplace(aDate$STRING, ".", "")
jobDesc = "transform data"
submitJob(jobId, jobDesc, transformData, aDate)
}