From 4291338b2e258de09b724a0c72938403740ba38d Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 4 Mar 2024 16:50:14 +0100 Subject: [PATCH] add warning message for merge without merge keys --- dlt/common/destination/reference.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dlt/common/destination/reference.py b/dlt/common/destination/reference.py index ddcc5d1146..9ebcbed250 100644 --- a/dlt/common/destination/reference.py +++ b/dlt/common/destination/reference.py @@ -344,6 +344,16 @@ def _verify_schema(self) -> None: table_name, self.capabilities.max_identifier_length, ) + if ( + table.get("write_disposition") == "merge" + and (not has_column_with_prop(table, "primary_key")) + and (not has_column_with_prop(table, "merge_key")) + ): + logger.warning( + f'Table "{table_name}" in schema "{self.schema.name}" has write disposition' + ' "merge" but no primary key or merge keys specified. Loader will fall back to' + ' "append" write disposition for this table.' + ) if has_column_with_prop(table, "hard_delete"): if len(get_columns_names_with_prop(table, "hard_delete")) > 1: raise SchemaException(