[英]UNION ALL doesn't generate any data in Hive
我正在嘗試對具有相同DDL結構的三個不同表執行UNION ALL,但最終輸出將生成零行。 我不知道底層執行中發生了什么。 有人可以分享您的想法嗎? 我的示例Hive SQL如下所示。 謝謝。
SET hive.execution.engine=tez;
SET hive.exec.dynamic.partition.mode=nonstrict;
SET hive.qubole.cleanup.partial.data.on.failure=true;
SET hive.tez.container.size=8192;
SET tez.task.resource.memory.mb=8192;
SET tez.task.resource.cpu.vcores=2;
SET hive.mapred.mode=nonstrict;
SET hive.qubole.dynpart.use.prefix=true;
SET hive.vectorized.execution.enabled=true;
SET hive.vectorized.execution.reduce.enabled =true;
SET hive.cbo.enable=true;
SET hive.compute.query.using.stats=true;
SET hive.stats.fetch.column.stats=true;
SET hive.stats.fetch.partition.stats=true;
SET mapred.reduce.tasks = -1;
SET hive.auto.convert.join.noconditionaltask.size=2730;
SET hive.auto.convert.join=true;
SET hive.auto.convert.join.noconditionaltask=true;
SET hive.auto.convert.join.noconditionaltask.size=405306368;
SET hive.compute.query.using.stats=true;
SET hive.stats.fetch.column.stats=true;
SET hive.stats.fetch.partition.stats=true;
SET mapreduce.job.reduce.slowstart.completedmaps=0.8;
CREATE TABLE IF NOT EXISTS X STORED AS PARQUET AS
SELECT a,
b,
c
FROM A
UNION ALL
SELECT a,
b,
c
FROM B
UNION ALL
SELECT a,
b,
c
FROM C;
如果我嘗試在Presto上運行以下查詢,則表明有數據。
SELECT COUNT(1) FROM
(
SELECT a,
b,
c
FROM A
UNION ALL
SELECT a,
b,
c
FROM B
UNION ALL
SELECT a,
b,
c
FROM C
)Z;
在Tez上運行時, UNION ALL
將並行運行,並在表位置中創建其他子目錄(檢查表位置中的內容)。 在讀取表之前,請嘗試添加以下配置設置,以允許Hive讀取子目錄:
set hive.mapred.supports.subdirectories=true;
set mapred.input.dir.recursive=true;
您的查詢非常簡單,僅在映射器上運行,每個子查詢都寫有自己的子目錄,並且不會干擾另一個子目錄。
另外,您可以distribute by
在末尾添加“ distribute by
”或order by
(運行速度會更慢),運行UNION而不是UNION ALL來強制額外的reducer階段,在union之后應用過濾器等-它將在表文件夾中創建文件而沒有子目錄:
CREATE TABLE IF NOT EXISTS X STORED AS PARQUET AS
select * from
(
SELECT a,
b,
c
FROM A
UNION ALL
SELECT a,
b,
c
FROM B
UNION ALL
SELECT a,
b,
c
FROM C
)s distribute by a; --this will force reducer step
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.