我怎么才能让它工作呢?
hive> desc temp;
OK
a int
b int
Time taken: 0.077 seconds, Fetched: 2 row(s)
我想创建包含列名为c和d的t2配置单元表,但出现以下错误。
hive> create table t2(c int,d int) as select a,b from temp;
FAILED: SemanticException [Error 10065]: CREATE TABLE AS SELECT command cannot specify the list of columns for the target table
发布于 2017-04-03 16:11:00
您不需要再次提及表架构,因为您正在指定从另一个表获取架构。因此,您的表创建语句应该如下所示
create table t2 as select a,b from temp;
发布于 2018-06-16 09:14:11
我知道这很古老,但从定义上讲,如果其他人有同样的问题,答案很简单。
根据定义,CREATE TABLE AS SELECT
用于将结果集持久化为表。这意味着,如果您希望新表具有不同的列名,则需要使用不同的结果集来创建它。一种简单的方法是使用列别名:
create table t2 as select a as c, b as d from temp;
我知道您说过不想这样做(尽管有一个小的拼写错误-您的查询将失败,因为它将尝试将两个列都命名为c),但希望这解释了为什么您应该这样做:您需要构建一个数据集,其元数据与您想要创建的表相匹配。
https://stackoverflow.com/questions/43178920
复制相似问题