Class MergeIntoWriter<T>
- Type Parameters:
- T- the type of data in the Dataset. param: table the name of the target table for the merge operation. param: ds the source Dataset to merge into the target table. param: on the merge condition. param: schemaEvolutionEnabled whether to enable automatic schema evolution for this merge operation. Default is- false.
MergeIntoWriter provides methods to define and execute merge actions based
 on specified conditions.
 - Since:
- 4.0.0
- 
Method SummaryModifier and TypeMethodDescriptionvoidmerge()Executes the merge operation.Initialize aWhenMatchedaction without any condition.whenMatched(Column condition) Initialize aWhenMatchedaction with a condition.Initialize aWhenNotMatchedaction without any condition.whenNotMatched(Column condition) Initialize aWhenNotMatchedaction with a condition.Initialize aWhenNotMatchedBySourceaction without any condition.whenNotMatchedBySource(Column condition) Initialize aWhenNotMatchedBySourceaction with a condition.Enable automatic schema evolution for this merge operation.
- 
Method Details- 
whenMatchedInitialize aWhenMatchedaction without any condition.This WhenMatchedaction will be executed when a source row matches a target table row based on the merge condition.This WhenMatchedcan be followed by one of the following merge actions: -updateAll: Update all the matched target table rows with source dataset rows. -update(Map): Update all the matched target table rows while changing only a subset of columns based on the provided assignment. -delete: Delete all target rows that have a match in the source table.- Returns:
- a new WhenMatchedobject.
 
- 
whenMatchedInitialize aWhenMatchedaction with a condition.This WhenMatchedaction will be executed when a source row matches a target table row based on the merge condition and the specifiedconditionis satisfied.This WhenMatchedcan be followed by one of the following merge actions: -updateAll: Update all the matched target table rows with source dataset rows. -update(Map): Update all the matched target table rows while changing only a subset of columns based on the provided assignment. -delete: Delete all target rows that have a match in the source table.- Parameters:
- condition- a- Columnrepresenting the condition to be evaluated for the action.
- Returns:
- a new WhenMatchedobject configured with the specified condition.
 
- 
whenNotMatchedInitialize aWhenNotMatchedaction without any condition.This WhenNotMatchedaction will be executed when a source row does not match any target row based on the merge condition.This WhenNotMatchedcan be followed by one of the following merge actions: -insertAll: Insert all rows from the source that are not already in the target table. -insert(Map): Insert all rows from the source that are not already in the target table, with the specified columns based on the provided assignment.- Returns:
- a new WhenNotMatchedobject.
 
- 
whenNotMatchedInitialize aWhenNotMatchedaction with a condition.This WhenNotMatchedaction will be executed when a source row does not match any target row based on the merge condition and the specifiedconditionis satisfied.This WhenNotMatchedcan be followed by one of the following merge actions: -insertAll: Insert all rows from the source that are not already in the target table. -insert(Map): Insert all rows from the source that are not already in the target table, with the specified columns based on the provided assignment.- Parameters:
- condition- a- Columnrepresenting the condition to be evaluated for the action.
- Returns:
- a new WhenNotMatchedobject configured with the specified condition.
 
- 
whenNotMatchedBySourceInitialize aWhenNotMatchedBySourceaction without any condition.This WhenNotMatchedBySourceaction will be executed when a target row does not match any rows in the source table based on the merge condition.This WhenNotMatchedBySourcecan be followed by one of the following merge actions: -updateAll: Update all the not matched target table rows with source dataset rows. -update(Map): Update all the not matched target table rows while changing only the specified columns based on the provided assignment. -delete: Delete all target rows that have no matches in the source table.- Returns:
- a new WhenNotMatchedBySourceobject.
 
- 
whenNotMatchedBySourceInitialize aWhenNotMatchedBySourceaction with a condition.This WhenNotMatchedBySourceaction will be executed when a target row does not match any rows in the source table based on the merge condition and the specifiedconditionis satisfied.This WhenNotMatchedBySourcecan be followed by one of the following merge actions: -updateAll: Update all the not matched target table rows with source dataset rows. -update(Map): Update all the not matched target table rows while changing only the specified columns based on the provided assignment. -delete: Delete all target rows that have no matches in the source table.- Parameters:
- condition- a- Columnrepresenting the condition to be evaluated for the action.
- Returns:
- a new WhenNotMatchedBySourceobject configured with the specified condition.
 
- 
withSchemaEvolutionEnable automatic schema evolution for this merge operation.- Returns:
- A MergeIntoWriterinstance with schema evolution enabled.
 
- 
mergepublic void merge()Executes the merge operation.
 
-