insert into table test values (1,'row1'),(2,'row2');
也可以select任意一张空表来insert
1 2
insert into table default.example_table (select 1L,'xiaodou',array(1L,2L,3L) from default.test limit 1);
如果遇到 Unable to create temp file for insert values Expression of type TOK_FUNCTION not supported in insert/values
1 2
insert into table test partition(ds="2019-08-20") select 1L,2,1S,1.111,"test",2Y,true,array(1,2,3),array(1Y,1Y,1Y),map('name','Xiao','age','20'),map(10L,false,20L,true),"lin","tong";
对于hive1和hive2,如果是parquet表修改字段类型产生冲突的时候,可能会报 Unable to alter table. The following columns have types incompatible with the existing columns in their respective positions
对于hive1和hive2,如果是parquet表修改字段类型产生冲突的时候,可能会报 Unable to alter table. The following columns have types incompatible with the existing columns in their respective positions
如果要控制数据只有一个文件的话,可以设置reduce任务的数量为1,然后添加 distribute by rand() 强行触发reduce任务
1 2 3 4 5 6 7
set mapred.reduce.tasks=1;
INSERT OVERWRITE DIRECTORY 's3://xx/xx/xx' ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' SELECT user_id FROM xx.xx where pdate="2022-08-06" distribute by rand();