반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

지구정복

[Spark] Dynamic partition strict mode requires at least one static partition column Error 본문

데이터 엔지니어링 정복/Spark

[Spark] Dynamic partition strict mode requires at least one static partition column Error

noohhee 2025. 4. 15. 17:14
728x90
반응형

 

Spark를 이용해서 Hive 테이블 쓰기 작업중 아래 에러가 발생했다.

com.streamsets.datatransformer.dag.error.OperatorFailureException: Operator Hive_01 failed due to org.apache.spark.SparkException
	at com.streamsets.datatransformer.dag.BaseBatchDAGRunner.com$streamsets$datatransformer$dag$BaseBatchDAGRunner$$generateOperatorFailure(BaseBatchDAGRunner.scala:664)
	at com.streamsets.datatransformer.dag.BaseBatchDAGRunner$$anon$3.call(BaseBatchDAGRunner.scala:722)
	at com.streamsets.datatransformer.dag.BaseBatchDAGRunner$$anon$3.call(BaseBatchDAGRunner.scala:698)
	at com.streamsets.datatransformer.dag.BaseBatchDAGRunner$$anonfun$materialize$2$$anon$4.call(BaseBatchDAGRunner.scala:739)
	at com.streamsets.datatransformer.dag.BaseBatchDAGRunner$$anonfun$materialize$2$$anon$4.call(BaseBatchDAGRunner.scala:735)
	at com.streamsets.datacollector.security.GroupsInScope.execute(GroupsInScope.java:34)
	at com.streamsets.datatransformer.dag.BaseBatchDAGRunner$$anon$2.call(BaseBatchDAGRunner.scala:691)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: 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

 

 

먼저 hive table에서 dynamic partition 개념에 대해 알아본다.

 

* Static Partition

해당 partition table에 새로운 data를 insert할 때 어떤 partition에 data를 insert할지를 명시해줘야한다.

아래처럼 basis_date = '20210325'라고 명시해줬다.

insert into test_table partition (basis_date = '20210325')
select *
from source_table

 

 

* Dynamic Partition

Partition Column명만 명시하고 Partition Column의 값은 명시하지 않아도 된다.

insert into tm.tbl_dynamic partition(ptn_date)

 

기본적으로 Hive는 static partition을 사용한다.

 

만약 Dynamic Partition을 사용하기 위한 Hive 설정값은 다음과 같다.

 

hive.exec.dynamic.partition=false (default)

hive.exec.dynamic.partition.mode=strict (default) 정적 파티션 사용

 

동적 파티션을 사용하려면 아래처럼 변경해야한다.

hive.exec.dynamic.partition=true

hive.exec.dynamic.partition.mode=nonstrict

 

Spark에서 Hive 연결한다면 hive-site.conf에 아예 설정해도되고,

만약 Spark session에서만 사용한다면 아래처럼 설정해준다.

spark=SparkSession \
	.builder \
    .appName('TEST_QUERY) \
    .config('hive.exec.dynamic.partition', 'true') \
    .config('hive.exec.dynamic.partition.mode', 'nonstrict') \
    .enableHiveSupport() \
    .getOrCreate()

 

 

 

 

 

 

 

 

 

728x90
반응형
Comments