Azure 在配置单元中,如何将数据插入到单个文件中

Azure 在配置单元中,如何将数据插入到单个文件中,azure,hadoop,Azure,Hadoop,插入覆盖目录'wasb:///hiveblob/' 从表1中选择*; 但当我们发出命令时 插入覆盖目录'wasb:///hiveblob/sample.csv' 从表1中选择*; 失败,出现异常无法重命名:wasb://incrementalhive-1@crmdbs.blob.core.windows.net/hive/scratch/hive_2015-06-08_10-01-03_930_4881174794406290153-1//-ext-10000至:wasb:/hiveblob/s

插入覆盖目录'wasb:///hiveblob/' 从表1中选择*; 但当我们发出命令时 插入覆盖目录'wasb:///hiveblob/sample.csv' 从表1中选择*; 失败,出现异常无法重命名:wasb://incrementalhive-1@crmdbs.blob.core.windows.net/hive/scratch/hive_2015-06-08_10-01-03_930_4881174794406290153-1//-ext-10000至:wasb:/hiveblob/sample.csv


那么,是否有任何方法可以将数据插入到单个文件中

默认情况下,您将有多个输出文件,等于还原器的数量。这是由蜂巢决定的。但是,您可以配置减速器。看但是,如果我们减少减缩器,并将运行更多的执行时间,那么性能可能会受到影响。或者,文件出现后,可以使用get merge,将所有文件合并到一个文件中


hadoop fs-getmerge/your/src/folder/your/dest/folder/yourFileName。src文件夹包含所有要合并的文件。

默认情况下,您将有多个输出文件,等于还原器的数量。这是由蜂巢决定的。但是,您可以配置减速器。看但是,如果我们减少减缩器,并将运行更多的执行时间,那么性能可能会受到影响。或者,文件出现后,可以使用get merge,将所有文件合并到一个文件中


hadoop fs-getmerge/your/src/folder/your/dest/folder/yourFileName。src文件夹包含所有要合并的文件。

我认为您无法让hive写入特定的文件,如wasb:///hiveblob/foo.csv 直接的

您可以做的是:

在运行查询之前,告诉配置单元将输出文件合并为一个文件。 通过这种方式,您可以拥有任意多个还原器,并且仍然拥有单个输出文件

运行您的查询,例如插入覆盖目录

然后在配置单元中使用dfs-mv将文件重命名为任何名称

这可能比按照Ramzy的建议使用单独的hadoop fs-getMerge/your/src/folder/your/dest/folder/yourFileName痛苦得多

根据所使用的运行时引擎的不同,指示合并文件的方式可能会有所不同

例如,如果在配置单元查询中使用tez作为运行时引擎,则可以执行以下操作:

-- Set the tez execution engine
-- And instruct to merge the results
set hive.execution.engine=tez;
set hive.merge.tezfiles=true;

-- Your query goes here.
-- The results should end up in wasb:///hiveblob/000000_0 file.
INSERT OVERWRITE DIRECTORY 'wasb:///hiveblob/' SELECT * from table1;


-- Rename the output file into whatever you want
dfs -mv 'wasb:///hiveblob/000000_0' 'wasb:///hiveblob/foo.csv'
以上这些版本对我很有用:HDP2.2、Tez 0.5.2和Hive 0.14.0

对于默认的MapReduce引擎,您可以尝试以下方法,尽管我自己还没有尝试过:

-- Try this if you use MapReduce engine.
set hive.execution.engine=mr;
set hive.merge.mapredfiles=true;

我不认为你可以告诉hive写一个特定的文件,比如wasb:///hiveblob/foo.csv 直接的

您可以做的是:

在运行查询之前,告诉配置单元将输出文件合并为一个文件。 通过这种方式,您可以拥有任意多个还原器,并且仍然拥有单个输出文件

运行您的查询,例如插入覆盖目录

然后在配置单元中使用dfs-mv将文件重命名为任何名称

这可能比按照Ramzy的建议使用单独的hadoop fs-getMerge/your/src/folder/your/dest/folder/yourFileName痛苦得多

根据所使用的运行时引擎的不同,指示合并文件的方式可能会有所不同

例如,如果在配置单元查询中使用tez作为运行时引擎,则可以执行以下操作:

-- Set the tez execution engine
-- And instruct to merge the results
set hive.execution.engine=tez;
set hive.merge.tezfiles=true;

-- Your query goes here.
-- The results should end up in wasb:///hiveblob/000000_0 file.
INSERT OVERWRITE DIRECTORY 'wasb:///hiveblob/' SELECT * from table1;


-- Rename the output file into whatever you want
dfs -mv 'wasb:///hiveblob/000000_0' 'wasb:///hiveblob/foo.csv'
以上这些版本对我很有用:HDP2.2、Tez 0.5.2和Hive 0.14.0

对于默认的MapReduce引擎,您可以尝试以下方法,尽管我自己还没有尝试过:

-- Try this if you use MapReduce engine.
set hive.execution.engine=mr;
set hive.merge.mapredfiles=true;

您可以通过强制还原为一个文件来强制配置单元生成一个文件。这将复制一个表中的任何碎片文件,并将它们合并到HDFS中的另一个位置。当然,强制使用一个减速器会破坏并行性的好处。如果您计划进行任何数据转换,我建议您先进行转换,然后在最后一个单独的阶段进行转换

要使用配置单元生成单个文件,您可以尝试:

set hive.exec.dynamic.partition.mode=nostrict;
set hive.exec.compress.intermediate=false;
set hive.exec.compress.output=false;
set hive.exec.reducers.max=1;

create table if not exists db.table
stored as textfiel as
select * from db.othertable;

db.othertable是包含多个碎片文件的表。db.table将有一个包含组合数据的文本文件

您可以通过强制缩减器为一个文件来强制配置单元生成一个文件。这将复制一个表中的任何碎片文件,并将它们合并到HDFS中的另一个位置。当然,强制使用一个减速器会破坏并行性的好处。如果您计划进行任何数据转换,我建议您先进行转换,然后在最后一个单独的阶段进行转换

要使用配置单元生成单个文件,您可以尝试:

set hive.exec.dynamic.partition.mode=nostrict;
set hive.exec.compress.intermediate=false;
set hive.exec.compress.output=false;
set hive.exec.reducers.max=1;

create table if not exists db.table
stored as textfiel as
select * from db.othertable;
db.othertable是包含多个碎片文件的表。db.table将有一个包含组合数据的文本文件