From 880f5998d68ac594a122adb93bf3c9bd69fece21 Mon Sep 17 00:00:00 2001 From: Minura Punchihewa Date: Sun, 8 Sep 2024 14:31:31 +0530 Subject: [PATCH] moved the val func for checking if write_mode supported to ExternalTable --- .../kedro_datasets/databricks/_base_table_dataset.py | 7 ------- .../databricks/external_table_dataset.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/kedro-datasets/kedro_datasets/databricks/_base_table_dataset.py b/kedro-datasets/kedro_datasets/databricks/_base_table_dataset.py index 7a850c7a4..6188ff69e 100644 --- a/kedro-datasets/kedro_datasets/databricks/_base_table_dataset.py +++ b/kedro-datasets/kedro_datasets/databricks/_base_table_dataset.py @@ -121,13 +121,6 @@ def _validate_write_mode(self): f"`write_mode` must be one of: {valid_modes}" ) - # Upserts are only supported for delta tables. - if self.write_mode == "upsert" and self.format != "delta": - raise DatasetError( - f"Format '{self.format}' is not supported for upserts. " - f"Please use 'delta' format." - ) - def _validate_dataframe_type(self): """Validates the dataframe type. diff --git a/kedro-datasets/kedro_datasets/databricks/external_table_dataset.py b/kedro-datasets/kedro_datasets/databricks/external_table_dataset.py index 453d538d9..94e285dd0 100644 --- a/kedro-datasets/kedro_datasets/databricks/external_table_dataset.py +++ b/kedro-datasets/kedro_datasets/databricks/external_table_dataset.py @@ -34,6 +34,18 @@ def _validate_existence_of_table(self) -> None: "If the external table does not exists, the `location` parameter must be provided. " "This should be valid path in an external location that has already been created." ) + + def _validate_write_mode_for_format(self) -> None: + """Validates that the write mode is compatible with the format. + + Raises: + DatasetError: If the write mode is not compatible with the format. + """ + if self.write_mode == "upsert" and self.format != "delta": + raise DatasetError( + f"Format '{self.format}' is not supported for upserts. " + f"Please use 'delta' format." + ) class ExternalTableDataset(BaseTableDataset):