使用来自其他 table 的 select 创建外部 table
Create external table with select from other table
我正在使用 HDInsight,需要在完成 运行 查询后删除我的集群。但是,我需要收集到的数据才能再活一天。我正在处理将从 table1 创建计算列并将它们插入到 table2 中的查询。首先,我想要一个简单的测试来复制行。您可以从 select 语句创建外部 table 吗?
drop table if exists table2;
create external table table2 as
select *
from table1
STORED AS TEXTFILE LOCATION 'wasb://{container name}@{storage name}.blob.core.windows.net/';
是的,但是您必须将它分成两个命令。首先创建外部 table 然后填充它。
create external table table2(attribute STRING)
STORED AS TEXTFILE
LOCATION 'table2';
INSERT OVERWRITE TABLE table2 Select * from table1;
table2 的架构必须与 select 查询相同,在此示例中它仅包含一个字符串属性。
我知道这个问题太过时了,但这是解决方案。
CREATE EXTERNAL TABLE table2
STORED AS textfile
LOCATION wasb://....
AS SELECT * FROM table1
由于 Hive 不支持使用 "as select" 子句创建外部 table,首先我们需要使用完整的 DDL 命令创建外部 table,然后将数据加载到 table。请通过 this 了解不同的数据格式支持。
create external table table_ext(col1 typ1,...)
STORED AS ORC
LOCATION 'table2'; // optional if not provided then default location is used
INSERT OVERWRITE TABLE table_ext Select * from table1;
确保 table_ext 具有与 table1.
相同的 DDL
我正在使用 HDInsight,需要在完成 运行 查询后删除我的集群。但是,我需要收集到的数据才能再活一天。我正在处理将从 table1 创建计算列并将它们插入到 table2 中的查询。首先,我想要一个简单的测试来复制行。您可以从 select 语句创建外部 table 吗?
drop table if exists table2;
create external table table2 as
select *
from table1
STORED AS TEXTFILE LOCATION 'wasb://{container name}@{storage name}.blob.core.windows.net/';
是的,但是您必须将它分成两个命令。首先创建外部 table 然后填充它。
create external table table2(attribute STRING)
STORED AS TEXTFILE
LOCATION 'table2';
INSERT OVERWRITE TABLE table2 Select * from table1;
table2 的架构必须与 select 查询相同,在此示例中它仅包含一个字符串属性。
我知道这个问题太过时了,但这是解决方案。
CREATE EXTERNAL TABLE table2
STORED AS textfile
LOCATION wasb://....
AS SELECT * FROM table1
由于 Hive 不支持使用 "as select" 子句创建外部 table,首先我们需要使用完整的 DDL 命令创建外部 table,然后将数据加载到 table。请通过 this 了解不同的数据格式支持。
create external table table_ext(col1 typ1,...)
STORED AS ORC
LOCATION 'table2'; // optional if not provided then default location is used
INSERT OVERWRITE TABLE table_ext Select * from table1;
确保 table_ext 具有与 table1.
相同的 DDL