如上图,两个表的结构是一样的。
我想把dk_60081_zhjr_user_app_useinfo_d_month表中的符合条件的数据插入到td_special_month表中。
insert overwrite table hw_1_zyjk_qwsjxygj_101.td_special_month partition (stat_month = '202106') select * from hw_1_zyjk_qwsjxygj_101.dk_60081_zhjr_user_app_useinfo_d_month where stat_month='202106' and app_name in ('XXX');
然后就报错
Error: Error while compiling statement: FAILED: SemanticException [Error 10044]: Line 1:23 Cannot insert into target table because column number/types are different ''202106'': Table insclause-0 has 9 columns, but query has 10 columns. (state=42000,code=10044)
解决方案:
insert overwrite table hw_1_zyjk_qwsjxygj_101.td_special_month partition (stat_month = '202106') select serv_number,app_id,app_name,app_p_name,app_s_name,click_cnt,use_time,flax_all,statis_date from hw_1_zyjk_qwsjxygj_101.dk_60081_zhjr_user_app_useinfo_d_month where stat_month='202106' and app_name in ('XXX);
把select * 改成 select serv_number,app_id,app_name,app_p_name,app_s_name,click_cnt,use_time,flax_all,statis_date