sparksql 設置動態分區數報錯


set hive.exec.dynamic.partition=true;(可通過這個語句查看:set hive.exec.dynamic.partition;) 
set hive.exec.dynamic.partition.mode=nonstrict; 
注:這個屬性默認是strict,即限制模式,strict是避免全分區字段是動態的,必須至少一個分區字段是指定有值即靜態的,且必須放在最前面。
設置為nonstrict之后所有的分區都可以是動態的了。
SET hive.exec.max.dynamic.partitions=500000;(如果自動分區數大於這個參數,將會報錯)
注:這個屬性表示一個DML操作可以創建的最大動態分區數,默認是1000

SET hive.exec.max.dynamic.partitions.pernode=500000;

注:這個屬性表示每個節點生成動態分區的最大個數,默認是100
SET hive.exec.max.created.files=150000  
注:這個屬性表示一個DML操作可以創建的最大文件數,默認是100000

在sparksql中設置了這些參數,並將{HIVE_HOME}/conf/hive-site.xml移動至{SPARK_HOME}/conf下。
但是報錯如下:

Caused by: org.apache.hadoop.hive.ql.metadata.HiveFatalException: [Error 20004]: Fatal error occurred when node tried to create too many dynamic partitions. The maximum number of dynamic partitions is controlled by hive.exec.max.dynamic.partitions and hive.exec.max.dynamic.partitions.pernode. Maximum was set to: 10080
at org.apache.hadoop.hive.ql.exec.FileSinkOperator.getDynOutPaths(FileSinkOperator.java:877)
at org.apache.hadoop.hive.ql.exec.FileSinkOperator.processOp(FileSinkOperator.java:657)
at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:815)
at org.apache.hadoop.hive.ql.exec.SelectOperator.processOp(SelectOperator.java:84)
at org.apache.hadoop.hive.ql.exec.mr.ExecReducer.reduce(ExecReducer.java:244)
... 7 more

超過了最大的分區數設置。在spark中查詢"hive.exec.max.dynamic.partitions"的值,顯示為500000,好像參數設置是成功的,為什么還是報錯超過了最大分區數呢?

原因是,我的hive-site.xml文件中的hive的引擎是tez引擎,在sparksql中,不應該設置為該值,應該將該文件中hive的引擎設置為:mr。即:

hive.execution.engine=mr;  或者將該屬性去掉。在sparksql中,引擎不在是tez,它有自己的一套運行機制。
這樣問題就解決了。(hive的配置文件hive-site.xml不需要和{SPARK_HOME}/conf下的hive-site.xml一致。)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM