SQL Hive 插入覆盖表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26168277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:43:58  来源:igfitidea点击:

Hive Insert Overwrite Table

sqlhiveinsertoverwrite

提问by Anna Mai

I'm new to Hive and I wanted to know if insert overwrite will overwrite an existing table I have created. I want to filter an already created table, let's call it TableA, to only select the rows where age is greater than 18. Can I achieve this using insert overwrite table?

我是 Hive 的新手,我想知道插入覆盖是否会覆盖我创建的现有表。我想过滤一个已经创建的表,我们称之为 TableA,只选择年龄大于 18 的行。我可以使用插入覆盖表来实现这一点吗?

I'm thinking of writing something like:

我正在考虑写一些类似的东西:

INSERT OVERWRITE TABLE TableA SELECT a.Age FROM TableA WHERE a.Age > = 18

there are NA entries in the table I created, but I assume that after I filter this table there will be no NAs in the Age column, right?

我创建的表中有 NA 条目,但我假设在我过滤此表后,年龄列中将没有 NA,对吗?

回答by K S Nidhin

Self filtering and insertion is not support , yet in hive.

不支持自过滤和插入,但在 hive 中。

I would suggest the following steps in your case :

对于您的情况,我建议采取以下步骤:

1.Create a similar table , say tabB , with same structure.

1.创建一个类似的表,比如 tabB ,具有相同的结构。

create table tabB like tableA;

2.Then you could apply your filter and insert into this new table.

2.然后你可以应用你的过滤器并插入到这个新表中。

INSERT OVERWRITE TABLE tabB SELECT a.Age FROM TableA WHERE a.Age > = 18

Hope this helps.

希望这可以帮助。