Definição
Aplica um fluxo de CDC numa tabela de destino, como SCD tipo 1 ou tipo 2, tratando ordem e exclusões.
Nas versões recentes a mesma operação chama-se create_auto_cdc_flow (AUTO CDC em SQL).
Exemplos
1. SCD tipo 1
dlt.create_streaming_table("silver_customers")
dlt.apply_changes(
target="silver_customers",
source="cdc_customers",
keys=["customer_id"],
sequence_by=F.col("changed_at"),
apply_as_deletes=F.expr("operation = 'D'"),
except_column_list=["operation"])2. SCD tipo 2 (histórico)
dlt.create_streaming_table("dim_customer_history")
dlt.apply_changes(
target="dim_customer_history",
source="cdc_customers",
keys=["customer_id"],
sequence_by=F.col("changed_at"),
stored_as_scd_type=2)3. Histórico só de algumas colunas
dlt.apply_changes(
target="dim_customer_history",
source="cdc_customers",
keys=["customer_id"],
sequence_by=F.col("changed_at"),
stored_as_scd_type=2,
track_history_column_list=["segment", "city"])