1 为了便于测试,需要mock一些数据,并尽可能随机散列,比如说要为每个客户随机生成一个字段值 到访客户 / 成交客户 / 会员客户
实现方式:
split('到访客户 成交客户 会员客户',' ')[cast(rand()*3 as int)]
通过rand()生成随机小数0-1之间
cast(double*n as int):将小数转换成随机整数下标,n为值字典的个数
2将随机整数插入临时表
insert into tmp values(cast(rand()*88 as int),'good');
FAILED: SemanticException [Error 10293]: Unable to create temp file for insert values Expression of type TOK_FUNCTION not supported in insert/values
改成: insert into tmp (select cast(rand()*88 as int ),'goodboy'); 即可
3 表结构为tmp(id string, name string),也可以直接插入:一个int类型的id insert into tmp values (111,'good');