# SDP 파이프라인에서 Auto Loader + 스키마 진화
import dlt
@dlt.table(
comment="Bronze: 원본 이벤트 데이터"
)
def bronze_events():
return (
spark.readStream
.format("cloudFiles")
.option("cloudFiles.format", "json")
.option("cloudFiles.schemaEvolutionMode", "addNewColumns")
.option("cloudFiles.schemaLocation", "/checkpoints/schema")
.load("s3://bucket/raw/events/")
)
@dlt.table(
comment="Silver: 정제된 이벤트"
)
@dlt.expect_or_drop("valid_event_type", "event_type IS NOT NULL")
def silver_events():
return dlt.read_stream("bronze_events").select(
"event_id",
"event_type",
"user_id",
"timestamp"
# 명시적 컬럼 선택 → Bronze에 새 컬럼이 추가되어도 Silver에는 영향 없음
)