Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot change hive.exec.max.dynamic.partitions in Spark

I'm trying to insert some data in a table that will have 1500 dynamic partitions and I receive this error:

 Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: 
 Number of dynamic partitions created is 1500, which is more than 1000. 
 To solve this try to set hive.exec.max.dynamic.partitions to at least 1500.

So, I try to: SET hive.exec.max.dynamic.partitions=2048 but I still get the same error.

How can I change this value from Spark?

Code:

this.spark.sql("SET hive.exec.dynamic.partition=true")
this.spark.sql("set hive.exec.dynamic.partition.mode=nonstrict")
this.spark.sql("SET hive.exec.max.dynamic.partitions=2048")
this.spark.sql(
    """
      |INSERT INTO processed_data
      |PARTITION(event, date)
      |SELECT c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,event,date FROM csv_data DISTRIBUTE BY event, date
    """.stripMargin
).show()

Using Spark 2.0.0 standalone mode. Thank you!

like image 471
Gogu Avatar asked Nov 09 '16 11:11

Gogu


People also ask

What is hive exec Max dynamic partitions?

hive. exec. max. dynamic. partitions : The maximum number of partitions allowed to be created in total by one dynamic partition insert.

Can I limit the number of partitions in hive?

Single Query LimitationA single query cannot commit more than 500,000 (500K) partitions. To avoid this, define the time range of the query to remain within this limitation.

Is there any relationship between hive and Spark partitioning?

They are both chunks of data, but Spark splits data in order to process it in parallel in memory. Hive partition is in the storage, in the disk, in persistence.


1 Answers

From spark 2.x version, adding hive set properties in Spark CLI may not work. Please add your hive set properties in hive-site.xml of your both spark and hive conf directories.

adding below property in hive-site.xml file should resolve your issue.

<name>hive.exec.max.dynamic.partitions</name>
<value>2048</value>
<description></description>

Note: restart hiveserver2 and spark history server if it didn't work.

like image 86
Vinay Kumar Dudi Avatar answered Sep 23 '22 07:09

Vinay Kumar Dudi