有什么快捷函数可以把第一张表扩展成第二张表吗,就是把start_no-end_no之间的数据都输出成一条一套记录

attachments-2022-09-nxf7zb0Z6317178ccfcd0.png

attachments-2022-09-WOf5MCLf63171794edadc.png

请先 登录 后评论

1 个回答

mhxiang


用each函数对原始表的每一行调用cj函数,对原始表的每一行数据生成的表和start_no与end_no生成的连续数据表执行交叉连接,然后用unionAll合并结果。

start_no=[565663,565918,566010,566363,566512]
end_no=[565722,565983,566245,566487,566550]
tb=table(take(2022.06.01,5) as date,take(`src55,5) as source,take(`SZ,5) as market,take(2011,5) as channel_no,start_no  , end_no,take(1,5) as err_type)

def f(tb,i){
        tt=select date,source,market,channel_no,err_type from tb where rowNo(date)=i
        start_no=tb[i]['start_no']
        end_no=tb[i]['end_no']
        return cj(tt,table(start_no..end_no as seq_no))
        }
        
tb=unionAll(each(f{tb},1..size(tb)-1),false)



attachments-2022-09-3L2qHFSJ6322faeadfe61.png


请先 登录 后评论
  • 1 关注
  • 0 收藏,777 浏览
  • haaha 提出于 2022-09-06 17:49

相似问题