@@ -69,6 +69,7 @@ def init_client(
6969 expected_update : TSchemaTables ,
7070 truncate_filter : Callable [[str ], bool ],
7171 load_staging_filter : Callable [[str ], bool ],
72+ drop_staging_filter : Callable [[TTableSchema ], bool ],
7273 drop_tables : Optional [List [TTableSchema ]] = None ,
7374 truncate_tables : Optional [List [TTableSchema ]] = None ,
7475) -> TSchemaTables :
@@ -81,8 +82,9 @@ def init_client(
8182 schema (Schema): The schema as in load package
8283 new_jobs (Iterable[LoadJobInfo]): List of new jobs
8384 expected_update (TSchemaTables): Schema update as in load package. Always present even if empty
84- truncate_filter (Callable[[str], bool]): A filter that tells which table in destination dataset should be truncated
85- load_staging_filter (Callable[[str], bool]): A filter which tell which table in the staging dataset may be loaded into
85+ truncate_filter (Callable[[str], bool]): A filter that tells if table should be truncated
86+ load_staging_filter (Callable[[str], bool]): A filter which tell if table may be loaded into
87+ drop_staging_filter (Callable[[str], bool]): A filter which tell if table may be dropped
8688 drop_tables (Optional[List[TTableSchema]]): List of tables to drop before initializing storage
8789 truncate_tables (Optional[List[TTableSchema]]): List of tables to truncate before initializing storage
8890
@@ -111,8 +113,13 @@ def init_client(
111113 )
112114 )
113115
114- # get tables to drop
115- drop_table_names = {table ["name" ] for table in drop_tables } if drop_tables else set ()
116+ # get tables to drop, note that drop_tables are not in schema and come from the package
117+ # state
118+ drop_table_names = (
119+ {table ["name" ] for table in drop_tables if drop_staging_filter (table )}
120+ if drop_tables
121+ else set ()
122+ )
116123 job_client .verify_schema (only_tables = tables_with_jobs | dlt_tables , new_jobs = new_jobs )
117124 applied_update = _init_dataset_and_update_schema (
118125 job_client ,
0 commit comments