要加载到 table 中的 Hive 上下文

Hive Context to load into a table

我正在选择整个 table 并加载到新的 table.It 已正确加载,但值是附加的而不是覆盖。 星火1.6版 下面是代码片段

DataFrame df = hiveContext.createDataFrame(JavaRDD<Row>, StructType);
df.registerTempTable("tempregtable"); 
String query="insert into employee select * from tempregtable";
hiveContext.sql(query);

我正在删除并创建 table(员工)并执行上述 code.But 旧行值仍然附加新的 row.For 例如,如果我插入四行并且删除 table 并再次插入四行,总共 8 行得到了 added.Kindly 帮助我,如何覆盖数据而不是附加数据。

问候 普拉卡什

尝试

String query="insert overwrite table employee select * from tempregtable";

INSERT OVERWRITE 将覆盖 table 或分区

中的任何现有数据

INSERT INTO 将附加到 table 或分区

参考:Hive Language Manual