@@ -331,11 +331,26 @@ def _merge_iceberg(
331331 source_table: str
332332 AWS Glue/Athena source table name.
333333 merge_cols: List[str], optional
334- List of column names that will be used for conditional inserts and updates.
334+ List of column names that will be used for conditional inserts and updates. Cannot be used together with ``merge_on_clause``.
335335
336336 https://docs.aws.amazon.com/athena/latest/ug/merge-into-statement.html
337+ merge_on_clause: str, optional
338+ Custom ON clause for the MERGE statement. If specified, this string will be used as the ON condition
339+ between the target and source tables, allowing for complex join logic beyond simple equality on columns.
340+ Cannot be used together with ``merge_cols``.
337341 merge_condition: str, optional
338- The condition to be used in the MERGE INTO statement. Valid values: ['update', 'ignore'].
342+ The condition to be used in the MERGE INTO statement. Valid values: ['update', 'ignore', 'conditional_merge'].
343+ - 'update': Update matched rows and insert non-matched rows.
344+ - 'ignore': Only insert non-matched rows.
345+ - 'conditional_merge': Use custom conditional clauses for merge actions.
346+ merge_conditional_clauses : List[dict], optional
347+ List of dictionaries specifying custom conditional clauses for the MERGE statement.
348+ Each dictionary should have:
349+ - 'when': One of ['MATCHED', 'NOT MATCHED', 'NOT MATCHED BY SOURCE']
350+ - 'condition': (optional) Additional SQL condition for the clause
351+ - 'action': One of ['UPDATE', 'DELETE', 'INSERT']
352+ - 'columns': (optional) List of columns to update or insert
353+ Used only when merge_condition is 'conditional_merge'.
339354 merge_match_nulls: bool, optional
340355 Instruct whether to have nulls in the merge condition match other nulls
341356 kms_key : str, optional
@@ -504,8 +519,20 @@ def to_iceberg( # noqa: PLR0913
504519 List of column names that will be used for conditional inserts and updates.
505520
506521 https://docs.aws.amazon.com/athena/latest/ug/merge-into-statement.html
522+ merge_on_clause
523+ Custom ON clause for the MERGE statement. If specified, this string will be used as the ON condition
524+ between the target and source tables, allowing for complex join logic beyond simple equality on columns.
525+ Cannot be used together with ``merge_cols``.
507526 merge_condition
508- The condition to be used in the MERGE INTO statement. Valid values: ['update', 'ignore'].
527+ The condition to be used in the MERGE INTO statement. Valid values: ['update', 'ignore', 'conditional_merge'].
528+ merge_conditional_clauses
529+ List of dictionaries specifying custom conditional clauses for the MERGE statement.
530+ Each dictionary should have:
531+ - 'when': One of ['MATCHED', 'NOT MATCHED', 'NOT MATCHED BY SOURCE']
532+ - 'action': One of ['UPDATE', 'DELETE', 'INSERT']
533+ - 'condition': (optional) Additional SQL condition for the clause
534+ - 'columns': (optional) List of columns to update or insert
535+ Used only when merge_condition is 'conditional_merge'.
509536 merge_match_nulls
510537 Instruct whether to have nulls in the merge condition match other nulls
511538 keep_files
0 commit comments