cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

I've set the partition mode to nonstrict in hive but spark is not seeing it

max522over
New Contributor II

I've got a table I want to add some data to and it's partitoned. I want to use dynamic partitioning but I get this error

org.apache.spark.SparkException: Dynamic partition strict mode requires at least one static partition column. To turn this off set hive.exec.dynamic.partition.mode=nonstrict

at org.apache.spark.sql.hive.execution.InsertIntoHiveTable.sideEffectResult$lzycompute(InsertIntoHiveTable.scala:168)

at org.apache.spark.sql.hive.execution.InsertIntoHiveTable.sideEffectResult(InsertIntoHiveTable.scala:127)

at org.apache.spark.sql.hive.execution.InsertIntoHiveTable.doExecute(InsertIntoHiveTable.scala:263)

I've set

hive.exec.dynamic.partition.mode=nonstrict

to nonstrict and I've restarted hive in ambari. But when I re run the spark-shell job I still get the error?

Should I set it elsewhere, in the hive config?

here is the command

df2.write.mode("append").partitionBy("p_date", "p_store_id").saveAsTable("TLD.ticket_pa

yment_testinsert")

df2 is a dataframe with a bunch of csv data read into it.

I've tried setting it in my spark-shell command

spark-shell --master yarn-client --packages com.databricks:spark-csv_2.11:1.4.0 --num-executors 4 --executor-cores 5 --executor-memory 8G --queue hadoop-capq --conf "hive.exec.dynamic.partition.mode=nonstrict"

but I get this warning

Warning: Ignoring non-spark config property: hive.exec.dynamic.partition.mode=nonstrict

1 ACCEPTED SOLUTION

Accepted Solutions

User16789201666
Databricks Employee
Databricks Employee

Try this:

hiveContext.setConf("hive.exec.dynamic.partition", "true") hiveContext.setConf("hive.exec.dynamic.partition.mode", "nonstrict")

http://stackoverflow.com/questions/31341498/save-spark-dataframe-as-dynamic-partitioned-table-in-hiv...

View solution in original post

3 REPLIES 3

User16789201666
Databricks Employee
Databricks Employee

Try this:

hiveContext.setConf("hive.exec.dynamic.partition", "true") hiveContext.setConf("hive.exec.dynamic.partition.mode", "nonstrict")

http://stackoverflow.com/questions/31341498/save-spark-dataframe-as-dynamic-partitioned-table-in-hiv...

ๆˆ‘ไนŸ้‡ๅˆฐ็ฑปไผผ้—ฎ้ข˜ไบ†๏ผŒ้€š่ฟ‡ไธŠ้ข็š„ๆ–นๆณ•่งฃๅ†ณไบ†๏ผŒ่ฐข่ฐข@peyman !

class JavaSparkSessionSingletonUtil {
private static transient SparkSession instance = null;
public static SparkSession getInstance(String appName) {
SparkSession.clearDefaultSession();
if (instance == null) {
instance = SparkSession.builder().appName(appName)
.config("hive.exec.dynamic.partition", "true")
.config("hive.exec.dynamic.partition.mode", "nonstrict")
//.config("spark.sql.warehouse.dir", new File("spark-warehouse").getAbsolutePath())
// .config("spark.driver.allowMultipleContexts", "true")
.enableHiveSupport().getOrCreate();
}
return instance;
}
}

max522over
New Contributor II

I got it working. This was exactly what I needed. Thank you @Peyman Mohajerianโ€‹ 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group