多表联合不能相连

我在多表联合的过程中遇到些麻烦,代码如下:

dbPath = "dfs://ctp_market_data"
tableName = "ctp_market_data"
T = loadTable(dbPath,tableName)

// 设置查询的时间范围
date_range = [2023.06.12]


for (date_t in date_range) {
contract_code = select concatDateTime(TradingDay, time(string(UpdateTime) + "." + lpad(string(UpdateMillisec), 3, "0"))) as TradingTime, UpdateTime, BidPrice1,BidVolume1,AskPrice1,AskVolume1,InstrumentID from T where TradingDay = date_t}


//提取合约代码中的各个部分
update contract_code set symbol_code = contract_code.InstrumentID.substr(0, regexFind(contract_code.InstrumentID, "[0-9]",1)) //品种代码
update contract_code set InstrumentID2=strReplace(InstrumentID,"-","")//去杠
update contract_code set future_code = InstrumentID2.substr(0,regexFind(InstrumentID2, "C|P",2))//标的代码
update contract_code set strike_prices = substr(contract_code.InstrumentID2.substr(regexFind(contract_code.InstrumentID2, "C|P",4)),regexFind(InstrumentID2.substr(regexFind(InstrumentID2, "C|P",4)), "[0-9]+"))//执行价 
update contract_code set OptionType = InstrumentID2.substr(regexFind(InstrumentID2, "C|P",4),1)//区分看跌看涨 


//提取所有看涨 和 看跌期权数据 和 标的期货数据
contract_code_c = select * from contract_code where OptionType = "C"
contract_code_p = select * from contract_code where OptionType = "P"
contract_code_f = select * from contract_code where OptionType = NULL

// 合并成同一行
data = select * from aj(contract_code_c, contract_code_p , `UpdateTime`strike_prices)

运行aj函数之后,结果是如下只有contract_code_c的数据:


attachments-2023-07-EqpeM4oh64a6bf318fd93.png

请先 登录 后评论

1 个回答

wale

aj的最后一个连接列通常为时间类型,改为如下试试:

data = select * from aj(contract_code_c, contract_code_p ,`strike_prices `UpdateTime) 
请先 登录 后评论