-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathloadOneFile.dos
34 lines (30 loc) · 1.13 KB
/
loadOneFile.dos
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
//单个CSV文件导入
login(`admin,`123456)
//建库建表
if (existsDatabase("dfs://sh_entrust"))
{
dropDatabase("dfs://sh_entrust")
}
create database "dfs://sh_entrust" partitioned by VALUE(2022.01.01..2022.01.03), HASH([SYMBOL, 10]), engine='TSDB'
create table "dfs://sh_entrust"."entrust"(
SecurityID SYMBOL,
TransactTime TIMESTAMP,
valOrderNoue INT,
Price DOUBLE,
Balance INT,
OrderBSFlag SYMBOL,
OrdType SYMBOL,
OrderIndex INT,
ChannelNo INT,
BizIndex INT)
partitioned by TransactTime,SecurityID,
sortColumns = [`SecurityID,`TransactTime]
//定义类型转换函数
def transType(mutable memTable)
{
return memTable.replaceColumn!(`col0,lpad(string(memTable.col0),6,`0)).replaceColumn!(`col1,datetimeParse(string(memTable.col1),"yyyyMMddHHmmssSSS")).replaceColumn!(`col5,string(memTable.col5)).replaceColumn!(`col6,string(memTable.col6))
}
//提交任务,下面的目录根据实际情况修改
filePath = "/home/ychan/data/loadForPoc/SH/Order/20210104/Entrust.csv"
db = database("dfs://sh_entrust")
loadTextEx(dbHandle = db, tableName = `entrust, partitionColumns = `col1`col0, filename = filePath, transform = transType, skipRows = 1)