Hi @eballinger.
To address your requirement of updating only specific Delta Live Tables (DLT) in your testing environment without removing the others, you can leverage the @dlt.table decorator and the temporary parameter in your Python code. This approach allows you to create temporary tables that persist only for the lifetime of the pipeline run, thus preventing their removal when not referenced in subsequent runs.
Here’s how you can modify your pipeline to achieve this:
- Define Temporary Tables: Use the temporary=True parameter in the @dlt.table decorator to create tables that are not removed when not referenced in the pipeline run.
- Selective Table Updates: Dynamically generate the pipeline code to include only the tables you want to update. The temporary tables will persist for the duration of the pipeline run and will not be deleted if not referenced in subsequent runs.
Here’s an example of how you can define a temporary table
import dlt
@dlt.table(temporary=True)
def my_temp_table():
return spark.read.table("source_table")
In your dynamic pipeline generation logic, you can conditionally include or exclude tables based on your testing requirements. This way, you can run the pipeline for only the tables you need to update, and the temporary tables will not be removed if they are not included in the run.
Additionally, you can use the spark.read.table("LIVE.table_name") function to reference tables within the same pipeline, ensuring that the tables are correctly referenced during the pipeline execution