|
14 | 14 | from awswrangler import _data_types, _utils, catalog, exceptions, s3 |
15 | 15 | from awswrangler._config import apply_configs |
16 | 16 | from awswrangler.athena._executions import wait_query |
17 | | -from awswrangler.athena._utils import _get_workgroup_config, _start_query_execution, _WorkGroupConfig, _MergeClause |
| 17 | +from awswrangler.athena._utils import _get_workgroup_config, _MergeClause, _start_query_execution, _WorkGroupConfig |
18 | 18 | from awswrangler.typing import GlueTableSettings |
19 | 19 |
|
20 | 20 | _logger: logging.Logger = logging.getLogger(__name__) |
@@ -228,6 +228,29 @@ def _validate_args( |
228 | 228 | "Either path or workgroup path must be specified to store the temporary results." |
229 | 229 | ) |
230 | 230 |
|
| 231 | + _validate_merge_arguments( |
| 232 | + merge_cols, merge_on_clause, merge_condition, |
| 233 | + merge_conditional_clauses, merge_match_nulls |
| 234 | + ) |
| 235 | + |
| 236 | + if mode == "overwrite_partitions": |
| 237 | + if not partition_cols: |
| 238 | + raise exceptions.InvalidArgumentCombination( |
| 239 | + "When mode is 'overwrite_partitions' partition_cols must be specified." |
| 240 | + ) |
| 241 | + if merge_cols: |
| 242 | + raise exceptions.InvalidArgumentCombination( |
| 243 | + "When mode is 'overwrite_partitions' merge_cols must not be specified." |
| 244 | + ) |
| 245 | + |
| 246 | + |
| 247 | +def _validate_merge_arguments( |
| 248 | + merge_cols: list[str] | None, |
| 249 | + merge_on_clause: str | None, |
| 250 | + merge_condition: Literal["update", "ignore", "conditional_merge"], |
| 251 | + merge_conditional_clauses: list[_MergeClause] | None, |
| 252 | + merge_match_nulls: bool, |
| 253 | +) -> None: |
231 | 254 | if merge_cols and merge_on_clause: |
232 | 255 | raise exceptions.InvalidArgumentCombination( |
233 | 256 | "Cannot specify both merge_cols and merge_on_clause. Use either merge_cols for simple equality matching or merge_on_clause for custom logic." |
@@ -275,16 +298,6 @@ def _validate_args( |
275 | 298 | "WHEN MATCHED must come before WHEN NOT MATCHED or WHEN NOT MATCHED BY SOURCE." |
276 | 299 | ) |
277 | 300 |
|
278 | | - if mode == "overwrite_partitions": |
279 | | - if not partition_cols: |
280 | | - raise exceptions.InvalidArgumentCombination( |
281 | | - "When mode is 'overwrite_partitions' partition_cols must be specified." |
282 | | - ) |
283 | | - if merge_cols: |
284 | | - raise exceptions.InvalidArgumentCombination( |
285 | | - "When mode is 'overwrite_partitions' merge_cols must not be specified." |
286 | | - ) |
287 | | - |
288 | 301 |
|
289 | 302 | def _merge_iceberg( |
290 | 303 | df: pd.DataFrame, |
|
0 commit comments