Skip to content

Commit

Permalink
moved the val func for checking if write_mode supported to ExternalTable
Browse files Browse the repository at this point in the history
Signed-off-by: Minura Punchihewa <minurapunchihewa17@gmail.com>
  • Loading branch information
MinuraPunchihewa committed Sep 8, 2024
1 parent b03bee8 commit dc3550e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions kedro-datasets/kedro_datasets/databricks/external_table_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit dc3550e

Please sign in to comment.